目的端配置大致分为如下三个步骤:配置mgr,配置checkpoint table,配置应用进程
在目的端先创建一张表,记得带主键:
mysql> create database hr;
Query OK, 1 row affected (0.00 sec)
mysql> use hr
Database changed
mysql> create table ah4(id int ,name varchar(10),primary key(id));
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
+————–+
| Tables_in_hr |
+————–+
| ah4 |
+————–+
1 row in set (0.00 sec)
mysql>
1.配置mgr
GGSCI (nosql2) 2> edit params mgr
PORT 7809
DYNAMICPORTLIST 7810-7909
--AUTOSTART ER *
AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3
PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 3
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45
GGSCI (nosql2) 3> start mgr
Manager started.
GGSCI (nosql2) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
2.配置checkpoint table
GGSCI (nosql2) 7> edit params ./GLOBALS
CHECKPOINTTABLE hr.checkpoint
添加:
GGSCI (nosql2) 8> add checkpointtable hr.checkpointtab
Successfully created checkpoint table hr.checkpointtab.
GGSCI (nosql2) 9> info checkpointtable hr.checkpointtab
Checkpoint table hr.checkpointtab created 2014-04-02 16:11:38.
GGSCI (nosql2) 10>
在相应的mysql数据库中,也可以看到相应的表被添加了:
mysql> show tables;
+---------------+
| Tables_in_hr |
+---------------+
| ah4 |
| checkpointtab |
+---------------+
2 rows in set (0.00 sec)
3.配置应用进程:
GGSCI (nosql2) 10> edit params rep3
replicat rep3
sourcedefs /u01/ogg/11.2/dirdef/ah4.prm
SOURCEDB hr,userid root,password 123456
reperror default,discard
discardfile /u01/ogg/11.2/dirrpt/rep4.dsc,append,megabytes 50
map hr.ah4, target hr.ah4;
GGSCI (nosql2) 13> add replicat rep3,exttrail /u01/ogg/11.2/dirdat/xs,checkpointtable hr.checkpointtab
REPLICAT added.
PS:
REPLICAT进程参数配置说明:
ASSUMETARGETDEFS:假定两端数据结构一致使用此参数;
SOURCEDEFS:假定两端数据结构不一致,使用此参数指定源端的数据结构定义文件,该文件需要由GlodenGate工具产生。
MAP:用于指定源端与目标端表的映射关系;
MAPEXCLUDE:用于使用在MAP中使用*匹配时排除掉指定的表;
REPERROR:定义出错以后进程的响应,一般可以定义为两种:
ABEND,即一旦出现错误即停止复制,此为缺省配置;
DISCARD,出现错误后继续复制,只是把错误的数据放到discard文件中。
DISCARDFILE:定义discardfile文件位置,如果处理中油记录出错会写入到此文件中;
SQLEXEC:在进程运行时首先运行一个SQL语句;
GROUPTRANSOPS:将小交易合并成一个大的交易进行提交,减少提交次数,降低系统IO消耗。
MAXTRANSOPS:将大交易拆分,每XX条记录提交一次。
4.测试
在目的端启动rep3进程,在源端启动ext3和push3进程。
在源端的ah4表中插入一条数据,看是否在目的端的ah4表中能看到。
源端进程:
GGSCI (ora11g) 30> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXT1 00:00:00 00:00:03
EXTRACT RUNNING EXT2 00:00:00 00:00:07
EXTRACT RUNNING EXT3 00:44:09 00:00:06
EXTRACT RUNNING PUSH1 00:00:00 00:00:03
EXTRACT RUNNING PUSH2 00:00:00 00:00:03
EXTRACT RUNNING PUSH3 00:00:00 00:37:40
GGSCI (ora11g) 31>
源端插入数据:
SQL> insert into ah4 values(1,'aaaccc');
1 row created.
SQL> commit;
Commit complete.
源端的ogg日志:
2014-04-02 16:19:26 INFO OGG-00993 Oracle GoldenGate Capture for Oracle, ext3.prm: EXTRACT EXT3 started.
2014-04-02 16:19:26 INFO OGG-01052 Oracle GoldenGate Capture for Oracle, ext3.prm: No recovery is required for target file /u01/ogg/11.2/dirdat/xs000000, at RBA 0 (file not opened).
2014-04-02 16:19:26 INFO OGG-01478 Oracle GoldenGate Capture for Oracle, ext3.prm: Output file /u01/ogg/11.2/dirdat/xs is using format RELEASE 11.2.
2014-04-02 16:19:26 INFO OGG-01517 Oracle GoldenGate Capture for Oracle, ext3.prm: Position of first record processed Sequence 1122, RBA 14423056, SCN 0.20548956, Apr 2, 2014 3:35:22 PM.
2014-04-02 16:19:29 INFO OGG-00987 Oracle GoldenGate Command Interpreter for Oracle: GGSCI command (oracle): start push3.
2014-04-02 16:19:29 INFO OGG-00963 Oracle GoldenGate Manager for Oracle, mgr.prm: Command received from GGSCI on host ora11g:52177 (START EXTRACT PUSH3 ).
2014-04-02 16:19:29 INFO OGG-00975 Oracle GoldenGate Manager for Oracle, mgr.prm: EXTRACT PUSH3 starting.
2014-04-02 16:19:29 INFO OGG-00992 Oracle GoldenGate Capture for Oracle, push3.prm: EXTRACT PUSH3 starting.
2014-04-02 16:19:29 INFO OGG-03035 Oracle GoldenGate Capture for Oracle, push3.prm: Operating system character set identified as UTF-8. Locale: en_US, LC_ALL:.
2014-04-02 16:19:29 INFO OGG-01815 Oracle GoldenGate Capture for Oracle, push3.prm: Virtual Memory Facilities for: COM
anon alloc: mmap(MAP_ANON) anon free: munmap
file alloc: mmap(MAP_SHARED) file free: munmap
target directories:
/u01/ogg/11.2/dirtmp.
2014-04-02 16:19:29 INFO OGG-00993 Oracle GoldenGate Capture for Oracle, push3.prm: EXTRACT PUSH3 started.
2014-04-02 16:19:34 INFO OGG-01226 Oracle GoldenGate Capture for Oracle, push3.prm: Socket buffer size set to 27985 (flush size 27985).
2014-04-02 16:19:34 INFO OGG-01052 Oracle GoldenGate Capture for Oracle, push3.prm: No recovery is required for target file /u01/ogg/11.2/dirdat/xs000000, at RBA 0 (file not opened).
2014-04-02 16:19:34 INFO OGG-01478 Oracle GoldenGate Capture for Oracle, push3.prm: Output file /u01/ogg/11.2/dirdat/xs is using format RELEASE 11.2.
目的端进程:
GGSCI (nosql2) 21> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT RUNNING REP3 00:00:00 00:00:02
GGSCI (nosql2) 22>
目的端数据库:
mysql> select * from ah4;
+----+--------+
| id | name |
+----+--------+
| 1 | aaaccc |
+----+--------+
1 row in set (0.00 sec)
mysql>
目的端的ogg日志:
2014-04-02 16:21:55 INFO OGG-00975 Oracle GoldenGate Manager for MySQL, mgr.prm: REPLICAT REP3 starting.
2014-04-02 16:21:55 INFO OGG-00995 Oracle GoldenGate Delivery for MySQL, rep3.prm: REPLICAT REP3 starting.
2014-04-02 16:21:55 INFO OGG-03035 Oracle GoldenGate Delivery for MySQL, rep3.prm: Operating system character set identified as UTF-8. Locale: en_US, LC_ALL:.
2014-04-02 16:21:55 INFO OGG-01815 Oracle GoldenGate Delivery for MySQL, rep3.prm: Virtual Memory Facilities for: COM
anon alloc: mmap(MAP_ANON) anon free: munmap
file alloc: mmap(MAP_SHARED) file free: munmap
target directories:
/u01/ogg/11.2/dirtmp.
2014-04-02 16:21:55 INFO OGG-00996 Oracle GoldenGate Delivery for MySQL, rep3.prm: REPLICAT REP3 started.
2014-04-02 16:22:17 INFO OGG-00963 Oracle GoldenGate Manager for MySQL, mgr.prm: Command received from EXTRACT on host ::ffff:192.168.0.164 (START SERVER CPU -1 PRI -1 TIMEOUT 300 PARAMS ).
2014-04-02 16:22:17 INFO OGG-01677 Oracle GoldenGate Collector for MySQL: Waiting for connection (started dynamically).
2014-04-02 16:22:17 INFO OGG-00963 Oracle GoldenGate Manager for MySQL, mgr.prm: Command received from SERVER on host localhost.localdomain (REPORT 30868 7810).
2014-04-02 16:22:17 INFO OGG-00974 Oracle GoldenGate Manager for MySQL, mgr.prm: Manager started collector process (Port 7810).
2014-04-02 16:22:17 INFO OGG-01228 Oracle GoldenGate Collector for MySQL: Timeout in 300 seconds.
2014-04-02 16:22:22 INFO OGG-01229 Oracle GoldenGate Collector for MySQL: Connected to ::ffff:192.168.0.164:61104.
2014-04-02 16:22:22 INFO OGG-01669 Oracle GoldenGate Collector for MySQL: Opening /u01/ogg/11.2/dirdat/xs000000 (byte -1, current EOF 0).
2014-04-02 16:22:53 INFO OGG-03010 Oracle GoldenGate Delivery for MySQL, rep3.prm: Performing implicit conversion of column data from character set windows-936 to ISO-8859-1.
转载请注明:IT运维空间 » 首页 » 配置ogg异构oracle-mysql(3)目的端配置
发表评论