GoldenGate配置(二)之双向复制配置
环境:
Item |
Source System |
Target System |
Platform |
Red Hat Enterprise Linux Server release 5.4 |
Red Hat Enterprise Linux Server release 5.4 |
Hostname |
gc1 |
gc2 |
Database |
Oracle 10.2.0.1 |
Oracle 11.2.0.1 |
Character Set |
ZHS16GBK |
ZHS16GBK |
ORACLE_SID |
PROD |
EMREP |
Listener Name/Port |
LISTENER/1521 |
LISTENER/1521 |
Goldengate User |
ogg |
ogg |
SQL>grant CONNECT, RESOURCE to ogg;
SQL>grant CREATE SESSION, ALTER SESSION to ogg;
SQL>grant SELECT ANY DICTIONARY, SELECT ANY TABLE to ogg;
SQL>grant ALTER ANY TABLE to ogg;
SQL>grant FLASHBACK ANY TABLE to ogg;
SQL>grant EXECUTE on DBMS_FLASHBACK to ogg;
SQL>grant CONNECT, RESOURCE to ogg;
SQL>grant CREATE SESSION, ALTER SESSION to ogg;
SQL>grant SELECT ANY DICTIONARY, SELECT ANY TABLE to ogg;
SQL>grant CREATE TABLE to ogg;
SQL>grant INSERT, UPDATE, DELETE on scott.tcustmer to ogg;--把需要同步表的DML操作授权给ogg
SQL>grant INSERT, UPDATE, DELETE on scott.tcustord to ogg;--把需要同步表的DML操作授权给ogg
SQL>alter database add supplemental log data;
SQL>alter system switch logfile;
SQL>alter database force logging;
GGSCI(gc2) 1> DBLOGIN USERID ogg, PASSWORD Ogg
Successfully logged into database.
GGSCI(gc2) 2> ADD TRANDATA scott.TCUSTMER
Logging of supplemental redo data enabled fortable SCOTT.TCUSTMER.
GGSCI(gc2) 3> ADD TRANDATA scott.TCUSTORD
Logging of supplemental redo data enabled fortable SCOTT.TCUSTORD.
GGSCI(gc2) 4> EDIT PARAMS EORA_1
-- Change Capture parameter file to capture
-- TCUSTMER and TCUSTORD changes
EXTRACT EORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD Ogg
TRANLOGOPTIONS EXCLUDEUSER ogg
EXTTRAIL ./dirdat/aa
TABLE scott.TCUSTMER;
TABLE scott.TCUSTORD;
~
~
"dirprm/eora_1.prm" [New] 9L, 257Cwritten
GGSCI(gc2) 5> ADD EXTRACT EORA_1, TRANLOG, BEGIN NOW
EXTRACT added.
GGSCI(gc2) 6> ADD EXTTRAIL ./dirdat/aa, EXTRACT EORA_1, MEGABYTES 5
EXTTRAIL added.
GGSCI(gc2) 7> START EXTRACT EORA_1
Sending START request to MANAGER ...
EXTRACT EORA_1 starting
GGSCI(gc2) 8> INFO EXTRACT EORA_1
EXTRACT EORA_1 Last Started 2014-06-1811:28 Status RUNNING
Checkpoint Lag 00:00:19 (updated 00:00:08 ago)
Log Read Checkpoint Oracle Redo Logs
2014-06-18 11:27:42 Seqno 6, RBA 35344
GGSCI(gc2) 9> EDIT PARAMS PORA_1
添加以下内容:
-- Data Pump parameter file to read thelocal
-- trail of TCUSTMER and TCUSTORDchanges
--
EXTRACT PORA_1
SETENV(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
PASSTHRU
RMTHOST gc1, MGRPORT 7809
RMTTRAIL ./dirdat/pa
TABLE scott.TCUSTMER;
TABLE scott.TCUSTORD;
~
~
~
"dirprm/pora_1.prm" [New] 10L, 250Cwritten
GGSCI(gc2) 10> ADD EXTRACT PORA_1, EXTTRAILSOURCE ./dirdat/aa
EXTRACT added.
GGSCI(gc2) 11> ADD RMTTRAIL ./dirdat/pa, EXTRACT PORA_1, MEGABYTES 5
RMTTRAIL added.
GGSCI(gc2) 12> START EXTRACT PORA_1
Sending START request to MANAGER ...
EXTRACT PORA_1 starting
GGSCI(gc1) 1> EDIT PARAMS ./GLOBALS
CHECKPOINTTABLE ogg.ggschkpt
~
~
"./GLOBALS" [New] 1L, 29C written
GGSCI(gc1) 2> quit
[oracle@gc1ogg]$ ll GLOBALS --验证
-rw-rw-rw- 1 oracle oinstall 29 Jun 18 11:33GLOBALS
GGSCI(gc1) 1> DBLOGIN USERID ogg, PASSWORD Ogg
Successfully logged into database.
GGSCI(gc1) 2> ADD CHECKPOINTTABLE
No checkpoint table specified, using GLOBALSspecification (ogg.ggschkpt)...
Successfully created checkpoint tableOGG.GGSCHKPT.
GGSCI(gc1) 3> EDIT PARAM RORA_1
--
-- Change Delivery parameter file to apply
-- TCUSTMER and TCUSTORD Changes
--
REPLICAT RORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD Ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE ./dirrpt/RORA_aa.DSC, PURGE
MAP scott.tcustmer, TARGET scott.tcustmer;
MAP scott.tcustord, TARGET scott.tcustord;
~
~
"dirprm/rora_1.prm" [New] 12L, 327Cwritten
GGSCI(gc1) 4> ADD REPLICAT RORA_1, EXTTRAIL ./dirdat/pa
REPLICAT added.
GGSCI(gc1) 5> START REPLICAT RORA_1
Sending START request to MANAGER ...
REPLICAT RORA_1 starting
GGSCI(gc1) 6> info all
Program Status Group Lag Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EORA_1 00:00:00 00:00:08
EXTRACT RUNNING PORA_1 00:00:00 00:00:01
REPLICAT RUNNING RORA_1 00:00:00 00:00:06
GGSCI(gc2) 13> info all
Program Status Group Lag Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EORA_1 00:00:00 00:00:09
EXTRACT RUNNING PORA_1 00:00:00 00:00:06
REPLICAT RUNNING RORA_1 00:00:00 00:00:01
验证insert操作双向同步
gc1: gc1→gc2,DML操作:insert操作
SQL>insert into tcustmer VALUES(‘HYL‘,‘HUANG DBA.‘,‘HARBIN‘,‘CN‘);
1 row created.
SQL>commit;
Commit complete.
SQL>select * from tcustmer;
CUST NAME CITY ST
---- -------------------------------------------------- --
HYL HUANGDBA. HARBIN CN
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
SQL>insert into tcustmer VALUES(‘WT‘,‘WANGDBA.‘,‘QINGDAO‘,‘CN‘);
1 row created.
SQL>commit;
Commit complete.
SQL>select * from tcustmer;
CUST NAME CITY ST
---- -------------------------------------------------- --
HYL HUANGDBA. HARBIN CN
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
WT WANGDBA. QINGDAO CN
SQL>update tcustmer set city = ‘BEIJING‘, state = ‘CN‘ wherecust_code=‘HYL‘;
1 row updated.
SQL>commit;
Commit complete.
SQL>select * from tcustmer;
CUST NAME CITY ST
---- ------------------------------ ----------------------
HYL HUANGDBA. BEIJING CN
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
WT WANGDBA. QINGDAO CN
SQL>update tcustmer set city = ‘BEIJING‘, state = ‘CN‘ wherecust_code=‘WT‘;
1 row updated.
SQL>commit;
Commit complete.
SQL>select * from tcustmer;
CUST NAME CITY ST
---- -------------------------------------------------- --
HYL HUANGDBA. BEIJING CN
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
WT WANGDBA. BEIJING CN
SQL>delete from tcustmer where CUST_CODE=‘WT‘;
1 row deleted.
SQL>commit;
Commit complete.
SQL>select * from tcustmer;
CUST NAME CITY ST
---- -------------------------------------------------- --
HYL HUANGDBA. BEIJING CN
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
SQL>delete from tcustmer where CUST_CODE=‘HYL‘;
1 row deleted.
SQL>commit;
Commit complete.
SQL>select * from TCUSTMER;
CUST NAME CITY ST
---- -------------------------------------------------- --
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
--至此,GoldenGate双向同步复制完成
声明:
原创作品,出自 “深蓝的blog” 博客,允许转载,转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。
关于涉及版权事宜,作者有权追究法律责任。
GoldenGate配置(二)之双向复制配置,布布扣,bubuko.com
原文:http://blog.csdn.net/huangyanlong/article/details/32977275