Adding new tables to an existing Oracle GoldenGate replication
Once a replication environment is set up, it’s rarely forever. Adding tables to an Oracle GoldenGate replication group with minimal impact to the current replication is quite a difficult operation. This posting should help you with this task.
In the example below, tables from schema G001 will be added to an existing replication setup from the database PROD1 to REP1.
1
2
3
4
5
| CFG_ADV_CONDCFG_NARRATIVE_TEMPLATECFG_REG_REPORT_RULESCMN_LOOKUPCMN_USER_LOGIN |
Stop the replication environment
- Connect to the source database PROD1 and stop all extract groups for the replication to the database REP1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| oracle@server1:~/ [PROD1] PROD1oracle@server1:~/ [PROD1] cdghoracle@server1:/u99/app/goldengate/gss/11.1.1.1.0/ [PROD1] ggsciGGSCI (server1) 1> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING DPG001 00:00:00 00:00:06EXTRACT RUNNING G001 00:00:00 00:00:05GGSCI (server1) 2> stop extract *Program Status Group Lag Time Since ChkptMANAGER RUNNINGEXTRACT STOPPED DPG001 00:00:00 00:00:01EXTRACT STOPPED G001 00:00:00 00:00:13 |
- Connect to the target database REP1 and stop the replicat group coming from the database PROD1
1
2
3
4
5
6
7
8
9
10
11
12
| GGSCI (server2) 1> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGREPLICAT RUNNING PROD1 00:00:00 00:00:04GGSCI (server2) 2> stop REPLICAT PROD1GGSCI (server2) 3> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGREPLICAT STOPPED PROD1 00:00:00 00:00:04 |
Update the extract environment with the new tables
- Now we can update the extract group G001 on the source database with the new tables to be replicated. Edit the G001 parameter file and add the new tables (vi editor)
1
2
3
4
5
6
7
| GGSCI (server1) 30> edit params G001. . . table G001SCHEMA.CFG_ADV_COND;table G001SCHEMA.CFG_NARRATIVE_TEMPLATE;table G001SCHEMA.CFG_REG_REPORT_RULES;table G001SCHEMA.CMN_LOOKUP;table G001SCHEMA.CMN_USER_LOGIN; |
- Add supplemental login on source database PROD1 for the new added tables
1
2
3
4
5
6
7
8
| GGSCI (server1) 7> DBLOGIN userid goldengate, password ******Successfully logged into database.GGSCI (server1) 8> add trandata G001SCHEMA.CFG_ADV_CONDGGSCI (server1) 9> add trandata G001SCHEMA.CFG_NARRATIVE_TEMPLATEGGSCI (server1) 10> add trandata G001SCHEMA.CFG_REG_REPORT_RULESGGSCI (server1) 11> add trandata G001SCHEMA.CMN_LOOKUPGGSCI (server1) 13> add trandata G001SCHEMA.CMN_USER_LOGIN |
- Configure the source database to extract the additional five tables and we can restart the corresponding extract groups
1
2
3
4
5
6
| GGSCI (server1) 30> start extract *GGSCI (server1) 31> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGEXTRACT RUNNING DPG001 00:23:02 00:00:03EXTRACT RUNNING G001 00:00:00 00:00:06 |
Initial Load from the new tables
As the addtional tables from the source database PROD1 are extracted, the initial load (expdp/impdp) from the data can be started on the target database REP1.
Attention, we have to start the export for a specific transaction point (SCN) , in order to begin the replication target database from the same SCN.
Attention, we have to start the export for a specific transaction point (SCN) , in order to begin the replication target database from the same SCN.
Thus we have to going to read the current_scn from the source database for the synchronization (explained later).
1
2
3
4
5
| SQL> select current_scn from v$database;CURRENT_SCN----------- 1657153626 |
- Create an expdp parfile with the above selected SCN and the additional tables to replicate
1
2
3
4
5
6
7
8
| oracle@server1:~/app/oracle/admin/PROD1/create/goldengate/add_tables [PROD1] cat expdp_additional_tables.parflashback_scn=1657153626SCHEMAS=G001SCHEMADUMPFILE=export_tables_G001SCHEMA.dmpLOGFILE=export_tables_G001SCHEMA.logINCLUDE=TABLE:"IN('CFG_ADV_COND','CFG_NARRATIVE_TEMPLATE','CFG_REG_REPORT_RULES','CMN_LOOKUP','CMN_USER_LOGIN')"DIRECTORY=DATAPUMPDIR |
- Start the export from the above tables as user system
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
| oracle@server1:~/app/oracle/admin/PROD1/create/goldengate/ [PROD1] expdp parfile=expdp_additional_tables.parUsername: systemPassword:Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsFLASHBACK automatically enabled to preserve database integrity.Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/******** parfile=expdp_additional_tables.parEstimate in progress using BLOCKS method...Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATATotal estimation using BLOCKS method: 21.25 MBProcessing object type SCHEMA_EXPORT/TABLE/TABLEProcessing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANTProcessing object type SCHEMA_EXPORT/TABLE/INDEX/INDEXProcessing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINTProcessing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICSProcessing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINTProcessing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS. . exported "G001SCHEMA"."CMN_USER_LOGIN" 8.735 MB 286163 rows. . exported "G001SCHEMA"."CFG_ADV_COND" 1.523 MB 1617 rows. . exported "G001SCHEMA"."CFG_REG_REPORT_RULES" 100.5 KB 714 rows. . exported "G001SCHEMA"."CFG_NARRATIVE_TEMPLATE" 9.789 KB 85 rows. . exported "G001SCHEMA"."CMN_LOOKUP" 6.585 KB 4 rowsMaster table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded******************************************************************************Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is: /u00/app/oracle/admin/PROD1/dmp/export_ARGUS_tables_G001SCHEMA.dmpJob "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 11:01:22 |
- Copy the dumpfile from server1 to server2
1
2
3
| oracle@server1:~/app/oracle/admin/PROD1/create/goldengate/ [PROD1] scp /u00/app/oracle/admin/PROD1/dmp/export_tables_G001SCHEMA.dmp oracle@server2:~/app/oracle/admin/REP1/dmp/export_tables_G001SCHEMA.dmp 100% 11MB 10.7MB/s 00:00 |
- Create an impdp parfile in order to load the tables from the above created dumpfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| Take care: the correct REMAP and EXCLUDE parameter must be configured based on your environment requirementoracle@server2:~/app/oracle/admin/REP1/create/goldengate/add_tables/ [REP1] cat impdp_PROD1_tables.parDUMPFILE=export_tables_G001SCHEMA.dmpLOGFILE=import_tables_G001SCHEMA.logREMAP_SCHEMA=G001SCHEMA:G001_PROD1REMAP_TABLESPACE=DATA_01:PROD1_DATAREMAP_TABLESPACE=DATA_02:PROD1_DATAREMAP_TABLESPACE=INDEX_01:PROD1_DATAREMAP_TABLESPACE=INDEX_02:PROD1_DATADIRECTORY=DATAPUMPDIREXCLUDE=GRANTEXCLUDE=CONSTRAINTEXCLUDE=REF_CONSTRAINT |
- Start the import with impdp as user system using the above parameter file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| oracle@server2:~/app/oracle/admin/REP1/create/goldengate/add_tables/ [REP1] impdp parfile=impdp_PROD1_tables.parUsername: systemPassword:Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit ProductionWith the Partitioning, Oracle Label Security, OLAP, Data Mining,Oracle Database Vault and Real Application Testing optionsMaster table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloadedStarting "SYSTEM"."SYS_IMPORT_FULL_01": system/******** parfile=impdp_PROD1_tables.parProcessing object type SCHEMA_EXPORT/TABLE/TABLEProcessing object type SCHEMA_EXPORT/TABLE/TABLE_DATA. . imported "G001_PROD1"."CMN_USER_LOGIN" 8.735 MB 286163 rows. . imported "G001_PROD1"."CFG_ADV_COND" 1.523 MB 1617 rows. . imported "G001_PROD1"."CFG_REG_REPORT_RULES" 100.5 KB 714 rows. . imported "G001_PROD1"."CFG_NARRATIVE_TEMPLATE" 9.789 KB 85 rows. . imported "G001_PROD1"."CMN_LOOKUP" 6.585 KB 4 rowsProcessing object type SCHEMA_EXPORT/TABLE/INDEX/INDEXProcessing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICSProcessing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICSJob "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at 11:49:06 |
Add temporary the new tables to replication group
Now the new tables to replicate can be temporary add to the replication group PROD1 with the above selected SCN number, as starting point for the replication.
Attention: Within the GoldenGate configuration file we speak about CSN and not SCN, but both contains the same information (System Change Number).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| oracle@server2:~/app/goldengate/ggs/11.1.1.1.0/[REP1] ggsciGGSCI (server2)> edit params PROD1REPLICAT PROD1ASSUMETARGETDEFSUSERID goldengate, PASSWORD *****DISCARDFILE /u00/app/goldengate/ggs/11.1.1.1.0/discard/PROD1_discard.txt, append, megabytes 10MAP G001schema.CFG_ADV_COND ,TARGET G001_PROD1.CFG_ADV_COND ,FILTER ( @GETENV ("TRANSACTION", "CSN") > 1657153626);MAP G001schema.CFG_NARRATIVE_TEMPLATE ,TARGET G001_PROD1.CFG_NARRATIVE_TEMPLATE ,FILTER ( @GETENV ("TRANSACTION", "CSN") > 1657153626);MAP G001schema.CFG_REG_REPORT_RULES ,TARGET G001_PROD1.CFG_REG_REPORT_RULES ,FILTER ( @GETENV ("TRANSACTION", "CSN") > 1657153626);MAP G001schema.CMN_LOOKUP ,TARGET G001_PROD1.CMN_LOOKUP ,FILTER ( @GETENV ("TRANSACTION", "CSN") > 1657153626);MAP G001schema.CMN_USER_LOGIN ,TARGET G001_PROD1.CMN_USER_LOGIN ,FILTER ( @GETENV ("TRANSACTION", "CSN") > 1657153626);MAP G001schema.*, TARGET G001_PROD1.* |
- Start the replication group PROD1 with the new added tables
1
2
3
4
| GGSCI (server2) 2> start replicat PROD1Sending START request to MANAGER ...REPLICAT PROD1 starting |
- Check the configuration until the both databases are synchronised
1
2
3
4
| GGSCI (server2) 1> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGREPLICAT RUNNING PROD1 00:00:00 00:00:00 |
Remove the temporary added new tables from the replication group file
As both databases are again synchronized including the new tables, the temporary added filter can be removed from the replication group file.
- Stop the replication group PROD1
GGSCI (server2) 4> stop replicat PROD1- Set back the original extraction configuration file for the froup PROD, without the filters for the new files
1
2
3
4
5
6
7
8
9
| oracle@server2:~/app/goldengate/ggs/11.1.1.1.0/[REP1] ggsciGGSCI (server2) 2> edit params PROD1REPLICAT PROD1ASSUMETARGETDEFSUSERID goldengate, PASSWORD *****DISCARDFILE /u00/app/goldengate/ggs/11.1.1.1.0/discard/PROD1_discard.txt, append, megabytes 10MAP G001schema.*, TARGET G001_PROD1.* |
- Restart the replication
1
2
3
4
5
6
| GGSCI (server2) 3> start REPLICAT PROD1GGSCI (server2) 4> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGREPLICAT RUNNING PROD1 00:00:00 00:00:00 |
=============================================================================
Comments
Post a Comment
Oracle DBA Information