Tuesday 16 February 2016

Oracle 11g GoldenGate Installation. Part 2

1. Install
With the database created, we can install GoldenGate software to the box:
  1. Get the GG software from OTN. We need “Oracle GoldenGate v10.4.0.x for Oracle 10g 64bit on Redhat 4.0″. The file has size is 27 Mb. It is officially intended for RHEL 4.0 x86-64, but it works fine on OEL 5.3 x86-64 and on Centos 5.3 x86-64.
  2. Create directory for the software and extract it to the directory:
[oracle@db1 product]$ mkdir /u01/app/oracle/product/gg
[oracle@db1 product]$ export GGS_ADMIN=/u01/app/oracle/product/gg
[oracle@db1 product]$ cd $GGS_ADMIN
[oracle@db1 gg]$ unzip V18157-01.zip
Archive:  V18157-01.zip
inflating: ggs_redhatAS40_x64_ora10g_64bit_v10.4.0.19_002.tar
[oracle@db1 gg]$ tar -xf ggs_redhatAS40_x64_ora10g_64bit_v10.4.0.19_002.tar
    1. If you are using Oracle 11gr1 or 11gr2, make a symbolic link . . .
[oracle@db1 gg]$ ln -s /u01/app/oracle/product/11.2.0/db_1/lib/libnnz11.so /u01/app/oracle/product/11.2.0/db_1/lib/libnnz10.so
    1.  . . . and the path to the GG libraries to LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/app/oracle/product/gg
    1. Now we can start GG command line utility to make sure it works.
[oracle@db1 gg]$ ./ggsci
  1. You should now get the prompt to the GoldenGate command line interface:
Oracle GoldenGate Command Interpreter for Oracle

Version 10.4.0.19 Build 002

Linux, x64, 64bit (optimized), Oracle 10 on Sep 22 2009 14:18:08

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

GGSCI (db1) 1>
  1. Create the necessary working directories for GG.
    [oracle@db1 gg]$ ./ggsci
    GGSCI (db1) 1>create subdirs
GGSCI (db1) 1>edit params mgr      
PORT 7809 :wq!

GGSCI (db1) 1>exit
[oracle@db1 gg]$ mkdir $GGS_ADMIN/discard
  1. The GoldenGate software has been successfully installed to the box db1.
2. Destination-side
We must repeat all the above steps on the destination side. Here, it will be host db4 with same database.
3. Source database
The GoldenGate software having been installed successfully, we must prepare the source database for replication.
  1. Switch the database to archivelog mode:
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
  1. Enable minimal supplemental logging:
SQL> alter database add supplemental log data;
  1. Prepare the database to support ddl replication (optional).a) Turn off recyclebin for the database . . .
SQL> alter system set recyclebin=off scope=spfile;
  1. . . . and bounce it.
  2. b) Create schema for ddl support replication . . .
SQL> create user ggs_admin identified by qwerty default tablespace golden temporary tablespace temp;
  1. . . . and grant the necessary privileges to the new user..
[oracle@db1 gg]$ cd $GGS_ADMIN

SQL> grant connect,resource,unlimited tablespace to ggs_admin;
SQL> grant execute on utl_file to ggs_admin;
  1. c) Run scripts for creating all necessary objects for support ddl replication:
SQL> @$GGS_ADMIN/marker_setup.sql
SQL> @$GGS_ADMIN/ddl_setup.sql
SQL> @$GGS_ADMIN/role_setup.sql
SQL> grant GGS_GGSUSER_ROLE to ggs_admin;
SQL> @$GGS_ADMIN/ddl_enable.sql

  1. Create test schemas for replication. I will create a replication from schema sender to schemareceiver (the receiving schema can be on the same database or on another).a) Source database:
SQL> create user sender identified by qwerty default tablespace goldentemporary tablespace temp;
SQL> grant connect,resource,unlimited tablespace to sender;
  1. b) Destination database:
SQL> create user receiver identified by qwerty default tablespace goldentemporary 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 dml 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:
[oracle@db1 gg]$ cd $GGS_ADMIN
[oracle@db1 gg]$ ./ggsci

GGSCI (db1) 4> info all

Program     Status      Group       Lag           Time Since Chkpt
MANAGER     STOPPED

GGSCI (db1) 6> edit params mgr

<code>PORT 7809</code>

GGSCI (db1) 7&gt; start manager

Manager started.
  1. We can check status of our processes:
GGSCI (db1) 8> info all

Program     Status      Group       Lag           Time Since Chkpt

MANAGER     RUNNING
  1. Create the extract group on the source side:
GGSCI (db1) 1> add extract ext2, tranlog, begin now

EXTRACT added.

GGSCI (db1) 2> add exttrail /u01/app/gg/dirdat/lt, extract ext2

EXTTRAIL added.

GGSCI (db1) 3> edit params ext1
  1. Add the following lines to the new parameter file for our extract:
--extract group--
extract ext1
--connection to database--
userid ggs_admin, password qwerty
--hostname and port for trail--
rmthost db2, mgrport 7809
--path and name for trail--
rmttrail /u01/app/gg/dirdat/lt
--DDL support
ddl include mapped objname sender.*
--DML
table sender.*;
  1. 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
  1. Create replicat on the destination side:
[oracle@db2 gg]$ cd $GGS_ADMIN

[oracle@db2 gg]$ ./ggsci

add checkpoint table to the destination database

GGSCI (db2) 1> edit params ./GLOBALS

and put following lines to the global parameter file:

GGSCHEMA ggs_admin

CHECKPOINTTABLE ggs_admin.checkpoint

~

GGSCI (db2) 2> dblogin userid ggs_admin

Password:

Successfully logged into database.

GGSCI (db2) 3> add checkpointtable ggs_admin.checkpoint

Successfully created checkpoint table GGS_ADMIN.CHECKPOINT.

Create replicat group:

GGSCI (db2) 4> add replicat rep1, exttrail /u01/app/gg/dirdat/lt,checkpointtable ggs_admin.checkpoint

REPLICAT added.

create parameter file for replicat:

GGSCI (db2) 5> edit params rep1
  1. And put following lines in the parameter file:
--Replicat group --
replicat rep1
--source and target definitions
ASSUMETARGETDEFS
--target database login --
userid ggs_admin, 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.*;
  1. Start extract and replicat:Source:
GGSCI (db1) 14> start extract ext1
  1. Destination:
GGSCI (db2) 15> start replicat rep1
  1. 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
  1. Destination:
GGSCI (db1) 8> info all

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

  1. Our replication has been successfully created.

No comments: