Thursday, February 03, 2011

Installation & Configuration of Golden Gate on RAC using ASM:




1.    Installation:

2. Select Oracle Fusion MiddleWare
3. Linux X86/64
4. I downloaded Oracle GoldenGate on Oracle v11.1.1.0.0 Media Pack for Linux x86-64
5. Extracted on /u01/goldengate

2.       Create skeletons:
Source DB:

1.       Create the necessary working directories for GG.

[oracle@db1 gg]$ ./ggsci
GGSCI (db1) 1>create subdirs
GGSCI (db1) 1>exit
[oracle@db1 gg]$ mkdir $GGATE/discard


Target DB:

Do the same alike source DB

3. Configure Source/Destination database

The GoldenGate software having been installed successfully, we must prepare the source database for replication.

Source DB:

1.    Switch the database to archivelog mode:

      SQL> shutdown immediate
      SQL> startup mount
      SQL> alter database archivelog;
      SQL> alter database open;
 
 2. Enable minimal supplemental logging:
     
SQL> alter database add supplemental log data;

   3. Prepare the database to support ddl replication (optional).

      a) Turn off recyclebin for the database . . .
      SQL> alter system set recyclebin=off scope=spfile;
Though it’s not required for 11g and onwards.
       . . . and bounce it.

 b) Create schema for ddl support replication . . .

 SQL> create user ggate identified by qwerty default tablespace users temporary tablespace temp;

      . . . and grant the necessary privileges to the new user..
      [oracle@db1 gg]$ cd $GGATE
      
      SQL> grant connect,resource,unlimited tablespace to ggate;
      SQL> grant execute on utl_file to ggate;


      c) Run scripts for creating all necessary objects for support ddl replication:

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

Create test schemas for replication. I will create a replication from schema sender to schema receiver (the receiving schema can be on the same database or on another).

a) Source database:

SQL> create user sender identified by qwerty default tablespace users temporary tablespace temp;
SQL> grant connect,resource,unlimited tablespace to sender;

b) Destination database:

SQL> create user receiver identified by qwerty default tablespace users temporary tablespace temp;
SQL> grant connect,resource,unlimited tablespace to receiver;


4.Replication

We’re going to create the simplest replication without the GG data pump (we can add it later). Our goal is to create ddl and ddl replication from the sender schema on the source database to receiver schema on the destination.

Replication also works if you’re using only one database. This is replication between schemas.

   1. Create and start manager on the source and the destination.

Source DB:

      [oracle@db1 gg]$ cd $GGATE
      [oracle@db1 gg]$ ./ggsci
      
      GGSCI (db1) 4> info all
      
      Program     Status      Group       Lag           Time Since Chkpt
      MANAGER     STOPPED
      
      GGSCI (db1) 6> edit params mgr
      PORT 7809
      
      GGSCI (db1) 7> start manager
      Manager started.

      We can check status of our processes:

      GGSCI (db1) 8> info all
      Program     Status      Group       Lag           Time Since Chkpt
      MANAGER     RUNNING

Create the extract group on the source side:

GGSCI (db1) 1> add extract extdm, tranlog, begin now
EXTRACT added.

GGSCI (db1) 2> ADD RMTTRAIL /u01/goldengate/dirdat/rt, EXTRACT exdm

GGSCI (db1) 3> edit params exdm

Add the following lines to the new parameter file for our extract:

EXTRACT exdm

--connection to database--
userid ggate, password qwerty
--specify redo/archive location
TRANLOGOPTIONS ALTARCHIVELOGDEST /u03/oralogs/
--specify ASM connectivity as we are using ASM
TRANLOGOPTIONS ASMUSER sys@asm, ASMPASSWORD DBApassword
--specify target database
rmthost warehouselab, mgrport 7809
rmttrail /u01/app/oracle/product/gg/dirdat/lt
--DDL support
ddl include mapped objname sender.*;
--DML
table sender.*;

We can check our processes again:

GGSCI (db1) 6> info all
Program     Status      Group       Lag           Time Since Chkpt
MANAGER     STOPPED
EXTRACT     STOPPED     EXT1        00:00:00      00:10:55


Create replicat on the destination side:
[oracle@db2 gg]$ cd $GGATE

[oracle@db2 gg]$ ./ggsci

add checkpoint table to the destination database

GGSCI (db2) 1> edit params ./GLOBAL
and put following lines to the global parameter file:

GGSCHEMA ggate

CHECKPOINTTABLE ggate.checkpoint

~

GGSCI (db2) 2> dblogin userid ggate
 Password:
 Successfully logged into database.

GGSCI (db2) 3> add checkpointtable ggate.checkpoint
 Successfully created checkpoint table GGATE.CHECKPOINT.

Create replicat group:

GGSCI (db2) 4> add replicat rep1, exttrail /u01/goldengate/dirdat/rt,checkpointtable ggate.checkpoint

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 parameter file for replicat:

GGSCI (db2) 5> edit params rep1

--Replicat group --
replicat rep1
--source and target definitions
ASSUMETARGETDEFS
--target database login --
userid ggate, password qwerty
--file for dicarded transaction --
discardfile /u01/app/oracle/product/gg/discard/rep1_discard.txt, append, megabytes 10
--ddl support
DDL
--Specify table mapping ---
map sender.*, target receiver.*;

# Start extract and replicat:

Source:
GGSCI (db1) 14> start extract exdm

Destination:
GGSCI (db2) 15> start replicat rep1
# Check all processes.

Source:
GGSCI (db1) 8> info all

Program     Status      Group       Lag           Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT1        00:00:00      00:00:05

Destination:
GGSCI (db1) 8> info all

Program     Status      Group       Lag           Time Since Chkpt
MANAGER     RUNNING
REPLICAT    RUNNING     REP1        00:00:00      00:00:00

Our replication has been successfully created.
5.    Checking

Now we can check our replication. We will create some tables in the sender schema on the source, insert some rows, and check how it will replicate to destination side.

   1. Source database:
      SQL> create table sender.test_tab_1 (id number,rnd_str varchar2(12));
      SQL> insert into sender.test_tab_1 values (1,'test_1');
      SQL>commit;
   2. Destination database:
      SQL> select * from receiver.test_tab_1;
      
      ID RND_STR
      ---------- ------------
      1 test_1

Our GoldenGate DDL and DML replication is now working. The table was created on the destination side and data were replicated.


You may want to follow the below thread for ASM configuration:
ORACLE @ Work: Oracle ASM for Oracle GoldenGate extract


4 comments:

Ketan said...

Excellent reference doc.

ahmetmelihbasbug said...

what is $GGATE ??? You didn't mentioned.

ahmetmelihbasbug said...

Can we install goldengate on RAC systems when we follow this article?

Ferdous Nadvi said...

This article is about installing GG on RAC, so yes.