In our earlier tutorial, we examined how to create a GoldenGate environment for initial data capture and load.
In this tutorial, we will see how by using GoldenGate change synchronization, changes that occur on the source (Oracle 11g on Linux) are applied near real time on the target (Oracle 11g on AIX). The table on the source is the EMP table in SCOTT schema which is being replicated to the EMP table in the target database SH schema.
These are the steps that we will take:
Create a GoldenGate Checkpoint table
Create an Extract group
Create a parameter file for the online Extract group
Create a Trail
Create a Replicat group
Create a parameter file for the online Replicat group
Create the GoldenGate Checkpoint table
GoldenGate maintains its own Checkpoints which is a known position in the trail file from where the Replicat process will start processing after any kind of error or shutdown. This ensures data integrity and a record of these checkpoints is either maintained in files stored on disk or table in the database which is the preferred option.
We can also create a single Checkpoint table which can used by all Replicat groups from the single or many GoldenGate instances.
In one of the earlier tutorials we had created the GLOBALS file. We now need to edit that GLOBALS file and add an entry for CHECKPOINTTABLE which will include the checkpoint table name which will be available to all Replicat processes via the EDIT PARAMS command.
GGSCI (devu007) 2> EDIT PARAMS ./GLOBALS
GGSCHEMA GGS_OWNER
CHECKPOINTTABLE GGS_OWNER.CHKPTAB
GGSCI (devu007) 4> DBLOGIN USERID ggs_owner, PASSWORD ggs_owner
Successfully logged into database.
GGSCI (devu007) 6> ADD CHECKPOINTTABLE GGS_OWNER.CHKPTAB
Successfully created checkpoint table GGS_OWNER.CHKPTAB.
apex:/u01/oracle/software/goldengate> sqlplus ggs_owner/ggs_owner SQL*Plus: Release 11.1.0.6.0 - Production on Mon Feb 8 09:02:19 2010 Copyright (c) 1982, 2007, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> desc chkptab Name Null? Type ----------------------------------------- -------- ---------------------------- GROUP_NAME NOT NULL VARCHAR2(8) GROUP_KEY NOT NULL NUMBER(19) SEQNO NUMBER(10) RBA NOT NULL NUMBER(19) AUDIT_TS VARCHAR2(29) CREATE_TS NOT NULL DATE LAST_UPDATE_TS NOT NULL DATE CURRENT_DIR NOT NULL VARCHAR2(255)
Create the Online Extract Group
GGSCI (redhat346.localdomain) 1> ADD EXTRACT ext1, TRANLOG, BEGIN NOW
EXTRACT added.
Create the Trail
We now create a trail – note that this path pertains to the GoldenGate software location on the target system and this is where the trail files will be created having a prefix ‘rt’ which will be used by the Replicat process also running on the target system
GGSCI (redhat346.localdomain) 2> ADD RMTTRAIL /u01/oracle/software/goldengate/dirdat/rt, EXTRACT ext1
RMTTRAIL added.
Create a parameter file for the online Extract group ext1
GGSCI (redhat346.localdomain) 3> EDIT PARAMS ext1
EXTRACT ext1
USERID ggs_owner, PASSWORD ggs_owner
RMTHOST devu007, MGRPORT 7809
RMTTRAIL /u01/oracle/software/goldengate/dirdat/rt
TABLE scott.emp;
ON TARGET SYSTEM
Create the online Replicat group
GGSCI (devu007) 7> ADD REPLICAT rep1, EXTTRAIL /u01/oracle/software/goldengate/dirdat/rt
REPLICAT added.
Note that the EXTTRAIL location which is on the target local system conforms to the RMTTRAIL parameter which we used when we created the parameter file for the extract process on the source system.
Create a parameter file for the online Replicat group, rep1
GGSCI (devu007) 8> EDIT PARAMS rep1
REPLICAT rep1
ASSUMETARGETDEFS
USERID ggs_owner, PASSWORD ggs_owner
MAP scott.emp, TARGET sh.emp;
ON SOURCE
Start the Extract process
GGSCI (redhat346.localdomain) 16> START EXTRACT ext1
Sending START request to MANAGER …
EXTRACT EXT1 starting
GGSCI (redhat346.localdomain) 17> STATUS EXTRACT ext1
EXTRACT EXT1: RUNNING
GGSCI (redhat346.localdomain) 16> INFO EXTRACT ext1
EXTRACT EXT1 Last Started 2010-02-08 14:27 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:09 ago)
Log Read Checkpoint Oracle Redo Logs
2010-02-08 14:27:48 Seqno 145, RBA 724480
ON TARGET
Start the Replicat process
GGSCI (devu007) 1> START REPLICAT rep1
Sending START request to MANAGER …
REPLICAT REP1 starting
GGSCI (devu007) 2> INFO REPLICAT rep1
REPLICAT REP1 Last Started 2010-02-08 14:55 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:01 ago)
Log Read Checkpoint File /u01/oracle/software/goldengate/dirdat/rt000001
2010-02-08 14:27:57.600425 RBA 1045
Note: the trail file has a prefix of ‘rt’ (which we had defined earlier)
LET US NOW TEST …
ON SOURCE
SQL> conn scott/tiger
Connected.
SQL> UPDATE emp SET sal=9999 WHERE ename=’KING’;
1 row updated.
SQL> COMMIT;
Commit complete.
ON TARGET
SQL> SELECT SAL FROM emp WHERE ename=’KING’;
SAL
———-
9999
Coming Next! – configuring GoldenGate Data Pump …..