Golden Gate Document
Golden Gate Document
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.
Now connect to the target CDB with the created user (c##cloner_usr) and perform
the following commands to create the target database:
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'
);
Prerequisites of GoldenGate
Amirreza Rastandeh
[email protected]
SQL> create user c##gguser identified by "gguser" default
tablespace goldengate quota unlimited on goldengate;
SQL> EXEC
DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(
grantee => 'c##gguser',
container => 'ALL',
grant_optional_privileges => '*');
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;
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.*
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
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.*;
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
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.)
If everything is OK and you don’t have any issues, you should start the Extract Data
Pump process on the source server:
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]