Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1934580
  • 博文数量: 389
  • 博客积分: 7877
  • 博客等级: 少将
  • 技术积分: 4531
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-10 14:02
文章分类

全部博文(389)

文章存档

2024年(1)

2022年(1)

2021年(1)

2020年(1)

2019年(1)

2018年(3)

2017年(6)

2016年(4)

2015年(8)

2014年(15)

2013年(31)

2012年(19)

2011年(47)

2010年(33)

2009年(105)

2008年(109)

2007年(4)

分类: Oracle

2011-04-27 15:04:08

创建golden gate用户

useradd gguser
passwd gguser

编辑.bash_profile环境变量,新增下面内容:
LD_LIBRARY_PATH=/home/gguser/gg:/opt/ibm/db2/V9.7/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

DB2INSTANCE=db2inst1
export DB2INSTANCE

LANG=zh_CN.GBK
export LANG


安装golden gate软件

golden gate for db2 v9.7 on linux64 安装文件,注意对于不同的数据库有不同的安装文件。
ggs_Linux_x64_db297_64bit_v11_1_1_0_0_078.tar

将文件传至目标端,解压即可
tar -xvf ggs_Linux_x64_db297_64bit_v11_1_1_0_0_078.tar

在golden gate安装目录下执行下面命令,以将manager作为service //这样DOS窗口就不会停留在窗口
install addservice addevents

源端配置golden gate
./ggsci
GGSCI (sourcedb1) 35>help    //这里,必须是进入到golden gate软件安装目录下才可以执行help命令
GGSCI (sourcedb1) 35>create subdirs
GGSCI (sourcedb1) 35>edit param mgr
port 7839
--DYNAMICPORTLIST 7840-7860 此处已注释,需要的话可以打开,但要保证这些端口可用
AUTOSTART EXTRACT *
AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 2
PURGEOLDEXTRACTS /home/gguser/gg/dirdat/ee*, USECHECKPOINTS, MINKEEPDAYS 2
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

配置需要捕获有数据变动的源表
GGSCI (sourcedb1) 35>dblogin sourcedb destination, userid db2inst1, password db2inst1
如果是正常登录数据库的话,会显示“Successfully logged into database.”
这里dblogin后面,除了ORACLE数据库之外,都需要跟sourcedb这个参数
GGSCI (sourcedb1) 35>add trandata db2inst1.TEST1
GGSCI (sourcedb1) 35>add trandata db2inst1.TEST2
正确情况下会显示“Logging of supplemental log data (include longvar) is enabled for table "DB2INST1"."TEST1"“

查询源表是否是golden gate捕获日志的表
GGSCI (sourcedb1) 35>info trandata db2inst1.TEST1

在源端建立抽取进程
GGSCI (sourcedb1) 35>add extract extkevin, tranlog, begin now

在源端配置本地trail文件
GGSCI (sourcedb1) 35>add exttrail /home/gguser/gg/dirdat/ee, extract extkevin, megabytes 50

配置extract参数
GGSCI (sourcedb1) 35>edit params extkevin
extract extkevin
dboptions NOCATALOGCONNECT, FETCHBATCHSIZE 1500
sourcedb destination, userid db2inst1, password db2inst1
exttrail /home/gguser/gg/dirdat/ee, megabytes 50
COMPRESSUPDATES
GETTRUNCATES
WILDCARDRESOLVE DYNAMIC
TRANLOGOPTIONS MANAGESECONDARYTRUNCATIONPOINT
table db2inst1.TEST1;
table db2inst1.TEST2;


在源端建立传送进程
GGSCI (sourcedb1) 35>add extract datapump, exttrailsource /home/gguser/gg/dirdat/ee

在源端配置trail文件传送至目标端地址
GGSCI (sourcedb1) 35>add  rmttrail  /home/gguser/gg/dirdat/ee, extract datapump

查看源端extract信息
GGSCI (sourcedb1) 36> info extract *

查看源端rmttrail信息
GGSCI (sourcedb1) 35> info rmttrail *

配置datapump参数
GGSCI (sourcedb1) 35>edit params datapump
extract datapump
sourcedb destination, userid db2inst1, password db2inst1
rmthost 172.16.36.21, mgrport 7839, compress
rmttrail /home/gguser/gg/dirdat/ee
SOURCEDEFS /home/gguser/gg/dirdef/db2test.def
gettruncates
wildcardresolve dynamic
table db2inst1.TEST1;
table db2inst1.TEST2;


至此源端的Goldengate 配置完毕!


目标端配置golden gate
./ggsci
GGSCI (destination1) 1>help    //这里,必须是进入到golden gate软件安装目录下才可以执行help命令
GGSCI (destination1) 1>create subdirs
GGSCI (destination1) 1>edit param mgr
port 7839
--dynamicportlist 7840-7850
purgeoldextracts /home/gguser/gg/dirdat/ee*,USECHECKPOINTS, MINKEEPDAYS 1
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

GGSCI (destination1) 1>edit params ./GLOBALS
checkpointtable odsuser.ggchkptable

GGSCI (destination1) 1>dblogin sourcedb destination, userid odsuser, password odsuser
GGSCI (destination1) 1>add checkpointtable odsuser.ggchkptable
在目标端建立复制进程
GGSCI (destination1) 1>add replicat repkevin, exttrail /home/gguser/gg/dirdat/ee, checkpointtable odsuser.ggchkptable

GGSCI (destination1) 1>edit params repkevin
replicat repkevin
targetdb destination, userid odsuser, password odsuser
discardfile /home/gguser/gg/dirrpt/reptest.dsc, append, MEGABYTES 200
numfiles 1000
SOURCEDEFS /home/gguser/gg/dirdef/db2test.def
dynamicresolution
handlecollisions
MAP db2inst1.TEST1, TARGET odsuser.TEST1, COLMAP (USEDEFAULTS, time = @GETENV ("GGHEADER", "COMMITTIMESTAMP"), date = @COLSTAT (NULL), operation = @GETENV ("GGHEADER", "OPTYPE") );
MAP db2inst1.TEST2, TARGET odsuser.TEST2;


启动源端和目标端所有进程
GGSCI (destination1) 1>start mgr
GGSCI (destination1) 1>start replicat repkevin

GGSCI (sourcedb1) 35>start mgr
GGSCI (sourcedb1) 35>start extract extkevin
GGSCI (sourcedb1) 35>start extract datapump

在源端进行DML操作,
在目标端进行验证




配置初始化同步
源端
GGSCI (sourcedb1) 35>add extract einikk, sourceistable
GGSCI (sourcedb1) 35>edit params einikk
extract einikk
sourcedb destination, userid db2inst1, password db2inst1
rmthost 172.16.36.21, mgrport 7839
rmttask replicat, group rinikk
table db2inst1.TEST1;
table db2inst1.TEST2;

目标端
GGSCI (destination1) 1>add replicat rinikk, specialrun
GGSCI (destination1) 1>edit params rinikk
replicat rinikk
SOURCEDEFS /home/gguser/gg/dirdef/db2test.def
targetdb destination, userid odsuser, password odsuser
MAP db2inst1.TEST1, TARGET odsuser.TEST1, COLMAP (USEDEFAULTS, time = @GETENV ("GGHEADER", "COMMITTIMESTAMP"), operation = @GETENV ("GGHEADER", "OPTYPE") );
MAP db2inst1.TEST2, TARGET odsuser.TEST2;


这样配置就完成了,开始启动源端的init load的extract 则开始做初始化加载

GGSCI (sourcedb1) 4> start extract einikk
GGSCI (sourcedb1) 4> view report einikk


GGSCI (destination1) 1> view report rinikk



def文件生成方法
GGSCI (sourcedb1) 4>edit params ./dirprm/defgen.prm
DEFSFILE ./dirdef/db2test.def, PURGE
sourcedb destination, userid db2inst1, password db2inst1
table db2inst1.TEST1;
table db2inst1.TEST2;

defgen paramfile ./dirprm/defgen.prm reportfile ./dirrpt/defgen.rpt

如果在初始化同步的时候,中间有表因为map等问题报错,导致同步进程异常中断,可以这样处理

对于已经成功同步的表,将其从 rinikk 配置文件里面删除掉,然后继续同步剩下的表!


阅读(3784) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~