转发一份GoldenGate 配置文档,里面有参数说明,值得看
性质
IP
系统
ORACLE版本
源端
10.122.0.110
AIX 5.3
10.2.0.1
目标端
10.122.0.113
WINDOWS 2003
10.2.0.1
?
创建GoldenGate安装目录并解压安装文件
unzip ogg112101_ggs_AIX_ppc_ora10.2_64bit.zip
tar –xf ggs_AIX_ppc_ora10.2_64bit.tar
注意:使用的安装包一定要与平台一致
?
设置环境变量
在用户参数文件中添加以下内容:
export GGATE_HOME=/u01/oracle/oracle/ogg
export LIBPATH=$GGATE_HOME:$ORACLE_HOME/lib
注意:添加后需使参数文件生效
HP及LINUX平台下用LD_LIBRARY_PATH替换LIBPATH
?
安装GoldenGate
进入OGG控制台创建OGG工作目录
然后在安装目录下执行 ./ggsci? 进入OGG控制台
执行命令 createsubdirs创建工作目录,显示如下:
GGSCI (NDSCDB1)1> create subdirs
Creatingsubdirectories under current directory /u01/oracle/oracle/ogg
?
Parameterfiles??????????????/u01/oracle/oracle/ogg/dirprm: already exists
Reportfiles?????????????????/u01/oracle/oracle/ogg/dirrpt: created
Checkpointfiles?????????????/u01/oracle/oracle/ogg/dirchk: created
Process statusfiles???????? ???/u01/oracle/oracle/ogg/dirpcs: created
SQL scriptfiles?????????????? /u01/oracle/oracle/ogg/dirsql:created
Databasedefinitions files??? ???/u01/oracle/oracle/ogg/dirdef: created
Extract datafiles?????????? ???/u01/oracle/oracle/ogg/dirdat: created
Temporaryfiles??????????????/u01/oracle/oracle/ogg/dirtmp: created
Stdout files??????????????????/u01/oracle/oracle/ogg/dirout: created
建立OGG安装目录,然后将压缩包解压到目录中,进入cmd控制台,创建工作目录,
操作步骤显示如下:
?
?
数据库模式配置
源端数据库必须开启归档模式
Alter databasearchivelog;
开启最小附加日志
Alter databaseadd supplemental log data;
使用SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;
可查看是否开启了最小附加日志;
?
源端数据库创建GoldenGate数据库用户并授权:(我们这里以ogg为例,使用其他亦可)
create user ogg identified by oracle defaulttablespace DATA_OL;
grant connect,resource,unlimited tablespace to ogg;
grant executeon utl_file to ogg;
grant select any dictionary,select any table to ogg;
grant alter any table to ogg;
grant flashback any table to ogg;
grant execute onDBMS_FLASHBACK to ogg;
添加表级transdata
GGSCI (NDSCDB1) 2>dblogin userid ogg,password oracle
Successfully logged intodatabase.
GGSCI(NDSCDB1) 3> add trandata olive.ol$_objects
Logging of supplemental redo dataenabled for table OLIVE.OL$_OBJECTS.
?
配置管理进程mgr:
GGSCI(NDSCDB1) 1> edit param mgr
(粘贴下面这段配置)
PORT 7839
DYNAMICPORTLIST 7840-7939
--AUTOSTART ER *
AUTORESTART EXTRACT *,RETRIES5,WAITMINUTES 3
PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45
MANAGER进程参数配置说明:
PORT:指定服务监听端口;这里以7839为例,默认端口为7809
DYNAMICPORTLIST:动态端口:可以制定最大256个可用端口的动态列表,当指定的端口不可用时,管理进程将会从列表中选择一个可用的端口,源端和目标段的Collector、Replicat、GGSCI进程通信也会使用这些端口;
COMMENT:注释行,也可以用--来代替;
AUTOSTART:指定在管理进程启动时自动启动哪些进程;
AUTORESTART:自动重启参数设置:本处设置表示每3分钟尝试重新启动所有EXTRACT进程,共尝试5次;
PURGEOLDEXTRACTS:定期清理trail文件设置:本处设置表示对于超过3天的trail文件进行删除。
LAGREPORT、LAGINFO、LAGCRITICAL:
定义数据延迟的预警机制:本处设置表示MGR进程每隔1小时检查EXTRACT的延迟情况,如果超过了30分钟就把延迟作为信息记录到错误日志中,如果延迟超过了45分钟,则把它作为警告写到错误日志中。
?
启动管理进程:
GGSCI(NDSCDB1) 2> start mgr
Managerstarted.
查看进程状态可发现 性质 IP 系统 ORACLE版本 源端 10.123.112.201/10.123.112.202 LINUX rhel5 64位 10.2.0.1 目标端 10.123.112.235 LINUX rhel5 32位 10.2.0.1 ? RAC环境中为了实现高可用性,需将OGG安装在集群文件系统中,这样OGG可以访问RAC中的所有节点,我们这里测试采用OCFS2文件系统。 从http://oss.oracle.com下载与LINUX内核相符的OCFS2 RPM包 LINUX下执行uname –r查看系统内核版本 eg: [oracle@node2ocfs]$ uname -r 2.6.18-92.el5 ? 使用ROOT用户安装OCFS2的RPM包 [root@node1ocfs]# rpm -ivh ocfs2-tools-1.2.7-1.el5.x86_64.rpm \ ocfs2console-1.2.7-1.el5.x86_64.rpm\ ocfs2-2.6.18-92.el5-1.2.9-1.el5.x86_64.rpm 进入OCFS2控制台界面 [root@node1 ~]#ocfs2console 在出现的窗体中选择[Clucster]-[ConfigureNodes]在"NodeConfiguration"对话框中,输入2个专用互连的节点名、IP 地址、端口号后,选择 [Clucster]-[PropagateCluster Configuration] ,提示"Finished"。 配置后的信息显示如下: ? 在集群中的所有节点上以 root 用户帐户的身份运行以下命令 创建ocfs2文件系统,其中-N选项用于指明最多允许多少个节点同时使用此文件系统: # mkfs -t ocfs2-N 2 /dev/sdh1 挂载分区: # mount /dev/sdh1/ggate ? 配置启动自动载入(所有节点): chown -Roracle:dba /ggate ? 在GoldenGate安装目录(OCFS2目录/ggate)解压安装文件 unzipogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip tar–xvf fbo_ggs_Linux_x64_ora10g_64bit.tar ? 设置环境变量 在用户参数文件中添加以下内容: exportGGATE_HOME=/ggate exportLD_LIBRARY_PATH=$GGATE_HOME:$ORACLE_HOME/lib 注意:添加后需使参数文件生效 ? 安装GoldenGate 进入OGG控制台创建OGG工作目录 然后在安装目录下执行 ./ggsci? 进入OGG控制台 执行命令 createsubdirs创建工作目录,显示如下: GGSCI(node1) 1> create subdirs ? Creatingsubdirectories under current directory /ggate ? Parameterfiles??????????????? then ? pid=`cut -f8"${GGS_HOME}/dirpcs/MGR.pcm"` ? if [ ${pid} = `ps -e |grep ${pid} |grep mgr|cut -d " " -f2` ] ? then ??? #manager process is running on the PID exitsuccess ??? exit 0 ? else ? if [ ${pid} = `ps -e |grep ${pid} |grep mgr|cut -d " " -f1` ] ? then ??? #manager process is running on the PID exitsuccess ??? exit 0 ? else ??? #manager process is not running on the PID ??? exit 1 ? fi fi else ? #manager is not running because there is noPID file ? exit 1 fi } ? #call_ggsci isa generic routine that executes a ggsci command call_ggsci () { ? ggsci_command=$1 ? ggsci_output=`${GGS_HOME}/ggsci << EOF ? ${ggsci_command} ? exit ? EOF` } ? case $1 in 'start') ? #start manager ? call_ggsci 'start manager' ? #there is a small delay between issuing thestart manager command ? #and the process being spawned on the OS.wait before checking ? sleep ${start_delay_secs} ? #check whether manager is running and exitaccordingly ? check_process ? ;; ? 'stop') ? #attempt a clean stop for all non-managerprocesses ? #call_ggsci 'stop er *' ? #ensure everything is stopped ? call_ggsci 'stop er *!' ? #call_ggsci 'kill er *' ? #stop manager without (y/n) confirmation ? call_ggsci 'stop manager!' ? #exit success ? exit 0 ? ;; ? 'check') ? check_process ? ;; ? 'clean') ? #attempt a clean stop for all non-managerprocesses ? #call_ggsci 'stop er *' ? #ensure everything is stopped ? #call_ggsci 'stop er *!' ? #in case there are lingering processes ? call_ggsci 'kill er *' ? #stop manager without (y/n) confirmation ? call_ggsci 'stop manager!' ? #exit success ? exit 0 ? ;; ? 'abort') ? #ensure everything is stopped ? call_ggsci 'stop er *!' ? #in case there are lingering processes ? call_ggsci 'kill er *' ? #stop manager without (y/n) confirmation ? call_ggsci 'stop manager!' ? #exit success ? exit 0 ? ;; ? esac ? 添加一个应用程序profile [oracle@node1 ggate]$cd $ORA_CRS_HOME/bin [oracle@node1bin]$ pwd /u01/app/oracle/product/10.2.0/crs_1/bin [oracle@node1 bin]$crs_profile –create GG_app –t application \ –r ggvip –a/ggate/gg_action.scr –o ci=10 ? 其中:-r ggvip表示ggvip必须在GoldenGate启动之前运行, -a /ggate/gg_action.scr指定action 脚本的位置,在每个节点必须都可用 –o ci=10:检查的时间间隔设置为10 ? 把这个资源注册到CRS: [oracle@node1 bin]$crs_register GG_app ? 把vip 的所有权给root,在root用户下执行: [root@node1 bin]#./crs_setperm ggvip –o oracle 为oracle用户分配启动这个资源的权限: [root@node1 bin]#./crs_setperm GG_app –u user:oracle:r-x 通过oracle用户启动这个资源: [oracle@node1bin]$ crs_start GG_app Attempting tostart `GG_app` on member `node1` Start of`GG_app` on member `node1` succeeded. 查看资源状态显示如下: [oracle@node1bin]$ crs_stat GG_app -t Name?????????? Type?????????? Target??? State ????Host??????? ------------------------------------------------------------ GG_app???????? application??? ONLINE???ONLINE??? node1? ? 测试节点迁移 在测试环境中可以使用crs_relocate –fGG_app使它强行漂移:过程显示如下: [oracle@node1~]$ crs_stat -t Name?????????? Type?????????? Target??? State????Host??????? ------------------------------------------------------------ GG_app????? ???application???ONLINE??? ONLINE??? node1?????? ggvip??????? ???application???ONLINE??? ONLINE??? node1?????? ora....AC1.srv?? ?application???ONLINE ???ONLINE??? node1?????? ora....AC2.srv?? ?application???ONLINE??? ONLINE??? node2?????? ora.RAC.RAC.cs application??? ONLINE???ONLINE??? node2?????? ora....C1.inst?? ?application???ONLINE??? ONLINE??? node1?????? ora....C2.inst?? ?application???ONLINE??? ONLINE??? node2?????? ora.RAC.db???? application??? ONLINE???ONLINE??? node1?????? ora....E1.lsnr?? ?application???ONLINE??? ONLINE??? node1?????? ora.node1.gsd ??application???ONLINE??? ONLINE??? node1?????? ora.node1.ons ??application???ONLINE??? ONLINE??? node1?????? ora.node1.vip ??application???ONLINE??? ONLINE??? node1?????? ora....E2.lsnr? ??application???ONLINE??? ONLINE??? node2?????? ora.node2.gsd ??application???ONLINE??? ONLINE??? node2?????? ora.node2.ons ??application???ONLINE??? ONLINE???node2?????? ora.node2.vip ??application???ONLINE??? ONLINE??? node2?????? [oracle@node1 ~]$ crs_relocate -f GG_app Attempting to stop `GG_app` on member `node1` Stop of `GG_app` on member `node1` succeeded. Attempting to stop `ggvip` on member `node1` Stop of `ggvip` on member `node1` succeeded. Attempting to start `ggvip` on member `node2` Start of `ggvip` on member `node2` succeeded. Attempting to start `GG_app` on member `node2` Start of `GG_app` on member `node2` succeeded. [oracle@node1~]$ crs_stat -t Name?????????? Type?????????? Target??? State????Host??????? ------------------------------------------------------------ GG_app???????? application??? ONLINE???ONLINE??? node2?????? ggvip?????? ????application??? ONLINE???ONLINE??? node2?????? ora....AC1.srv?? ?application???ONLINE??? ONLINE??? node1?????? ora....AC2.srv?? ?application???ONLINE??? ONLINE??? node2?????? ora.RAC.RAC.cs ?application???ONLINE??? ONLINE??? node2?????? ora....C1.inst??? ?application???ONLINE??? ONLINE??? node1?????? ora....C2.inst??? ?application???ONLINE??? ONLINE??? node2?????? ora.RAC.db?? ???application???ONLINE??? ONLINE??? node1?????? ora....E1.lsnr??? ?application???ONLINE??? ONLINE??? node1?????? ora.node1.gsd ???application???ONLINE??? ONLINE???node1?????? ora.node1.ons ???application???ONLINE??? ONLINE??? node1?????? ora.node1.vip ???application???ONLINE??? ONLINE??? node1?????? ora....E2.lsnr??? ?application???ONLINE??? ONLINE??? node2?????? ora.node2.gsd ???application???ONLINE??? ONLINE??? node2?????? ora.node2.ons ???application???ONLINE??? ONLINE??? node2?????? ora.node2.vip ???application???ONLINE??? ONLINE??? node2?????? 可以看到GoldenGate成功转移到2节点运行了。 ? ? 启动源端抽取进程extnd,ggserr.log错误显示如下: 2012-08-1711:11:38? 2012-08-28 15:09:41? ERROR??OGG-01668? Oracle GoldenGateCapture for Oracle, dpend.prm:? PROCESSABENDING.目标端ggserr.log错误显示如下: 2012-08-2815:06:30? WARNING OGG-01223? Oracle GoldenGate Collector for Oracle:? Unable to lock file"/uo1/app/ogg/dirdat/nd000004" (error 11, Resource temporarilyunavailable).? Lock currently held byprocess id (PID) 13854. 2012-08-2815:06:30? WARNING OGG-01223? Oracle GoldenGate Collector for Oracle:? Unable to open file"/uo1/app/ogg/dirdat/nd000004" (error 2, No such file or directory). 导致原因:可能是网络出现过故障,OGG源端的Data Pump进程与目标断了联系,目标端mgr为其启动的server进程一直还在运行,下次data pump重启时目标mgr会试图生成另外一个server进程,这样两个进程会争同一个队列文件。 处理方法: 1、停掉源端的所有data pump,使用ps –ef|grep server(或OGG安装目录)看看是不是还有OGG的server进程在跑,如果有,杀死它(一定要确认源端data pump全停掉,并且杀的是server进程,不要杀其它extract/replicat/mgr等),重启源端data pump即可。 ? 2、可能是目标端的trail file出问题了,前滚重新生成一个新的队列文件 SEND EXTRACT xxx ETROLLOVER 或者:alter extract xxx etrollover xxx为datapump的名称 ? 错误信息:2011-03-29 15:53:57? WARNINGOGG-01154? Oracle GoldenGate Delivery forOracle, repya.prm:? SQL error 14402mapping EPMA.D_METER to E PMA.D_METER OCIError ORA-14402: updating partition key column would cause a partition change(status = 14402), SQL <UPDATE "EPMA"."D_METER" SET"PR_ORG" = :a1,"BELONG_DEPT" = :a2 WHERE"METER_ID" = :b0>. 导致原因:源端更新了分区列,但目标端没有打开行移动,导致更新时报错; 处理方法:SQLPLUS>alter table SCHEMA.TABLENAME enable row movement;3.2?源端安装OCFS2集群文件系统
? ? export PATH=$PATH:/sbin:/usr/sbin
? ? /etc/init.d/o2cb enable
? ? export PATH=$PATH:/sbin:/usr/sbin
? ? chkconfig --add o2cb
? ? /etc/init.d/o2cb configure
?在/etc/rc.local增加入下内容:??? ???
chmod -R 775 /ggate3.3?源端安装GoldenGate
5???????常见错误及解决方法
5.1?OGG-00446
5.5?OGG-01154