Test the synchronization of Single-host OGG to Oracle 11 gb db in Linux
1. Install goldengate Software
1. test environment:
OS: RedHat 6 64bit
DB: Oracle 11.2.0.3 64bit
View OS and DB versions
[Oracle @ redhat6 ~] $ Uname-
Linux redhat6 2.6.32-131.0.15.el6.x86 _ 64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
SQL> select * from v $ version where rownum = 1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0-64bit Production
1. 2. Install OGG
[Oracle @ redhat6 ~] $ Cd/u01/ogg
[Oracle @ redhat6 ogg] $ unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
[Oracle @ redhat6 ogg] $ tar-xvf fbo_ggs_Linux_x64_ora11g_64bit.tar
1. 3. Add Environment Variables
[Oracle @ redhat6 ogg] $ vi/home/oracle/. bash_profile
LD_LIBRARY_PATH = $ ORACLE_HOME/lib:/usr/lib
Export LD_LIBRARY_PATH
Export PATH =/u01/ogg: $ PATH
Export GGATE =/u01/ogg
. Use the ggsci tool to create a directory
[Oracle @ redhat6 ogg] $./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 oggcore_11.2.1.0.20.platforms_120423.0230_fbo
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
Copyright (C) 1995,201 2, Oracle and/or its affiliates. All rights reserved.
GGSCI (redhat6) 1> create subdirs
The above configuration must be performed on both the SOURCE and TARGET ends.
2. Configure the SOURCE database
Goldengate captures the source database redo logs for analysis and applies the obtained data to the target database for data synchronization. Therefore, the source database must be in archive mode, and additional logs and forced logs must be enabled.
(1) Archiving mode,
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination/u01/app/oracle/archlog
Oldest online log sequence 12
Next log sequence to archive 14
Current log sequence 14
SQL> select log_mode, supplemental_log_data_min, force_logging from v $ database;
LOG_MODE SUPPLEME
-----------------------
ARCHIVELOG YES NO
(2) force log
SQL> alter database force logging;
Database altered.
(3) additional logs
SQL> alter database add supplemental log data;
SQL> select log_mode, supplemental_log_data_min, force_logging from v $ database;
LOG_MODE SUPPLEME
-----------------------
ARCHIVELOG YES
2.2 disable RecycleBin (oracle10g ogg must be disabled, but oracle11g ogg is not required)
SQL> alter system set recyclebin = off scope = spfile;
System altered.
SQL> shutdown immediate
2.3 create and authorize users who store DDL Information
SQL> create user ggate identified by ggate default tablespace users temporary tablespace temp;
User created.
SQL> grant connect, resource to ggate;
Grant succeeded.
SQL> grant execute on utl_file to ggate;
Grant succeeded.
[Oracle @ redhat6 ~] $ Cd $ GGATE
[Oracle @ redhat6 ggate] $ sqlplus/as sysdba
SQL * Plus: Release 11.2.0.3.0 Production on Mon Dec 9 04:55:44 2013
Copyright (c) 1982,201 1, Oracle. All rights reserved.
Connected:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0-64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @ marker_setup. SQL; --- enter the previously created user ggate
SQL> @ ddl_setup. SQL; --- enter the previously created user ggate
SQL> @ role_setup. SQL; --- enter the previously created user ggate
SQL> grant GGS_GGSUSER_ROLE to ggate;
SQL> @ ddl_enable. SQL;
Iii. Test OGG
3.1 create test users on source db and target db respectively.
Source db:
SQL> create user source identified by oracle default tablespace users temporary tablespace temp;
User created.
SQL> grant connect, resource, dba to source;
Grant succeeded.
Target db:
SQL> create user targer identified by oracle default tablespace tbs_hjj temporary tablespace temp;
User created.
SQL> grant connect, resource, dba to targer;
Grant succeeded.
3.2 Configure MANAGER in SOURCE and TARGET respectively
Perform the same operation on both the remote end and the target end.
GGSCI (redhat6) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
GGSCI (redhat6) 2> edit params mgr
GGSCI (redhat6) 3> start mgr
Manager started.
GGSCI (redhat6) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
3.3 configure the source db replication queue
Connect to the database and test the connection:
GGSCI (redhat6) 5> dblogin userid ggate @ hjj, password ggate
Successfully logged into database.
Add an extract:
GGSCI (redhat6) 6> add extract ext1, tranlog, begin now
EXTRACT added.
GGSCI (redhat6) 7> add exttrail/u01/ogg/dirdat/lt, extract ext1
EXTTRAIL added.
GGSCI (redhat6) 8> edit params ext1
Extract ext1
Userid ggate @ hjj, password ggate
Rmthost redhat6, mgrport 7809
Rmttrail/u01/ogg/dirdat/lt
Ddl include mapped objname source .*;
Table source .*;
GGSCI (redhat6) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
Extract running EXT1 00:00:00 00:00:10
3.4 configure the synchronization queue of TARGET DB
GGSCI (redhat6) 2> edit params./GLOBAL
GGSCHEMA ggate
CHECKPOINTTABLE ggate. checkpoint
GGSCI (redhat6) 3> dblogin userid ggate @ hjj, password ggate
Successfully logged into database.
GGSCI (redhat6) 4> add checkpointtable ggate. checkpoint
Successfully created checkpoint table ggate. checkpoint.
Create a synchronization queue
GGSCI (redhat6) 1> add replicat rep1, exttrail/u01/ogg/dirdat/lt, checkpointtable ggate. checkpoint
REPLICAT added.
GGSCI (redhat6) 5> edit params rep1
Replicat rep1
ASSUMETARGETDEFS
Userid ggate @ hjj, password ggate
Discardfile/u01/ogg/dirdat/rep1_discard.txt, append, megabytes 10
DDL
Map source. *, target targer .*;
3.5 enable synchronization
(1) SOURCE end:
GGSCI (redhat6) 10> start extract ext1
Sending START request to MANAGER...
EXTRACT EXT1 starting
GGSCI (redhat6) 11> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
Extract running EXT1 00:07:38 00:00:00
(2) TARGET end:
GGSCI (redhat6) 3> start replicat rep1
Sending START request to MANAGER...
REPLICAT REP1 starting
GGSCI (redhat6) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
Extract running EXT1 00:00:00 00:00:05
Replicat running REP1 00:00:00
3.6 Test Data Replication
(1) source db:
[Oracle @ redhat6 ogg] $ sqlplus source/oracle
SQL * Plus: Release 11.2.0.3.0 Production on Mon Dec 9 20:09:11 2013
Copyright (c) 1982,201 1, Oracle. All rights reserved.
Connected:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0-64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table hjj as select * from sys. all_users;
Table created.
(2) view Data Synchronization in target db:
[Oracle @ redhat6 ogg] $ sqlplus targer/oracle
SQL * Plus: Release 11.2.0.3.0 Production on Mon Dec 9 20:09:26 2013
Copyright (c) 1982,201 1, Oracle. All rights reserved.
Connected:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0-64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select count (*) from hjj;
COUNT (*)
----------
12
Run the following command on the SOURCE side:
SQL> insert into hjj select * from sys. all_users;
12 rows created.
SQL> commit;
Commit complete.
View synchronization status on TARGET
SQL> select count (*) from hjj;
COUNT (*)
----------
24
One-way replication from Oracle to Oracle is complete.