测试环境:
源端: win2003 R2 + SQLServer 2008 企业版
目标端:win2003 R2 + Oracle 10.2.0.1.0
源端先建好ODBC数据源: mssql-testdb1
数据库源端要做过一次全备份
mssql 用户: gguser/ggpwd, 默认schema: gguser
一. 初始化配置
1. 源端(SQL Server):
1) 创建子目录
进入安装包目录,运行ggsci.exe,输入如下命令
GGSCI> CREATE SUBDIRS
2) 添加windows服务进程
GGSCI> EDIT PARAMS ./GLOBALS
将以下内容添加到文件GLOBALS中
--------------------------------------------------
MGRSERVNAME GGSMGR-MSSQL
--------------------------------------------------
通过windows命令行窗口进入GoldenGate安装包目录,执行命令:
E:\duanbb\ogg\mssql> INSTALL ADDSERVICE
2. 目标端
1) 创建子目录
进入安装包目录,运行ggsci.exe,输入如下命令
GGSCI> CREATE SUBDIRS
2) 添加windows服务进程
GGSCI> EDIT PARAMS ./GLOBALS
将以下内容添加到文件GLOBALS中
--------------------------------------------------
MGRSERVNAME GGSMGR-ORACLE
--------------------------------------------------
通过windows命令行窗口进入GoldenGate安装包目录,执行命令:
E:\duanbb\ogg\oracle> INSTALL ADDSERVICE
二. 数据同步准备
1. 源端
1) GGSCI> EDIT PARAM MGR
--------------------------------------------------
PORT 6809
--------------------------------------------------
GGSCI> START MANAGER
2) 添加附加日志(supplemental log)
GGSCI> DBLOGIN SOURCEDB mssql-testdb1, USERID gguser, PASSWORD ggpwd
GGSCI> ADD TRANDATA gguser.t1
3) 建立数据类型转换
(1) GGSCI> EDIT PARAM defgen
--------------------------------------------------
DEFSFILE E:\duanbb\ogg\mssql\dirdef\t1.def, PURGE
SOURCEDB mssql-testdb1, USERID gguser, PASSWORD ggpwd
TABLE gguser.t1;
--------------------------------------------------
"gguser.t1"中的gguser指的是schema,下同
(2)运行windows命令行,进入安装目录,运行defgen,生成t1.def
E:\duanbb\ogg\mssql>defgen paramfile .\dirprm\defgen.prm
(3)将生成的t1.def拷到目标端dirdef目录下,因为目标端Replicat进程要用
2. 目标端
1) 启动 Manager 进程
GGSCI> EDIT PARAM MGR
--------------------------------------------------
PORT 7809
--------------------------------------------------
GGSCI> START MANAGER
2) 创建同步用户及对应的同步表
SQL> create user duanbb identified by duanbb;
User created.
SQL> grant connect, resource,select any dictionary to duanbb;
Grant succeeded.
SQL> create table t1(
ID NUMBER(10) NOT NULL,
NAME VARCHAR2(100),
PRIMARY KEY(ID));
三. 针对初始数据加载配置 Extract 和 Replicat
1. 源端
将extract进程命名为 INIEXT (init extract)
GGSCI> ADD EXTRACT iniext, SOURCEISTABLE
GGSCI> EDIT PARAM iniext
--------------------------------------------------
EXTRACT INIEXT
SOURCEDB mssql-testdb1, USERID gguser, PASSWORD ggpwd
RMTHOST 192.168.2.89, MGRPORT 7809
RMTTASK REPLICAT, GROUP INIREP
TABLE gguser.t1;
--------------------------------------------------
2. 目标端
1) 为 Replicat 进程设置参数
GGSCI> ADD REPLICAT INIREP, SPECIALRUN
GGSCI> EDIT PARAMS INIREP
--------------------------------------------------
REPLICAT INIREP
USERID duanbb, PASSWORD duanbb
DISCARDFILE E:\duanbb\ogg\oracle\inirep.txt, PURGE
SOURCEDEFS E:\duanbb\ogg\oracle\dirdef\t1.def
MAP gguser.t1, TARGET duanbb.t1;
--------------------------------------------------
四. 运行初始提取和加载
1. 在源端执行
GGSCI> START EXTRACT INIEXT
2. 在目标端验证
GGSCI> VIEW REPORT INIREP
五. 实时同步配置
1. 源端
GGSCI> ADD EXTRACT MSEXT, TRANLOG, BEGIN NOW
GGSCI> EDIT PARAMS MSEXT
--------------------------------------------------
EXTRACT MSEXT
TRANLOGOPTIONS MANAGESECONDARYTRUNCATIONPOINT
SOURCEDB mssql-testdb1, USERID gguser, PASSWORD ggpwd
RMTHOST 192.168.2.89, MGRPORT 7809
RMTTRAIL E:\duanbb\ogg\oracle\dirdat\ms
TABLE GGUSER.T1;
--------------------------------------------------
GGSCI> ADD RMTTRAIL E:\duanbb\ogg\oracle\dirdat\ms, EXTRACT MSEXT, MEGABYTES 50
2. 目标端
GGSCI> EDIT PARAMS ./GLOBALS
增加如下内容(不要覆盖以前的内容)
--------------------------------------------------
CHECKPOINTTABLE duanbb.chkpt
--------------------------------------------------
GGSCI> EXIT
GGSCI> DBLOGIN USERID duanbb, PASSWORD duanbb
GGSCI> ADD CHECKPOINTTABLE
GGSCI> ADD REPLICAT MSREP, EXTTRAIL E:\duanbb\ogg\oracle\dirdat\ms
GGSCI> EDIT PARAMS MSREP
--------------------------------------------------
REPLICAT MSREP
USERID duanbb, PASSWORD duanbb
SOURCEDEFS E:\duanbb\ogg\oracle\dirdef\t1.def
DISCARDFILE E:\duanbb\ogg\oracle\dirrpt\msrep.dsc, PURGE
MAP gguser.t1, TARGET duanbb.t1;
--------------------------------------------------
六. 启动并测试联机事务复制
1. 源端
GGSCI> START EXTRACT MSEXT
2. 目标端
GGSCI> START REPLICAT MSREP