Performing an initial load with GoldenGate – expdp/impdp
The last post in this series outlined on how to do an initial load of the target database using the “file to replicat” method:
- Installing and patching Oracle GoldenGate 12c to the latest release
- Setting up a sample replication with GoldenGate
- Performing an initial load with GoldenGate (1) – file to replicat
In this post I’ll show how to do the initial load by exporting a schema from the source database, importing that into the target and then start the re-synchronization in GoldenGate.
The initial setup on the source and the target is almost the same. But first lets delete all objects of “HR” in the target database:
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 | declare  lv_statement varchar2(2000);begin  forr in( selectobject_name,object_type fromdba_objects whereowner='HR')  loop    caser.object_type      when'TABLE'thenlv_statement := 'drop table hr.'||r.object_name||' cascade constraints';      when'VIEW'thenlv_statement := 'drop view hr.'||r.object_name;      when'SEQUENCE'thenlv_statement := 'drop sequence hr.'||r.object_name;      when'PROCEDURE'thenlv_statement := 'drop procedure hr.'||r.object_name;      elselv_statement := null;    endcase;    begin      dbms_output.put_line(lv_statement);      executeimmediate lv_statement;    exception whenothers thennull;    end;  endloop;end;/selectcount(*) fromdba_objects whereowner='HR'; | 
Exactly as in the last post lets setup the initial recording of transactions on the source and target databases. Not much explanation here as all the steps were already covered in the last post.
On the source:
| 
1 
2 
3 
4 
5 | GGSCI (oelgg1.it.dbi-services.com) 1> dblogin useridalias DB1 domain adminSuccessfully logged into database.GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 2> add trandata HR.*GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 2> edit params extrcdc1 | 
The parameters are:
| 
1 
2 
3 
4 
5 
6 
7 | EXTRACT extrcdc1USERIDALIAS DB1 domain adminEXTTRAIL ./dirdat/ggLOGALLSUPCOLSUPDATERECORDFORMAT compactTABLE hr.*;TABLEEXCLUDE HR.EMP_DETAILS_VIEW; | 
Next steps (as in the last post):
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 | GGSCI (oelgg1.it.dbi-services.com) 4> dblogin useridalias DB1 domain admin GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 5> register extract extrcdc1 databaseExtract EXTRCDC1 successfully registered with database at SCN 1863433. GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 6> add extract extrcdc1, integrated tranlog, begin nowEXTRACT added. GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 7> add exttrail ./dirdat/gg, extract extrcdc1, megabytes 5EXTTRAIL added.GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 10> edit params dppump1 | 
Parameters:
| 
1 
2 
3 
4 
5 
6 | EXTRACT dppump1PASSTHRURMTHOST oelgg2, MGRPORT 7809RMTTRAIL ./dirdat/jjTABLE hr.*;TABLEEXCLUDE HR.EMP_DETAILS_VIEW; | 
Next steps (as in the last post)
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 | GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 12> add extract dppump1, exttrailsource ./dirdat/ggEXTRACT added. GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 13> add rmttrail ./dirdat/jj, extract dppump1, megabytes 5RMTTRAIL added. GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 23> start extract * Sending START request to MANAGER ...EXTRACT DPPUMP1 starting Sending START request to MANAGER ...EXTRACT EXTRCDC1 starting GGSCI (oelgg1.it.dbi-services.com as ggadmin@DB1) 24> info all Program     Status      Group       Lag at Chkpt  Time Since Chkpt MANAGER     RUNNING                                           EXTRACT     RUNNING     DPPUMP1     00:00:00      00:00:02    EXTRACT     RUNNING     EXTRCDC1    00:00:07      00:00:07     | 
On the target system (as in the last post):
| 
1 | GGSCI (oelgg2.it.dbi-services.com as ggadmin@DB2) 26> edit params rplcdd | 
Parameters:
| 
1 
2 
3 
4 
5 | REPLICAT replcddASSUMETARGETDEFSDISCARDFILE ./dirrpt/replccd.dsc, purgeUSERIDALIAS DB2 domain adminMAP hr.*, TARGET hr.*; | 
Configure the replicat (as in the last post):
| 
1 
2 
3 
4 | GGSCI (oelgg2.it.dbi-services.com) 1> dblogin useridalias DB2 domain adminSuccessfully logged into database. GGSCI (oelgg2.it.dbi-services.com as ggadmin@DB2) 2> add replicat replcdd, integrated, exttrail ./dirdat/jj | 
Record the SCN of the source database:
| 
1 
2 
3 
4 
5 | SQL> selectcurrent_scn fromv$database;CURRENT_SCN-----------    2040227 | 
Having the scn we can now do an export of the “HR” schema on the source:
| 
1 
2 
3 
4 
5 | SQL> createorreplacedirectory gg as'/var/tmp';Directory created.SQL> !expdp userid="' / as sysdba'"schemas=hr dumpfile=exphr.dmp logfile=exphr.log directory=gg flashback_scn=2040227 | 
Transfer this to the target environment and do the import:
| 
1 
2 
3 
4 
5 | SQL> createorreplacedirectory gg as'/var/tmp';Directory created.SQL> !impdp userid="' / as sysdba'"schemas=hr dumpfile=exphr.dmp logfile=imphr.log directory=gg | 
The rest is the same as in the last post. Start the replicat on the target:
| 
1 
2 
3 
4 | GGSCI (oelgg2.it.dbi-services.com) 6> start replicat REPLCDD, aftercsn 2040227Sending START request to MANAGER ...REPLICAT REPLCDD starting | 
Do some modifications on the source:
| 
1 
2 
3 
4 
5 | SQL> updatehr.countries setCOUNTRY_NAME = 'Zimbabwe11'whereCOUNTRY_NAME = 'Zimbabwe10';1 row updated.SQL> commit; | 
And then check the modification on the target:
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 | SQL> select* fromhr.countries wherecountry_name like'%Zimba%';CO COUNTRY_NAME                  REGION_ID-- ---------------------------------------- ----------ZW Zimbabwe11                        4SQL> selectinstance_name fromv$instance;INSTANCE_NAME----------------DB2SQL>  | 
Quite easy if you get the basic steps for configuring the replicat and extracts right.
The next post will look into how you can suspend replication for end of day processing and restart it afterwards automatically.
The next post will look into how you can suspend replication for end of day processing and restart it afterwards automatically.
 
No comments:
Post a Comment