You are on page 1of 9

GoldenGate Setup

------------------
The main components of the GoldenGate architecture are :

EXTRACT : Collects the changes vectors from the redo logs and archive logs file
from the source database, and send them to the manager process (like capture
process for streams). It regulary checkpoints its R/W position to
a file and Can have the following status :
- STOPPED
- RUNNING
- STARTING
- ABENED (abnormal end)

TRAIL FILES : GoldenGate converts data to replicate into a special format which is
written to trail files both on the source and target systems. They are called local
trail on the source system and remote trail on the target system.

DATA PUMP : On the local trail, GoldenGate requires an additional extract process
called data pump to send data in large block accross TCP/IP.

SERVER COLLECTOR : This process runs on the target system and accepts data from the
source and writes it to the remote trails (like propagation process for streams).

MANAGER : Runs on both source and target systems. Stores the change vectors in
TRAIL files. It controls the starting, monitoring and restarting processes, the
reporting errors and events. Can have the following status :
- STOPPED
- RUNNING
REPLICAT : Recovers the change vectors from trail files and apply them to the
target database (like apply process for streams). It regulary checkpoints its R/W
position to a file. Can have the following status :
- STOPPED
- RUNNING
- STARTING
- ABENED (abnormal end)

GGSCI : GoldenGate Software Command Interface. It is a tool that provides a set of


commands to create, configurate and monitors GoldenGate.

1. Prerequisite
PRIMARY HOST/INSTANCE : OGG1.FCICANADA.COM / OGG1
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1

SECONDRY HOST/INSTANCE : OGG1.FCICANADA.COM / OGG1


ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1

Archiving should be enabled on OGG1 and is not required on OGG2

2. Software Install
Install GG software on both source and target

SOFTWARE_LOCATION=/u01/app/oracle/product/11.2.0/oggcore_1
MANAGER_PORT=7808

3. Source environment
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP
ORACLE_HOSTNAME=OGG1.FCICANADA.COM; export ORACLE_HOSTNAME
ORACLE_UNQNAME=OGG1; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1; export ORACLE_HOME
ORACLE_GG_HOME=/u01/app/oracle/product/11.2.0/oggcore_1; export ORACLE_GG_HOME
ORACLE_SID=OGG1; export ORACLE_SID

export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_GG_HOME:$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

if [ $USER = "oracle" ]; then


if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

4. Prepare the SOURCE DATABASE (host db) for replication. Switch the database to
archivelog mode:

SQL> shutdown immediate


SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
SQL> select log_mode from v$database;

LOG_MODE
------------
ARCHIVELOG

Enabling Supplemental logging on source database OGG1 in order to log all


transactions and loads. This step is not required for target database OGG2.

SQL> alter database add supplemental log data;


Database altered.
SQL>

Prepare the database for DDL replication. Turn off the recyclebin feature and be
sure that it is empty.

SQL> alter system set recyclebin=off scope=spfile;


SQL> PURGE DBA_RECYCLEBIN;
DBA Recyclebin purged.
SQL>

5. Create a schema that will contain the Oracle GoldenGate DDL objects.

SQL> create tablespace gg_tbls datafile '/u02/oradata/OGG1/gg_tbls.dbf' size 100m


reuse autoextend on;
Tablespace created.

SQL> create user ggate identified by oracle default tablespace gg_tbls quota
unlimited on gg_tbls;
User created.

SQL> grant create session, connect, resource to ggate;


Grant succeeded.

SQL> grant dba to ggate; -- just in case


Grant succeeded.

SQL> grant execute on utl_file to ggate;


Grant succeeded.

OR

GRANT CONNECT, RESOURCE TO ggate;


GRANT SELECT ANY DICTIONARY, SELECT ANY TABLE TO ggate;
GRANT CREATE TABLE TO ggate;
GRANT FLASHBACK ANY TABLE TO ggate;
GRANT EXECUTE ON dbms_flashback TO ggate;
GRANT EXECUTE ON utl_file TO ggate;
GRANT CREATE ANY TABLE TO ggate;
GRANT INSERT ANY TABLE TO ggate;
GRANT UPDATE ANY TABLE TO ggate;
GRANT DELETE ANY TABLE TO ggate;
GRANT DROP ANY TABLE TO ggate;
GRANT ALTER ANY TABLE TO ggate;
GRANT ALTER SYSTEM TO ggate;
GRANT LOCK ANY TABLE TO ggate;
GRANT SELECT ANY TRANSACTION to ggate;
ALTER USER ggate QUOTA UNLIMITED ON ogg_data;

6. Make sure you can tnsping both databases from each host
listener.ora
------------
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC = (GLOBAL_DBNAME = OGG1)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_1)
(SID_NAME = ogg1))
(SID_DESC = (GLOBAL_DBNAME = OGG2)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_1)
(SID_NAME = OGG2)))

tnsnames.ora
------------
OGG1 =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = OGG1.FCICANADA.COM)(PORT =
1523))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = OGG1)))

OGG2 =
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = OGG2.FCICANADA.COM)(PORT =
1523))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = OGG2)))

7. Change the directory on Golden Gate home directory and run scripts for creating
all necessary objects for support ddl replication.
[oracle@db ~]$ cd /u01/app/oracle/product/11.2.0/oggcore_1
[oracle@db gg]$ sqlplus / as sysdba

SQL> @marker_setup.sql
SQL> @ddl_setup.sql
SQL> @role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggate;
SQL> @ddl_enable.sql

[oracle@OGG1 ~]$ cd /u01/app/oracle/product/11.2.0/oggcore_1


[oracle@OGG1 oggcore_1]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Apr 15 04:09:32 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.

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

SQL> @marker_setup.sql

Marker setup script

You will be prompted for the name of a schema for the Oracle GoldenGate database
objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:ggate

Marker setup table script complete, running verification script...


Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE

MARKER TABLE
-------------------------------
OK

MARKER SEQUENCE
-------------------------------
OK

Script complete.
SQL> @ddl_setup.sql

Oracle GoldenGate DDL Replication setup script

Verifying that current user has privileges to install DDL Replication...

You will be prompted for the name of a schema for the Oracle GoldenGate database
objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle
11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:ggate


Working, please wait ...
Spooling to file ddl_setup_spool.txt

Checking for sessions that are holding locks on Oracle Golden Gate metadata
tables ...

Check complete.

Using GGATE as a Oracle GoldenGate schema name.

Working, please wait ...

DDL replication setup script complete, running verification script...


Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGATE

CLEAR_TRACE STATUS:

Line/pos Error
----------------------------------------
-----------------------------------------------------------------
No errors No errors

.
.
.
.
.

DDL TRIGGER TRACE LEVEL


-----------------------------------------------------------------------------------
-------------------------------------
NONE

LOCATION OF DDL TRACE FILE


-----------------------------------------------------------------------------------
-------------------------------------
/u01/app/oracle/diag/rdbms/ogg1/OGG1/trace/ggs_ddl_trace.log

Analyzing installation status...

VERSION OF DDL REPLICATION


-----------------------------------------------------------------------------------
-------------------------------------
OGGCORE_12.2.0.1.0_PLATFORMS_151101.1925.2

STATUS OF DDL REPLICATION


-----------------------------------------------------------------------------------
-------------------------------------
SUCCESSFUL installation of DDL Replication software components

Script complete.
SQL> @role_setup.sql

GGS Role setup script


This script will drop and recreate the role GGS_GGSUSER_ROLE
To use a different role name, quit this script and then edit the params.sql script
to change the gg_role parameter to the preferred name. (Do not run the script.)

You will be prompted for the name of a schema for the GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter GoldenGate schema name:ggate


Wrote file role_setup_set.txt

PL/SQL procedure successfully completed.

Role setup script complete

Grant this role to each user assigned to the Extract, GGSCI, and Manager processes,
by using the following SQL command:

GRANT GGS_GGSUSER_ROLE TO <loggedUser>

where <loggedUser> is the user assigned to the GoldenGate processes.


SQL> grant GGS_GGSUSER_ROLE to ggate;

Grant succeeded.

SQL> @ddl_enable.sql

Trigger altered.

SQL>

SQL> alter system set enable_goldengate_replication=true;

System altered.

After that, add information about your Oracle GoldenGate DDL scheme into file
GLOBALS. You should input this row into the file "GGSCHEMA ggate".
[oracle@db gg]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle


Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

GGSCI (db.us.oracle.com) 1> EDIT PARAMS ./GLOBALS


GGSCHEMA OGG_USER

GGSCI (db.us.oracle.com) 2>

--Create the schemes for replication on both hosts (OGG1, OGG2).

Source database (OGG1):


SQL> create user source identified by oracle default tablespace users temporary
tablespace temp;
User created.

SQL> grant connect,resource,unlimited tablespace to source;

Grant succeeded.

SQL>
Target database(OGG2):
SQL> create user target identified by oracle default tablespace users temporary
tablespace temp;

User created.

SQL> grant connect,resource,unlimited tablespace to target;

Grant succeeded.

SQL> grant dba to target; -- or particular grants

Grant succeeded.

SQL>
Create the directory for trail files on ***BOTH HOSTS and create directory for
****discard file on OGG2 host only.

[oracle@OGG1 ~]$ mkdir -p /u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr


[oracle@OGG2 ~]$ mkdir -p /u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr
[oracle@OGG2 ~]$ mkdir -p /u01/app/oracle/product/11.2.0/oggcore_1/discard

Configure Extract Parameters.


In this example the extract process will be called "ext1".
On the source server, create the parameter file for Extract ext1:

GGSCI (OGG1.FCICANADA.COM as ggate@OGG1) 3> add extract ext1, tranlog, begin now
EXTRACT added.

GGSCI (OGG1.FCICANADA.COM as ggate@OGG1) 4> add exttrail


/u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr, extract ext1
EXTTRAIL added.

GGSCI (OGG1.FCICANADA.COM as ggate@OGG1) 5> edit params ext1


extract ext1
userid ggate, password oracle
exttrail /u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr
ddl include mapped objname source.*;
table source.*;

GGSCI (OGG1.FCICANADA.COM as ggate@OGG1) 6> info all

Program Status Group Lag at Chkpt Time Since Chkpt


MANAGER RUNNING
EXTRACT STOPPED EXT1 00:00:00 00:02:33

Configure Data Pump Parameters


In this example the Data Pump process will be called dp1
On the source server create the parameter file for Data Pump process dp1:
GGSCI (db.us.oracle.com) 10> add extract pump1, exttrailsource
/u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr, begin now
EXTRACT added.

GGSCI (db.us.oracle.com) 11> add rmttrail


/u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr, extract pump1
RMTTRAIL added.

GGSCI (db.us.oracle.com) 12> edit params pump1


EXTRACT pump1
USERID ggate, PASSWORD oracle
RMTHOST db2, MGRPORT 7808
RMTTRAIL /u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr
PASSTHRU
table source.*;

GGSCI (db.us.oracle.com) 13> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING
EXTRACT STOPPED EXT1 00:00:00 00:02:33
EXTRACT STOPPED PUMP1 00:00:00 00:02:56

GGSCI (db.us.oracle.com) 14>

Configure the target database (OGG2).


Configure the manager process
[oracle@OGG2 oggcore_1]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle


Version 12.2.0.1.0 OGGCORE_12.2.0.1.0_PLATFORMS_151101.1925.2_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Nov 11 2015 01:38:14
Operating system character set identified as UTF-8.

Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved.

GGSCI (OGG2.FCICANADA.COM) 1> edit params mgr


PORT 7808

GGSCI (OGG2.FCICANADA.COM) 2> start manager


Manager started.

GGSCI (OGG2.FCICANADA.COM) 3> dblogin userid target


Password:
Successfully logged into database.

GGSCI (OGG2.FCICANADA.COM as target@OGG2) 4> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING

GGSCI (OGG2.FCICANADA.COM as target@OGG2) 5> add replicat rep1, exttrail


/u01/app/oracle/product/11.2.0/oggcore_1/dirdat/tr, begin now
REPLICAT added.
GGSCI (OGG2.FCICANADA.COM as target@OGG2) 6> edit params rep1
REPLICAT rep1
ASSUMETARGETDEFS
USERID target, PASSWORD oracle
discardfile /u01/app/oracle/product/11.2.0/oggcore_1/discard/rep1_discard.txt,
append, megabytes 10
DDL
map source.*, target target.*;

GGSCI (db2) 10> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING
REPLICAT STOPPED REP1 00:00:00 00:01:52

You might also like