目标:搭建一个Oracle到Oracle的Goldengate双向复制环境(支持DDL+DML)。
环境:
OS:Red Hat Enterprise Linux Server release 5.5 (Tikanga)
DB:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
gg1和gg2互为source和target,所处OS和所安DB均一样。
Oracle GoldenGate 系列:Extract 进程的恢复原理
Oracle goldengate的OGG-01004 OGG-1296错误
Oracle GoldenGate快速入门教程:基本概念和配置
搭建Oracle 到Oracle 的Golden Gate 单向复制测试环境
一、安装GG
在gg1和gg2都执行如下操作:
(1)添加环境变量,在/home/oracle/.bash_profile文件里添加如下内容:
export PATH=/u01/ggate:$PATH
exportLD_LIBRARY_PATH=/u01/ggate:$LD_LIBRARY_PATH
export ggtest=/u01/ggate
这里的GG 和Oracle 使用的是相同的用户,所以把GG 的变量加上就可以了。加载刚刚设置的环境变量:
source/home/oracle/.bash_profile
(2)使用ggsci工具,创建必要的目录
gg1:/u01/ggate> ggsci
--调用ggsci 工具
Oracle GoldenGate Command Interpreter forOracle
Version 11.1.1.1OGGCORE_11.1.1_PLATFORMS_110421.2040
Linux, x64, 64bit (optimized), Oracle 11gon Apr 21 2011 22:42:14
Copyright (C) 1995, 2011, Oracle and/or itsaffiliates. All rights reserved.
GGSCI (gg1) 1> create subdirs
--使用ggsci 工具创建目录
Creating subdirectories under currentdirectory /u01/ggate
Parameter files /u01/ggate/dirprm: created
Report files /u01/ggate/dirrpt: created
Checkpoint files /u01/ggate/dirchk: created
Process status files /u01/ggate/dirpcs: created
SQL script files /u01/ggate/dirsql: created
Database definitions files /u01/ggate/dirdef: created
Extract data files /u01/ggate/dirdat: created
Temporary files /u01/ggate/dirtmp: created
Veridata files /u01/ggate/dirver: created
Veridata Lock files /u01/ggate/dirver/lock: created
Veridata Out-Of-Sync files /u01/ggate/dirver/oos: created
Veridata Out-Of-Sync XML files/u01/ggate/dirver/oosxml: created
Veridata Parameter files /u01/ggate/dirver/params: created
Veridata Report files /u01/ggate/dirver/report: created
Veridata Status files /u01/ggate/dirver/status: created
Veridata Trace files /u01/ggate/dirver/trace: created
Stdout files /u01/ggate/dirout: created
GGSCI (gg1) 2>
以上就是GG 的安装,在source 和target database 都执行。
二、分别配置source和target
(1)GoldenGate通过抓取源端数据库重做日志进行分析,将获取的数据应用到目标端,实现数据同步。因此,源数据库需要必须处于归档模式,并启用附加日志和强制日志。
归档模式、附加日志、强制日志
--查看
SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;
LOG_MODE SUPPLEME FOR
------------ -------- ---
ARCHIVELOG NO NO
--修改
(1)archivelog
SQL>shutdown immediate
SQL>startup mount
SQL>alter database archivelog;
SQL>alter database open;
(2)force logging
SQL>alterdatabase force logging;
(3)supplemental log data
SQL>alterdatabase add supplemental log data;
(2)禁用Recycle Bin
如果启用DDL 支持,必须关闭recycle bin。官网的解释如下: