I was working on a project where it involves use of Oracle GoldenGate for data migration from one database to another. We can term this project as cross platform data replication (migration and upgrade if done for whole database) as both the source and target system and database versions are different to each other.
I would like to show a simple demo on setting up Oracle GoldenGate software and configuring the same to use for migration or replication of data between databases (Oracle in our case) where as
Oracle GoldenGate can be used for heterogeneous platform as well.
The post consists of the following
1. Environment details
2. GoldenGate installation
3. Prerequisites and Oracle GoldenGate software set up
4. Enabling TRANDATA
5. Param files set up
6. The GoldenGate process (Commands and Explanations)
7. Real time sample demo
Now let's get into the details.
1. Environment details
Source
Oracle 9.2.0.7.0 on SunOS operating system
OGG_source $ uname -sr
SunOS 5.10
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
Destination
Oracle 11.2.0.4 on Linux 2.6.32-358.0.1.el6.x86_64
OGG_target $ uname -sr
Linux 2.6.32-358.0.1.el6.x86_64
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
GoldenGate software used
Source: Oracle
GoldenGate Version 11.1.1.1 13
Destination: Oracle GoldenGate Version 11.2.1.0.17
2. GoldenGate Installation
For GoldenGate installation please see Oracle GoldenGate Installation
3. Prerequisites and Oracle GoldenGate software set up
3.1 Prerequisites
As
a prerequisite for enabling and utilizing OGG, archive log should be enabled in
the source database. If bidirectional, both the database should run in
ARCHIVELOG mode.
For enabling Archivelog mode, see Enabling Archivelog
Once Archivelog has been enabled, enable
supplemental logging in source by issuing the below command
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
3.2 OGG software setup
The following has to be performed on source and target databases to set up GG owner and create/grant required privileges and roles required to perform GG activities.
On Source:
export ORACLE_BASE=/r01/app/oracle/
export ORACLE_HOME=/r01/app/oracle/product/9.2.0
export PATH=$PATH:$ORACLE_HOME/bin:/backup/PRNETSDB/ogg/11.1
export ORACLE_SID=PRNETSDB
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export SHLIB_PATH=$ORACLE_HOME/lib
export GGH=/backup/PRNETSDB/ogg/11.1
$ cd $GGH
$ ggsci
ggsci> create subdirs
All the GoldenGate required directories will be created under GoldenGate Home directory
SQL> create user ggs_dba identified by ggs_dba default tablespace TOOLS temporary tablespace TEMP profile DEFAULT;
SQL> grant CONNECT to ggs_dba;
SQL> grant SELECT ANY TABLE to ggs_dba; -- This can be restricted to tables that are only involved
SQL> grant ALTER SESSION to ggs_dba;
Change
to the OGG HOME (GGH) directory and execute the scripts.
cd $GGH
-- Run the following as SYSDBA user with input "GGS_DBA"
SQL> @marker_setup.sql -- creates GGS_DDL_HIST table under GGS_DBA for DDL replication
SQL> @ddl_setup.sql -- To support DDL replication
SQL> @role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggs_dba;
SQL> @ddl_enable.sql -- Enables GGS trigger
Change
to dirprm directory which was
created earlier and perform the below
cd $GGH/dirprm
vi mgr.prm
PORT 15000
DYNAMICPORTLIST 15010-15020
USERID GGS_DBA, PASSWORD ggs_dba
ggsci> start manager
ggsci>
On Target:
export ORACLE_BASE=/ne01/app/oracle
export ORACLE_HOME=/ne01/app/oracle/product/11.2.0.4
export PATH=$PATH:$ORACLE_HOME/bin:/backup/gg_kt/ogg/11.2
export ORACLE_SID=STNETSDB
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/backup/gg_kt/ogg/11.2
export SHLIB_PATH=$ORACLE_HOME/lib
export GGH=/backup/gg_kt/ogg/11.2
$ cd GGH
$ ggsci
ggsci> create subdirs
All
the GoldenGate required directories will be created under GoldenGate Home
directory
SQL> create user ggs_dba identified by ggs_dba default tablespace TOOLS temporary tablespace TEMP profile DEFAULT;
SQL> grant CONNECT to ggs_dba;
SQL> grant SELECT ANY TABLE to ggs_dba; -- This can be restricted to tables that are only involved
SQL> grant ALTER SESSION to ggs_dba;
-- Grant insert, update, delete privilege on tables replicated
SQL> grant insert, delete, update on [list of tables] to ggs_dba;
Or grant
Oracle GoldenGate user DBA
role till the migration activity is complete and then revoke the grant if
required.
Change to the OGG HOME (GGH) directory and execute
the scripts.
cd $GGH
Run
the following as SYSDBA user with input "GGS_DBA"
SQL> @marker_setup.sql -- creates GGS_DDL_HIST table under GGS_DBA for DDL replication
SQL> @ddl_setup.sql -- To support DDL replication
SQL> @role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggs_dba;
SQL> @ddl_enable.sql -- Enable GGS trigger
Change
to dirprm directory which was
created earlier and perform the below
cd $GGH/dirprm
vi mgr.prm
PORT 12000
DYNAMICPORTLIST 12010-12020
USERID GGS_DBA, PASSWORD ggs_dba
cd $GGH
ggsci
ggsci 1> start manager
ggsci 2> edit params ./GLOBALS -- This creates a vi file named GLOBALS* under the current directory
GGSCHEMA ggs_dba
CHECKPOINTTABLE ggs_dba.checkpoint
:wq – to save the file
ggsci 3> dblogin userid ggs_dba Password ggs_dba
ggsci 4> add checkpointtable ggs_dba.checkpoint
Enable
ENABLE_GOLDENGATE_REPLICATION process as this is a mandatory step if the
database is of Oracle version 11g and above.
SQL> ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;
* To learn more about GLOBALS and other parameter
files, refer this oracle documentation link
4. Enabling TRANDATA
Enabling TRANDATA (transaction data) is explained in
Enable TRANDATA
Once the TRANDATA is enabled for individual tables, then the parameter files can be created
5. Param files set up
All the parameters set up required for our demo is given in this link
Simple parameter files for Oracle GoldenGate
Upon completion of Parameter files creation, we can start the Oracle GoldenGate replication process.
6. The GoldenGate process (Commands and Explanations)
Please see this link
OGG step by step process for the Oracle GoldenGate commands, step by step processes and their simple explanations.
Thus we have completed our Oracle GoldenGate set up and replication.
7. Real time sample demo
As we have completed the Oracle GoldenGate replication between 2 databases of different versions and platforms, the real time demo shown will be of much useful in understanding the process better.
Please see here for the demo -
Oracle GoldenGate sample demo.
Happy Replicating!!