Configure Extract(提取) Process in Source system
配置capture(捕获)参数
Edit extract process parameter
GGSCI (gc2) 21> EDIT PARAMS EORA_1 配置capture参数文件
-- Change Capture parameter file to capture
-- EMP_OGG and DEPT_OGG changes
EXTRACT EORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
EXTTRAIL /u01/app/ogg/dirdat/aa 跟踪提取文件放在/u01/app/ogg/dirdat目录下文件名以aa为前缀的文件中:例aa000000
TABLE scott.TCUSTMER; capture(捕获)要监视的表名,capture可以监视多张表也可以值监视一张表
TABLE scott.TCUSTORD;
Please note that “aa” is prefix for local trail file.
Execute the following commands in source system to add Primary Extract group.
GGSCI (gc2) 22> ADD EXTRACT EORA_1, TRANLOG, BEGIN NOW
EXTRACT added.
ADD EXTRACT EORA_1:添加EXTRACT进程,这就是一直运行,一段停止redo 里的日志就没人去抓取了
TRANLOG, BEGIN NOW:现在开始同步日志,也可以用异步,那就要另外配置
Define GoldenGate local trail
GGSCI (gc2) 24> ADD EXTTRAIL /u01/app/ogg/dirdat/aa,EXTRACT EORA_1, MEGABYTES 5 添加跟踪文件给EORA_1用,大小为5M
EXTTRAIL added.
Start primary Extract process
GGSCI (gc2) 25> START EXTRACT EORA_1 //启动进程
Sending START request to MANAGER ...
EXTRACT EORA_1 starting
Verify extract process is running or not:
GGSCI (gc2) 26> INFO EXTRACT EORA_1
EXTRACT EORA_1 Last Started 2014-08-11 18:57 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:01 ago)
Log Read Checkpoint Oracle Redo Logs
2014-08-11 18:57:57 Seqno 9, RBA 2469888
表示现在读取的日志系列号是 sequence 9,RBA 2469888 发生检查点的位置,检查的发生时间和MTTR设置有关,发生检查点
就是将这个检查点之前的脏数据块通过DBWn写入数据文件中,发生检查点的位置就是RBA,一个新的纪元又开始了,这个检查点以前的都保留了
SQL> select group#,sequence#,status from v$log;
GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 8 INACTIVE
2 9 CURRENT
3 7 INACTIVE
[oracle@gc2 ~]$ ps -ef | grep ogg 查看EORA_1进程
oracle 3843 3554 0 18:57 ? 00:00:00 /u01/app/ogg/extract PARAMFILE /u01/app/ogg/dirprm/eora_1.prm REPORTFILE /u01/app/ogg/dirrpt/EORA_1.rpt PROCESSID EORA_1 USESUBDIRS
Now Goldengate will generate local tail file “aa000000” under dirdat in Source system:
[oracle@gc2 ~]$ ll /u01/app/ogg/dirdat/ 查看要跟踪的日志信息,捕获(capture)的日志信息就放在这个跟踪文件里面
total 4
-rw-rw-rw- 1 oracle oinstall 906 Aug 11 18:57 aa000000
Configure pump(传递) process in source system--------------------------------
配置传递到目标库(target)的信息
Edit data pump process parameter
GGSCI (gc2) 27> EDIT PARAMS PORA_1
-- Data Pump parameter file to read the local
-- trail of EMP_OGG and DEPT_OGG changes
--
EXTRACT PORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
PASSTHRU
RMTHOST oraclelinux54.cuug.net, MGRPORT 7809 将捕获的日志传送到目标主机oraclelinux54.cuug.net,端口7809
RMTTRAIL /u01/app/ogg/dirdat/pa
TABLE scott.TCUSTMER;
TABLE scott.TCUSTORD;
Add data pump Extract group
GGSCI (gc2) 29> ADD EXTRACT PORA_1, EXTTRAILSOURCE /u01/app/ogg/dirdat/aa
告诉PORA_1要传送哪个路径下的跟踪信息
EXTRACT added.
Verify results:
GGSCI (gc2) 30> INFO EXTRACT PORA_1
EXTRACT PORA_1 Initialized 2014-08-11 19:08 Status STOPPED
Checkpoint Lag 00:00:00 (updated 00:00:23 ago)
Log Read Checkpoint File /u01/app/ogg/dirdat/aa000000
First Record RBA 0
Add GoldenGate remote(远程) trail in Source system
在源数据库端配置远程的路径及文件
GGSCI (gc2) 31> ADD RMTTRAIL /u01/app/ogg/dirdat/pa, EXTRACT PORA_1, MEGABYTES 5
表示把捕获到的信息传送到远程的哪个目录的文件中
RMTTRAIL added.
Start data pump process:
GGSCI (gc2) 32> START EXTRACT PORA_1 启动传送,一直运行
Sending START request to MANAGER ...
EXTRACT PORA_1 starting
Verify the results:
GGSCI (gc2) 33> INFO EXTRACT PORA_1
EXTRACT PORA_1 Last Started 2014-08-11 19:11 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:00 ago)
Log Read Checkpoint File /u01/app/ogg/dirdat/aa000000
First Record RBA 906
Now Goldengate will generate remote tail file “pa000000” under dirdat in Target system:
[oracle@gc2 ~]$ ll /u01/app/ogg/dirdat/
total 4
-rw-rw-rw- 1 oracle oinstall 906 Aug 11 18:57 aa000000
Configure replicat(复制) process in target system-----------------------------------------
在目标端配置怎么接收,怎么处理传过来的信息
Create GLOBALS parameter in target system
Edit GLOBALS(upper case) parameter file to indicate checkpoint table
GGSCI (oraclelinux54.cuug.net) 5> EDIT PARAMS ./GLOBALS
CHECKPOINTTABLE ogg.ggschkpt 用到ogg下的checkpoint表
Verify:
[oracle@oraclelinux54.cuug.net:/u01/app/ogg]$ll GLOBALS
-rw-rw-rw- 1 oracle oinstall 29 Aug 11 07:14 GLOBALS
For GLOBALS configuration take effect, we must exit GGSCI session:
GGSCI (oraclelinux54.cuug.net) 6> exit
Add replicat checkpoint table in target system:
GGSCI (oraclelinux54.cuug.net) 1> DBLOGIN USERID ogg, PASSWORD ogg 登入到目标数据库
Successfully logged into database.
GGSCI (oraclelinux54.cuug.net) 2> ADD CHECKPOINTTABLE 把检查点信息放到这个表当中,专门存放checkpoint的表
Successfully created checkpoint table OGG.
sys@TDB112>conn ogg/ogg
ogg@TDB112>select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------------------------------------------------------------------ --------------------- ----------
GGSCHKPT TABLE
Edit Delivery process parameter
Add Replicat group:
GGSCI (oraclelinux54.cuug.net) 4>ADD REPLICAT RORA_1, EXTTRAIL/u01/app/ogg/dirdat/pa
表示从哪里提取传送过来的信息
REPLICAT added.
Edit replicat process RORA_1 parameter:
GGSCI (oraclelinux54.cuug.net) 7> EDIT PARAM RORA_1
--
-- Change Delivery parameter file to apply
-- EMP_OGG and DEPT_OGG 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;
Note: In the MAP statement, the first owner/schema is for the source and the second for the target.
Start Replicat process:
GGSCI (oraclelinux54.cuug.net) 8> START REPLICAT RORA_1
Sending START request to MANAGER ...
REPLICAT RORA_1 starting
Verify:
GGSCI (oraclelinux54.cuug.net) 9> INFO REPLICAT RORA_1
REPLICAT RORA_1 Initialized 2014-08-11 07:20 Status STOPPED
Checkpoint Lag 00:00:00 (updated 00:07:19 ago)
Log Read Checkpoint File /u01/app/ogg/dirdat/pa000000
First Record RBA 0
Verify if DML can be duplicated correctly
Insert operation
Insert data in source system:
SQL> conn scott/tiger
SQL> insert into tcustmer values ('abbb','beijing','shanghao' ,'ch');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from tcustmer;
CUST NAME CITY ST
---- ------------------------------ -------------------- --
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
abb beijing shanghao ch
Check the result in target system:
SQL> select * from tcustmer;
CUST NAME CITY ST
---- ------------------------------ -------------------- --------------------------------------
WILL BG SOFTWARE CO. SEATTLE WA
JANE ROCKY FLYER INC. DENVER CO
abb beijing shanghao ch