Oracle GoldenGate 学习教程二、配置和使用(4)

  当GoldenGate运行时会产生一些与同步数据不相关的文件,这些文件记录了GoldenGate进程错误、数据库错误、GoldenGate操作等信息,这个文件叫做Discard file,配置Replicat进程时由DISCARDFILE参数定义,这个参数是可选的,但推荐创建相应的目录并配置,方便诊断GoldenGate错误问题;
创建Discard file目录

[oracle@sywu ogg_trg]$ mkdir /u01/app/product/ogg_trg/discrd [oracle@sywu ogg_trg]$ chmod 775 /u01/app/product/ogg_trg/discrd/

目标端创建Replicat进程

GGSCI (sywu) 27> add replicat rsydb001,exttrail /u01/app/product/ogg_trg/dirdat/ps,checkpointtable OGG_TRG.OGG_CHK REPLICAT added.

编辑Replicat进程配置文件

REPLICAT rsydb001 SETENV(ORACLE_SID="sydb") SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8) USERID ogg_trg,password ogg_trg DISCARDFILE /u01/app/product/ogg_trg/discrd/reptr.desc,append,megabytes 512 ALLOWNOOPUPDATES ASSUMETARGETDEFS MAP OGG_OWNER.TOGG,target OGG_TRG.TOGG;

到这里简单的源端和目标端的MGR、Extract、Replicat进程就配置完了,测试配置文件是否错误,进程启动是否正常,如果进程有问题就使用“view report 进程名”查看错误;不要将所有进程启动,因为有些工作还没有完成。

3 初始化数据

为什么要初始化数据?
  因为DML操作包括INSERT、UPDATE、DELETE、SELECT操作,而在这些操作中UPDATE、DELETE操作Redo只记录了变更的数据列以及行ID(ROWID),GoldenGate抽取数据后将其转换为自己的格式发送都目标端,假设源端有100条数据,从08:00 AM开始同步到目标端,而在同步开始前目标端没有初始化数据(目标端为空数据),那么08:00 AM后事物产生的UPDATE、DELETE DML操作发送到目标端,目标端GoldenGate Replicat进程会因为找不到数据而报错从而导致Replicat进程崩溃停止(ABENDED),所以这就需要我们在同步前初始化数据,初始化完后再同步,这样大大降低错误率。同步数据的方式可以通过DBLINK、EXP/IMP、SQLLDR或者表空间迁移等方式同步;我的测试都在同一个库所以就直接创建表了。

SYS@sydb>create table ogg_trg.togg as select * from ogg_owner.togg 2 / Table created. Elapsed: 00:00:00.24 4 使用GoldenGate

数据初始化后,分别启动源端MGR进程、主抽取进程(Primary Extract)、Data Pump进程(Secondly Extract)以及目标端MGR进程、Replicat进程;
启动源端GoldenGate进程

[oracle@sywu ~]$ sggsci Oracle GoldenGate Command Interpreter for Oracle Version 12.1.2.1.0 OGGCORE_12.1.2.1.0_PLATFORMS_140727.2135.1_FBO Linux, x64, 64bit (optimized), Oracle 11g on Aug 7 2014 09:14:25 Operating system character set identified as UTF-8. Copyright (C) 1995, 2014, Oracle and/or its affiliates. All rights reserved. GGSCI (sywu) 1> start mgr Manager started. GGSCI (sywu) 2> start PSYDB001 Sending START request to MANAGER ... EXTRACT PSYDB001 starting GGSCI (sywu) 3> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING ESYDB001 00:00:00 00:00:02 EXTRACT RUNNING PSYDB001 00:00:00 12:41:34

启动目标端GoldenGate进程

[oracle@sywu ~]$ tggsci Oracle GoldenGate Command Interpreter for Oracle Version 12.1.2.1.0 OGGCORE_12.1.2.1.0_PLATFORMS_140727.2135.1_FBO Linux, x64, 64bit (optimized), Oracle 11g on Aug 7 2014 09:14:25 Operating system character set identified as UTF-8. Copyright (C) 1995, 2014, Oracle and/or its affiliates. All rights reserved. GGSCI (sywu) 1> start mgr Manager started. GGSCI (sywu) 2> start RSYDB001 Sending START request to MANAGER ... REPLICAT RSYDB001 starting GGSCI (sywu) 3> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT RUNNING RSYDB001 00:00:00 00:00:07

进程都启动完了,此时观察源端和目标端trail文件生成情况

[oracle@sywu ~]$ ls -ltr /u01/app/product/ogg_src/dirdat total 324 -rw-r-----. 1 oracle oinstall 1418 Aug 26 09:42 es000000 -rw-r-----. 1 oracle oinstall 1481 Aug 26 09:48 es000001 -rw-r-----. 1 oracle oinstall 1481 Aug 26 09:50 es000002 -rw-r-----. 1 oracle oinstall 1481 Aug 26 09:52 es000003 -rw-r-----. 1 oracle oinstall 1481 Aug 26 09:52 es000004 [oracle@sywu ~]$ ls -ltr /u01/app/product/ogg_trg/dirdat total 324 -rw-r-----. 1 oracle oinstall 193469 Aug 25 13:00 ps000000 -rw-r-----. 1 oracle oinstall 891 Aug 25 13:00 ps000001 -rw-r-----. 1 oracle oinstall 1652 Aug 25 13:07 ps000002 -rw-r-----. 1 oracle oinstall 891 Aug 25 13:07 ps000003 -rw-r-----. 1 oracle oinstall 105884 Aug 25 13:49 ps000004 -rw-r-----. 1 oracle oinstall 891 Aug 25 13:49 ps000005 -rw-r-----. 1 oracle oinstall 2095 Aug 26 09:54 ps000006 -rw-r-----. 1 oracle oinstall 1201 Aug 26 09:54 ps000007 -rw-r-----. 1 oracle oinstall 2032 Aug 26 09:54 ps000008

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/34cc0a588956ba1ccf7320b8e7f0a08e.html