Looking for something? Try here..

Sunday, August 23, 2015

OGG sample real time demo

This post gives a real time demo of Oracle GoldenGate replication. For complete installation and set up, see this link

Terminologies used
OGG_source $ -- refers commands executed from source server
OGG_target $ -- refers commands executed from target server
SQL@OGG_source > -- refers commands executed from source SQLPLUS terminal
SQL@OGG_target > -- refers commands executed from target SQLPLUS terminal
GGSCI (source) -- refers commands executed from source GGSCI terminal
GGSCI (target) -- refers commands executed from target GGSCI terminal

At line 69, the initial extract is started from OS as a background process. The reason being the initial extract might run for hours depending on the amount of data it has to unload from the source database and hence to let it run without any issues till it completes, we are starting the process as a background process.
Also we are grepping the start time of the extract at line 74 to use it at a later time in the replication operation. See line 245 where this captured time is used.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
OGG_source $ cd $GGH
OGG_source $ ggsci
 
Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1 13067027
Solaris, sparc, 64bit (optimized), Oracle 9i on Oct 14 2011 08:02:21
 
Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
 
 
 
GGSCI (source) 1> info all
 
Program     Status      Group       Lag           Time Since Chkpt
 
MANAGER     RUNNING
 
 
GGSCI (source) 2> ADD EXTRACT DEMO1E, TRANLOG, THREADS 2, BEGIN NOW
EXTRACT added.
 
 
GGSCI (source) 3> ADD EXTTRAIL /backup/PRNETSDB/ogg/11.1/dirdat/ea, EXTRACT DEMO1E, Megabytes 200
EXTTRAIL added.
 
 
GGSCI (source) 4> start extract DEMO1E
 
Sending START request to MANAGER ...
EXTRACT DEMO1E starting
 
 
GGSCI (source) 5> info all
 
Program     Status      Group       Lag           Time Since Chkpt
 
MANAGER     RUNNING
EXTRACT     RUNNING     DEMO1E      00:00:07      00:00:06
 
 
GGSCI (source) 6> ADD EXTRACT DEMO1P, EXTTRAILSOURCE /backup/PRNETSDB/ogg/11.1/dirdat/ea
EXTRACT added.
 
 
GGSCI (source) 7> ADD RMTTRAIL /backup/gg_kt/ogg/11.2/dirdat/pa, EXTRACT DEMO1P, Megabytes 100
RMTTRAIL added.
 
 
GGSCI (source) 8> start extract DEMO1P
 
Sending START request to MANAGER ...
EXTRACT DEMO1P starting
 
 
GGSCI (source) 9> info all
 
Program     Status      Group       Lag           Time Since Chkpt
 
MANAGER     RUNNING
EXTRACT     RUNNING     DEMO1E      00:00:00      00:00:06
EXTRACT     RUNNING     DEMO1P      00:00:00      00:00:22
 
 
GGSCI (source) 10> ADD EXTRACT DEMO1I, sourceistable
EXTRACT added.
 
 
GGSCI (source) 11> exit
OGG_source $ nohup extract paramfile $GGH/dirprm/DEMO1I.prm reportfile $GGH/dirrpt/DEMO1I.rpt > DEMO1I.out 2>&1 &
[1]     17810
OGG_source $
[1] +  Done                    nohup extract paramfile $GGH/dirprm/DEMO1I.prm reportfile $GGH/dirrpt/DEMO1I.rpt > DEMO1I.out 2>&1 &
OGG_source $ cd dirrpt
OGG_source $ more DEMO1I.rpt|grep "Starting at"
                    Starting at 2015-08-07 08:02:26
OGG_source $ sqlplus "/ as sysdba"
 
SQL*Plus: Release 9.2.0.7.0 - Production on Fri Aug 7 08:03:15 2015
 
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
 
 
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production
 
SQL@OGG_source > select count(*) from sdas.ogg_test;
 
  COUNT(*)
----------
      7004
 
********** Operation on Target system starts here **********
 
SQL@OGG_target > select count(*) from sdas.tgt_ogg_test;
 
  COUNT(*)
----------
         0
 
SQL@OGG_target > !
OGG_target $ cd $GGH
OGG_target $ ggsci
 
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.17 17888650 OGGCORE_11.2.1.0.0OGGBP_PLATFORMS_131215.2328_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Dec 16 2013 03:43:25
 
Copyright (C) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
 
 
 
GGSCI (target) 1> add rep TDEMO1I, exttrail /backup/gg_kt/ogg/11.2/dirdat/ia, nodbcheckpoint
REPLICAT added.
 
 
GGSCI (target) 2> start replicat TDEMO1I
 
Sending START request to MANAGER ...
REPLICAT TDEMO1I starting
 
 
GGSCI (target) 3> info all
 
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
 
MANAGER     RUNNING
REPLICAT    RUNNING     TDEMO1I     00:00:00      00:00:01
 
 
GGSCI (target) 4> stats replicat TDEMO1I
 
Sending STATS request to REPLICAT TDEMO1I ...
 
Start of Statistics at 2015-08-07 08:08:46.
 
Replicating from SDAS.OGG_TEST to SDAS.TGT_OGG_TEST:
 
*** Total statistics since 2015-08-07 08:08:29 ***
        Total inserts                                   7004.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                7004.00
 
*** Daily statistics since 2015-08-07 08:08:29 ***
        Total inserts                                   7004.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                7004.00
 
*** Hourly statistics since 2015-08-07 08:08:29 ***
        Total inserts                                   7004.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                7004.00
 
*** Latest statistics since 2015-08-07 08:08:29 ***
        Total inserts                                   7004.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                7004.00
 
End of Statistics.
 
 
GGSCI (target) 5> send rep TDEMO1I, getlag
 
Sending GETLAG request to REPLICAT TDEMO1I ...
Last record lag: 359 seconds.
At EOF, no more records to process.
 
 
GGSCI (target) 6> stop rep TDEMO1I
 
Sending STOP request to REPLICAT TDEMO1I ...
Request processed.
 
 
GGSCI (target) 7> exit
OGG_target $ exit
exit
 
SQL@OGG_target > select count(*) from sdas.tgt_ogg_test;
 
  COUNT(*)
----------
      7004
 
********** Insert and update some values in the source ************
 
SQL@OGG_source > insert into sdas.ogg_test values (20202,'Selvakumar Nagulan',sysdate,'N',20202);
 
1 row created.
 
SQL@OGG_source > update sdas.ogg_test set emp_name='Priyanka' where emp_id=7000;
 
1 row updated.
 
SQL@OGG_source > commit;
 
Commit complete.
 
SQL@OGG_source > select count(*) from sdas.ogg_test;
 
  COUNT(*)
----------
      7005
 
*********** Check the changes in target which still didn't reflect here ***********
*********** Do the rest of OGG operations to enable real time sync ****************
 
SQL@OGG_target > select * from sdas.tgt_ogg_test where emp_id=7000;
 
EMP_ID     EMP_NAME                                           JOINDATE  S     SALARY
---------- -------------------------------------------------- --------- - ----------
7000       Priya                                              20-MAY-15 A       7000
 
SQL@OGG_target > select * from sdas.tgt_ogg_test where emp_id=20202;
 
no rows selected
 
SQL@OGG_target > !
OGG_target $ ggsci
 
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.17 17888650 OGGCORE_11.2.1.0.0OGGBP_PLATFORMS_131215.2328_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Dec 16 2013 03:43:25
 
Copyright (C) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
 
 
 
GGSCI (target) 1> dblogin userid ggs_dba password ggs_dba
Successfully logged into database.
 
GGSCI (target) 2> ADD REPLICAT DEMO1R, EXTTRAIL /backup/gg_kt/ogg/11.2/dirdat/pa, checkpointtable ggs_dba.CHECKPOINT
REPLICAT added.
 
 
GGSCI (target) 3> ALTER REPLICAT DEMO1R, BEGIN 2015-08-07 08:02:26
REPLICAT altered.
 
 
GGSCI (target) 4> start replicat DEMO1R
 
Sending START request to MANAGER ...
REPLICAT DEMO1R starting
 
 
GGSCI (target) 5> info all
 
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
 
MANAGER     RUNNING
REPLICAT    RUNNING     DEMO1R      00:06:19      00:00:08
REPLICAT    STOPPED     TDEMO1I     00:00:00      00:02:48
 
 
GGSCI (target) 6> stats rep DEMO1R
 
Sending STATS request to REPLICAT DEMO1R ...
 
Start of Statistics at 2015-08-07 08:12:03.
 
Replicating from SDAS.OGG_TEST to SDAS.TGT_OGG_TEST:
 
*** Total statistics since 2015-08-07 08:11:44 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00
 
*** Daily statistics since 2015-08-07 08:11:44 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00
 
*** Hourly statistics since 2015-08-07 08:11:44 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00
 
*** Latest statistics since 2015-08-07 08:11:44 ***
        Total inserts                                      1.00
        Total updates                                      1.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00
 
End of Statistics.
 
 
GGSCI (target) 7> send rep DEMO1R, ggetlag
 
Sending GGETLAG request to REPLICAT DEMO1R ...
 
ERROR: unknown request.
 
2015-08-07 08:12:28  WARNING OGG-01742  Command sent to REPLICAT DEMO1R returned with an ERROR response.
 
 
GGSCI (target) 8> send rep DEMO1R, getlag
 
Sending GETLAG request to REPLICAT DEMO1R ...
Last record lag: 379 seconds.
At EOF, no more records to process.
 
 
GGSCI (target) 9> stop rep DEMO1R
 
Sending STOP request to REPLICAT DEMO1R ...
Request processed.
 
 
GGSCI (target) 10> exit
OGG_target $ exit
exit
 
SQL@OGG_target > select count(*) from sdas.tgt_ogg_test;
 
  COUNT(*)
----------
      7005
 
SQL@OGG_target > select * from sdas.tgt_ogg_test where emp_id=7000;
 
EMP_ID     EMP_NAME                                           JOINDATE  S     SALARY
---------- -------------------------------------------------- --------- - ----------
7000       Priyanka                                           20-MAY-15 A       7000
 
SQL@OGG_target > select * from sdas.tgt_ogg_test where emp_id=20202;
 
EMP_ID     EMP_NAME                                           JOINDATE  S     SALARY
---------- -------------------------------------------------- --------- - ----------
20202      Selvakumar Nagulan                                 07-AUG-15 N      20202
 
SQL@OGG_target > !
OGG_target $ ggsci
 
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.17 17888650 OGGCORE_11.2.1.0.0OGGBP_PLATFORMS_131215.2328_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Dec 16 2013 03:43:25
 
Copyright (C) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
 
 
 
GGSCI (target) 1> edit params DEMO1R
 
********* Here remove the HANDLECOLLISIONS line from the param file and start the replicat **********
 
GGSCI (target) 2> start rep DEMO1R
 
Sending START request to MANAGER ...
REPLICAT DEMO1R starting
 
 
GGSCI (target) 3> info all
 
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
 
MANAGER     RUNNING
REPLICAT    RUNNING     DEMO1R      00:00:00      00:00:06
REPLICAT    STOPPED     TDEMO1I     00:00:00      00:05:50
 
 
GGSCI (target) 4> exit
OGG_target $ exit
exit
 
********* The source and target are now in sync with real time replication enabled **********
 
SQL@OGG_source > insert into sdas.ogg_test values (30303,'Rafael Nadal',sysdate,'N',30303);
 
1 row created.
 
SQL@OGG_source > commit;
 
Commit complete.
 
SQL@OGG_source >
 
SQL@OGG_target >
SQL@OGG_target > select * from sdas.tgt_ogg_test where emp_id=30303;
 
EMP_ID     EMP_NAME                                           JOINDATE  S     SALARY
---------- -------------------------------------------------- --------- - ----------
30303      Rafael Nadal                                       07-AUG-15 N      30303
 
SQL@OGG_target >

Happy Replicating!!

No comments:

Post a Comment