在配置GoldenGate环境时,刚开始的时候,我们总是需要先初始化把Source Database中需要复制的表的数据先load到目标库中,除非Source Database是一个新建的库或需要复制的对象中还没有任何数据。
目标:为了实现node1中的gate01.到node2的实时数据同步,在配置OGG实现同步前,先把两个系统中的表中的数据完成初始化同步。
说明:完成这个数据同步的技术很多,我这里仅仅是为了说明如何利用GoldenGate的Direct Load的方法实现数据的同步。
把源端数据库的数据同步到目标数据库
初始环境:利用系统的测试脚本(demo_ora_create.sql、demo_ora_insert.sql)完成源端建表和数据插入,目标端的建表工作。
源端数据库:
1、为gate01建立专用的表空间
SQL> create tablespace ggs
2 datafile '/home/app/oradata/node1/ggs01.dbf' size 50m,'/home/app/oradata/node1/ggs02.dbf' size 50m;
Tablespace created.
2、在源数据库上建数据库用户gate01
SQL> create user gate01 identified by gate01
2 default tablespace ggs
3 temporary tablespace TEMP
4 quota unlimited on ggs;
User created.
SQL> grant connect,resource,dba to gate01;
Grant succeeded.
3、在源数据库上建数据库用户gate01的表TCUSTMER、TCUSTORD,并插入记录:
SQL> conn gate01/gate01
Connected.
SQL> @demo_ora_create.sql
SQL> @demo_ora_insert.sql
目标数据库:
4、为gate02建立专用的表空间
SQL> create tablespace ggs
2 datafile '/home/app/oradata/node2/ggs01.dbf' size 50m,'/home/app/oradata/node2/ggs02.dbf' size 50m;
Tablespace created.
5、建数据库用户gate02
SQL> create user gate02 identified by gate02
2 default tablespace ggs
3 temporary tablespace TEMP
4 quota unlimited on ggs;
User created.
SQL> grant connect,resource,dba to gate02;
Grant succeeded.
6、在目标数据库上建数据库用户gate02的表TCUSTMER、TCUSTORD,不需要插入记录
SQL> conn gate02/gate02
Connected.
SQL> @demo_ora_create.sql
7、在源数据上配置管理进程MGR
GGSCI (node1) 1> edit params mgr
port 7809
GGSCI (source) 2> start mgr –启动管理进程
Manager started.
8、在目标数据库上配置管理进程MGR
GGSCI (node2) 1> edit params mgr
port 7809
GGSCI (node2) 2> start mgr
Manager started.
9、在源和目的端检查管理进程是否启动
GGSCI (node1) 3> info mgr
Manager is running (IP port node1.7809).
GGSCI (node2) 3> info mgr
Manager is running (IP port node2.7809).
10、在源数据库上增加需要传输的用户表
GGSCI (node1) 4> dblogin userid gate01,password gate01
Successfully logged into database.
GGSCI (node1) 5> add trandata gate01.tcustmer
Logging of supplemental redo data enabled for table GATE01.TCUSTMER.
GGSCI (node1) 7> add trandata gate01.tcustord
Logging of supplemental redo data enabled for table GATE01.TCUSTORD.
GGSCI (node1) 9> info trandata gate01.*
Logging of supplemental redo log data is enabled for table GATE01.TCUSTMER
Logging of supplemental redo log data is enabled for table GATE01.TCUSTORD
11、在源数据库上配置extract进程 Eora01
GGSCI (node1) 10> add extract eora01,sourceistable
EXTRACT added.
GGSCI (node1) 11> info extract *, tasks
GGSCI (node1) 12> edit params eora01
extract eora01
userid gate01, password gate01
rmthost 192.168.150.129, mgrport 7809
rmttask replicat, group rora01
table gate01.*;
12、在目标数据库上配置replicat进程 Rora01
GGSCI (node2) 4> ADD REPLICAT Rora01, SPECIALRUN
REPLICAT added.
GGSCI (node2) 5> INFO REPLICAT *, TASKS
GGSCI (node2) 6> EDIT PARAMS Rora01
REPLICAT Rora01
ASSUMETARGETDEFS
USERID gate02, PASSWORD "gate02"
DISCARDFILE ./dirrpt/Rora01.dsc, PURGE
MAP gate01.*, TARGET gate02.*;
13、在源数据库上执行初始化过程
GGSCI (node1) 4>START EXTRACT Eora01
GGSCI (node1) 5>VIEW REPORT EORA01(在源数据上查看是否有报错)
GGSCI (node1) 6> VIEW REPORT EORA01
GGSCI (node2) 10>VIEW REPORT RORA01(在目标数据上查看是否有报错)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21256317/viewspace-1063570/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/21256317/viewspace-1063570/