0% found this document useful (0 votes)
135 views

Golden Gate Document

This document provides step-by-step instructions for implementing unidirectional replication between two Oracle databases using Oracle GoldenGate. It outlines prerequisites, configurations needed on the source and target databases, and creation of GoldenGate processes including Extract, Extract Data Pump on the source and Replicat on the target. The goal is to replicate the HR schema from the source database to the target database in a single direction.

Uploaded by

masheed ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views

Golden Gate Document

This document provides step-by-step instructions for implementing unidirectional replication between two Oracle databases using Oracle GoldenGate. It outlines prerequisites, configurations needed on the source and target databases, and creation of GoldenGate processes including Extract, Extract Data Pump on the source and Replicat on the target. The goal is to replicate the HR schema from the source database to the target database in a single direction.

Uploaded by

masheed ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Step-by-step implementation of

Unidirectional Replication with Oracle GoldenGate

As you know, Oracle GoldenGate is a powerful replication tool that you can use to
implement many replication scenarios. Even though Golden Gate was built with the
intention of replication, you can use it for some other purposes like database
migration, database upgrades, data integration, and even as a database high-
availability solution. Supported topologies are depicted in the Oracle GoldenGate
documents.
(https://docs.oracle.com/goldengate/1212/gg-winux/GWUAD/wu_about_gg.htm#GWUAD110)

In this document, I want to explain how to implement the first and one of the most
important of these topologies, and its unidirectional replication. In this scenario, let's
assume that we have two Oracle databases with different versions as the following
description:
Source Target
Database Version Oracle database 12c Oracle database 12c
Database Type Single instance – Multitenant Single instance – Multitenant
PDB Name HRPDB HRPDB
Host name mylnxsrv01 mylnxsrv02

Amirreza Rastandeh
[email protected]
To do this scenario, we need to do the following steps in order:
1. Oracle GoldenGate installation
2. Creation of the target database
3. Prerequisites of GoldenGate
4. Source configurations
5. Target configurations
6. Test all the configurations

Note: Please consider the Oracle GoldenGate Licensing Information before any
action.

Oracle GoldenGate installation


You need to download and install Oracle GoldenGate on both the source and the
target servers. In order to keep this document short, I don't cover the installation step.
Even though installation is very easy to do yourself, you can refer to lots of
documents that are available to install GoldenGate.

Creation of the target database


If your target database is already available, you can skip this step.
There are several ways to create and sync the target database. In this document, I use
the PDB cloning solution. So, perform the following steps to do that.
On the target CDB create a user:

SQL> create user c##cloner_usr identified by "test";

SQL> grant connect,resource, create database link,


create pluggable database to c##cloner_usr;

Now connect to the target CDB with the created user (c##cloner_usr) and perform
the following commands to create the target database:

SQL> create database link to_clone_hrpdb


connect to pdbadmin identified by "test"
using 'mylnxsrv01:1521/hrpdb';

Amirreza Rastandeh
[email protected]
SQL> create pluggable database hrpdb
from hrpdb@to_clone_hrpdb file_name_convert=(
'/oradata/mydb_site_a/hrpdb','/oradata/mydb_site_b/hrpdb'
);

SQL> alter pluggable database hrpdb open;

Prerequisites of GoldenGate

Configurations on the source server

SQL> ALTER DATABASE FORCE LOGGING;

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

SQL> ALTER SYSTEM SWITCH LOGFILE;

SQL> select SUPPLEMENTAL_LOG_DATA_MIN,FORCE_LOGGING


from v$database;

SQL> ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE


SCOPE=BOTH;

SQL> alter pluggable database all open;

SQL> alter session set container=cdb$root;

SQL> CREATE TABLESPACE goldengate


DATAFILE SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
LOGGING DEFAULT NO INMEMORY EXTENT MANAGEMENT LOCAL
AUTOALLOCATE BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;

SQL> alter session set container=hrpdb;

SQL> CREATE TABLESPACE goldengate


DATAFILE SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
LOGGING DEFAULT NO INMEMORY EXTENT MANAGEMENT LOCAL
AUTOALLOCATE BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;

SQL> alter session set container=cdb$root;

Amirreza Rastandeh
[email protected]
SQL> create user c##gguser identified by "gguser" default
tablespace goldengate quota unlimited on goldengate;

SQL> grant create session,connect,resource,alter


system,flashback any table,select any dictionary to
c##gguser container=all;

SQL> grant dba to c##gguser container=all;

SQL> EXEC
DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(
grantee => 'c##gguser',
container => 'ALL',
grant_optional_privileges => '*');

We should also open the required ports on the firewall:

# firewall-cmd --zone=public --permanent --add-port=9500-9520/tcp


# firewall-cmd --zone=public --permanent --add-port=7809/tcp
# firewall-cmd --reload

Configurations on the target server

SQL> ALTER DATABASE FORCE LOGGING;

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

SQL> ALTER SYSTEM SWITCH LOGFILE;

SQL> select SUPPLEMENTAL_LOG_DATA_MIN,FORCE_LOGGING


from v$database;

SQL> ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE


SCOPE=BOTH;

SQL> alter pluggable database all open;

SQL> alter session set container=cdb$root;

Amirreza Rastandeh
[email protected]
SQL> CREATE TABLESPACE goldengate
DATAFILE SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
LOGGING DEFAULT NO INMEMORY EXTENT MANAGEMENT LOCAL
AUTOALLOCATE BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;

SQL> alter session set container=hrpdb;

SQL> CREATE TABLESPACE goldengate


DATAFILE SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
LOGGING DEFAULT NO INMEMORY EXTENT MANAGEMENT LOCAL
AUTOALLOCATE BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;

SQL> alter session set container=cdb$root;

SQL> create user c##gguser identified by "gguser" default


tablespace goldengate quota unlimited on goldengate;

SQL> grant create session,connect,resource,


alter system,flashback any table,select any dictionary to
c##gguser container=all;

SQL> grant dba to c##gguser container=all;


SQL> EXEC
DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(
Grantee => 'c##gguser',
Container => 'ALL',
grant_optional_privileges=>'*');

We should also open the required ports on the firewall:

# firewall-cmd --zone=public --permanent --add-port=9600-9620/tcp


# firewall-cmd --zone=public --permanent --add-port=7809/tcp
# firewall-cmd --reload

Amirreza Rastandeh
[email protected]
Source configurations
We should configure some processes on the source server side. These processes are
Manager, Extract, and Extract Data Pump.
Run the GGSCI tool and configure the Manager process first:
GGSCI> edit params mgr

Copy the following lines and paste them into the opened editor page:
PORT 7809
DynamicPortList 9500-9520
PurgeOldExtracts ./dirdat/*, UseCheckPoints, MinKeepHours 2
Autostart Extract *
AUTORESTART Extract *, WaitMinutes 1, Retries 3

Save and close the editor. Then, start the Manager process and make sure it doesn't
have any issues:
GGSCI> stop mgr
GGSCI> start mgr
GGSCI> info mgr detail

If there are no issues, connect to the database through GGSCI and perform run
required commands to enable the trandata for the entire HR schema:
GGSCI> dblogin userid c##gguser@hrpdb password gguser
GGSCI> add schematrandata hrpdb.hr
GGSCI> info trandata hrpdb.HR.*

Create the Extract process:


GGSCI> edit params ext_p01

Copy the following lines and paste them into the opened editor page:
EXTRACT ext_p01
USERID c##gguser@source_cdb PASSWORD gguser
SETENV (ORACLE_HOME = "/oracle/product/12.2.0/db_1")
SETENV (ORACLE_SID = "mydb")
DISCARDFILE discard.txt, APPEND
TranlogOptions IntegratedParams (max_sga_size 256)
Exttrail ./dirdat/in
LOGALLSUPCOLS
DDL INCLUDE MAPPED
SOURCECATALOG HRPDB
UPDATERECORDFORMAT COMPACT
Table HRPDB.HR.*;

Amirreza Rastandeh
[email protected]
Run the following commands:
GGSCI> dblogin userid c##gguser@source_cdb password gguser;
GGSCI> register extract ext_p01 database container (hrpdb)
GGSCI> add extract ext_p01, integrated tranlog, begin now
GGSCI> add exttrail ./dirdat/et, extract ext_p01, megabytes 10

Create the Extract data pump process:


GGSCI> edit params ext_dp01

Copy the following lines and paste them into the opened editor page:
(Note that you should have the "source_cdb" entry in your tnsnames.ora file.)
EXTRACT ext_dp01
SETENV (ORACLE_SID='mydb')
USERID c##gguser@source_cdb PASSWORD gguser
RMTHOST mylnxsrv02, MGRPORT 7809
rmttrail ./dirdat/pn
table hrpdb.HR.*;

Run the following commands:


GGSCI> add extract ext_dp01, exttrailsource ./dirdat/et
GGSCI> add rmttrail ./dirdat/rt, extract ext_dp01, megabytes 10

Start the Extract process and make sure everything is configured properly:
GGSCI> start extract ext_p01
GGSCI> info all

Amirreza Rastandeh
[email protected]
Target configurations
We should configure some processes on the target server side, too. These processes
are Manager and Replicat.
Just like what we did in the source server, run the GGSCI tool and configure the
Manager process first:
GGSCI> edit params mgr

Copy the following lines and paste them into the opened editor page:
PORT 7809
DynamicPortList 9600-9620
PurgeOldExtracts ./dirdat/rt*, UseCheckPoints, MinKeepHours 2
Autostart Replicat *
AUTORESTART Replicat *, WaitMinutes 1, Retries 3

Then, start the Manager process and make sure it doesn't have any issues:
GGSCI> stop mgr
GGSCI> start mgr
GGSCI> info mgr detail

Create the Replicat process:


GGSCI> edit params rep_p01

Copy the following lines and paste them into the opened editor page:
(Note that you should have the "hrpdb" entry in your tnsnames.ora file.)
replicat rep_p01
userid c##gguser@hrpdb password gguser
SETENV (ORACLE_HOME = " /oracle/product/12.2.0/db_1")
SETENV (ORACLE_SID = "mydb")
DBOPTIONS INTEGRATEDPARAMS(parallelism 2)
DDL INCLUDE MAPPED
DDLOPTIONS REPORT
AssumeTargetDefs
DiscardFile ./dirrpt/rpdw.dsc, Purge
map hrpdb.hr.*, target hrpdb.hr.*;

Amirreza Rastandeh
[email protected]
Connect to the database through GGSCI and run the following commands:
(Note that you should have the "target_cdb" entry in your tnsnames.ora file.)

GGSCI> dblogin userid c##gguser@target_cdb password gguser


GGSCI> add replicat rep_p01 Integrated exttrail ./dirdat/rt
GGSCI> start replicat rep_p01
GGSCI> info all

If everything is OK and you don’t have any issues, you should start the Extract Data
Pump process on the source server:

GGSCI> start extract ext_dp01


GGSCI> info all

Amirreza Rastandeh
[email protected]
Test all the configurations
You can test the unidirectional replication by executing some DML commands on
the source side and check the target database after each command to make sure they
apply on the target side (note that there may be a little delay for the changes to take
effect, so be patient!), for example, run each of the following commands, wait a few
seconds, and check for its effect on the target database:

--1st command
SQL> insert into employees
values
(207,'Amir','Rastandeh','a.rastandeh','5432',
sysdate,'IT_PROG',3000,null,null,60);
SQL> commit;

--2nd command
SQL> update employees set salary=salary*1.2
where employee_id=100;
SQL> commit;

--3rd command
SQL> delete from employees where employee_id = 207;
SQL> commit;

--4th command
SQL> alter table HR.EMPLOYEES add mycol number(1);

--5th command
SQL> alter table HR.EMPLOYEES modify mycol NUMBER(10);

--6th command
SQL> alter table HR.EMPLOYEES drop column mycol;

Good Luck!
Amirreza Rastandeh
[email protected]

Amirreza Rastandeh
[email protected]

You might also like