(1)检查必需的lib包
下载对应平台版本的GoldenGate,解压。在解压路径下执行:
[root@GG_HOME] > # ldd ggsci
将列出所有需要的lib和当前缺少的。GoldenGate在Linux和Unix下安装,需要安装ORACLE的lib环境以及$ORACLE_HOME/lib下的几个包,所以必须安装在Oracle之后,而且确保在环境变量中加入:
exportLD_LIBRARY_PATH=$ORACLE_HOME/lib
(2)绿色安装GoldenGate
在解压路径下执行./ggsci进行接口命令行,
[root@GG_HOME] > #./ggsci --进入GoldenGate命令窗口模式
GGSCI> CREATESUBDIRS--建立子目录
GGSCI>edit parammgr--配置GoldenGate主进程参数
由于第一次执行该命令,会提示创建mgr参数文件,点“是”并在文本中输入如下参数:
保存,生成的参数文件保存在GG_HOMEdirprm下
然后可以启动GoldenGate主控制进程:
GGSCI>start mgr
GGSCI>info all--查看进程状态
如果进程MANAGER状态显示为RUNNING则表示主进程已在运行。至此软件安装完成。
和Windows下安装的主要区别是需要确认必需的lib包,进入GGSCI接口命令行后的操作都是一致的。
Ogg 整理文档
1.Vim/etc/hosts
192.168.6.80source
192.168.6.82target
2. 配置/etc/oratab文件
源端: source:$ORACLE_HOME:Y
目标: target: $ORACLE_HOME:Y
3.数据库相关配置:
确保源数据库和目标数据库保持同步(准备工作)
创建用户,授权
SQL> create tablespace gg_tbs datafile '/u01/gg.dbf' size 200mautoextend on next 20m maxsize unlimited loggingonline flashback on;
SQL> create user goldengate identified bygoldengate default tablespace gg_tbs temporary tablespacetemp quota unlimited on users;
grantconnect to goldengate;
grantalter any table to goldengate;
grantalter session to goldengate;
grantcreate session to goldengate;
grantflashback any table to goldengate;
grantselect any dictionary to goldengate;
grantselect any table to goldentage;
grantresource to goldengate;
grant dropany table to goldengate;
grant dbato goldengate;(可直接最大权限给予)
源数据库准备工作
打开补充日志及强制日志
SQL> select supplemental_log_data_min from v$database;--查看是否开启了最小附加日志模式
SQL> alter database add supplemental logdata; --开启最小附加日志模式
光开启最小附加日志模式还不够,还需要打开表级的补全日志,可以在GoldenGate中使用add trandata命令强制重做日志记录主键值,以保证在目标端能成功复制:
GGSCI> dblogin userid ddw,password ddw --GoldenGate中登录OARCLE数据库
GGSCI>add trandata ddw.--表名可以使用通配符
GGSCI>add trandata coss3.per_test,nokey,cols(sampletime,objectid)
可以在数据库中修改
SQL>alter table add supplemental log data (primary key)columns;
千万不要小看这步日志设置,其实在GoldenGate的配置中,这步是最容易出错的环节。如果开启DDL复制做冗灾备份,最好直接在数据库级别打开补全日志:
SQL> alter database add supplemental log data (primarykey,unique,foreign key) columns;
检查一下,全是YES就OK了(整个数据库级别补全)
SQL> select supplemental_log_data_min,
supplemental_log_data_pk,
supplemental_log_data_ui
from v$database;
4. 装goldengate
a. unzip tar xf
b. ./ggsci (配置.so文件路径$ORACLE_HOME/lib)
c. create subdirs
5.配置goldengate
在源端和目标端配置mgr(管理进程)
Edit paramsmgr
输入以下内容:
Port7809
Dynamicportlist 7810-7820
在源端配置:提取进程
add extractextl,tranlog,begin now(取名字小于八个字符)
注意,如果是在RAC环境下,需要再加上THREADS 指定提取的日志THREAD
GGSCI> add extract extl,tranlog,begin now ,THREADS
Edit extract extl 内容如下
extract extl--抽取进程名
userid ddw@orcl,passwordddw--连接本机DB的帐号密码
rmthost192.168.0.44, mgrport7801--目标数据库服务器地址和GG服务端口号
rmttrail d:toolsGGgg10gdirdatrl--远程队列的位置(下一步建的东西)
dynamicresolution--优化参数,动态分析表结构
gettruncates--抓取truncate数据
tableddw.aatest;(ddw.*)--需要抽取的表,可以使用通配符
这种是不太常用的方法: 原因是如果网络出现故障,导致日志不能传送过去经常需要下面一种配置方法:
Add extraceextl,tranlog ,begin now
Edit extrat extl内容如下
Extract extl
Useridgoldengate@source,password goldengate
Exttrail/u01/ogg/gg/rl
Dynamicresolution
Gettruncates
Table goldengate.*;
然后把这个进程创建本地队列: add exttrail / u01/ogg/gg/rl extractextl
接下来,一步也很重要: 创建一个dataPUMP 进程 (这里的datapump与ORACLE 10g推出的数据泵不是一个概念。在GoldenGate中,datapump相当于一个次级提取进程(secondary extract)。在上面演示的同步流程中,提取进程直接将提取的redo信息经过处理后放置到了目标端服务器上,当两者之间的网络出现故障时,会因无法生成trail文件而导致提取进程崩溃,错误提示类似如下:
2010-11-12 10:01:21 GGSERROR150 TCP/IP error 10061 (由于目标机器积极拒绝,无法连接。); retries exceeded.
2010-11-12 10:01:21 GGSERROR190 PROCESS ABENDING.
)
而加入datapump后,主提取进程(即第一个extract)首先将trail生成在本地,然后datapump读取本地trail再发送到目标服务器,即便网络故障,主提取进程仍然能随着事务生成trail文件,而datapump则会暂时停止传输,等待网络通畅后在将堆积的本地trail文件发送至目标服务器,从而实现了断点传输的功能。在实际应用中,每一个同步流程都应该配置datapump以应对网络问题。
Add extract pump,exttrailsource /u01/ogg/gg/rl ,beginnow
Edit params pump
如果有配置可以删除语句(delete rmttrail d:toolsGGgg10gdirdatrlextract extl)
Addrmttrail /u01/ogg/gg/rl (远程队列) extract pump;
接下来是配置 复制进程(replicat)
GGSCI>add replicat repl exttraild:toolsGGgg10gdirdatrl,begin now,nodbcheckpoint–新增复制进程,使用对应的队列rl,即刻开始,使用文件检查点
GGSCI>edit param repl --配置复制进程参数
开启复制进程:
GGSCI>start repl
通过view report进程名(repl,extl,pump)可以查看,信息
正确输出:
源端:view extl
***********************************************************************
Oracle GoldenGate Capture for Oracle
Version 11.2.1.0.1OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64,64bit (optimized), Oracle 11g on Apr 23 2012 08:42:16
Copyright (C) 1995, 2012, Oracle and/or itsaffiliates. All rights reserved.
Starting at 2012-08-17 09:43:06
***********************************************************************
Operating System Version:
Linux
Version #1 SMP Wed Jun 13 18:24:36 EDT 2012,Release 2.6.32-279.el6.x86_64
Node: source
Machine: x86_64
soft limit hardlimit
Address SpaceSize:unlimitedunlimited
HeapSize:unlimitedunlimited
FileSize:unlimitedunlimited
CPUTime:unlimitedunlimited
Process id: 4537
Description:
***********************************************************************
**Running with the followingparameters**
***********************************************************************
2012-08-17 09:43:06INFOOGG-03035 Operating system character setidentifie
d as UTF-8. Locale: en_US, LC_ALL:.
extract extl
userid goldengate@source,password**********
exttrail /u01/ogg/gg/r1
dynamicresolution
gettruncates
table goldengate.*;
2012-08-17 09:43:07INFOOGG-01815 Virtual Memory Facilities for:BR
anonalloc: mmap(MAP_ANON) anon free:munmap
filealloc: mmap(MAP_SHARED) file free:munmap
target directories:
/u01/ogg/BR/EXTL.
Bounded Recovery Parameter:
BRINTERVAL = 4HOURS
BRDIR= /u01/ogg
2012-08-17 09:43:07INFOOGG-01815 Virtual Memory Facilities for:COM
anonalloc: mmap(MAP_ANON) anon free:munmap
filealloc: mmap(MAP_SHARED) file free:munmap
target directories:
/u01/ogg/dirtmp.
CACHEMGR virtual memory values (may have beenadjusted)
CACHESIZE:64G
CACHEPAGEOUTSIZE(normal):8M
PROCESS VM AVAIL FROM OS(min):128G
CACHESIZEMAX (strict force todisk):96G
Database Version:
Oracle Database 11g Enterprise Edition Release11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 -Production
NLSRTL Version 11.2.0.1.0 - Production
Database Language and Character Set:
NLS_LANG= "american_america.zhs16gbk"
NLS_LANGUAGE= "AMERICAN"
NLS_TERRITORY= "AMERICA"
NLS_CHARACTERSET = "ZHS16GBK"
2012-08-17 09:43:07INFOOGG-01513 Positioning to Sequence 55, RBA7695376,
SCN 0.767167.
2012-08-17 09:43:07INFOOGG-01516 Positioned to Sequence 55, RBA7695376,
SCN 0.767167, Aug 17, 2012 9:42:36 AM.
2012-08-17 09:43:07INFOOGG-01055 Recovery initialization completed forta
rget file /u01/ogg/gg/r1000003, at RBA1072.
2012-08-17 09:43:07INFOOGG-01478 Output file /u01/ogg/gg/r1 is usingform
at RELEASE 11.2.
2012-08-17 09:43:07INFOOGG-01026 Rolling over remote file/u01/ogg/gg/r10
00003.
2012-08-17 09:43:07INFOOGG-01053 Recovery completed for target file/u01/
ogg/gg/r1000004, at RBA 1072.
2012-08-17 09:43:07INFOOGG-01057 Recovery completed for alltargets.
***********************************************************************
**Run TimeMessages**
***********************************************************************
2012-08-17 09:43:07INFOOGG-01517 Position of first record processedSeque
nce 55, RBA 7695376, SCN 0.767167, Aug 17, 20129:42:36 AM.
Wildcard TABLE resolved (entrygoldengate.*):
table"GOLDENGATE"."EMP";
Using the following key columns for source tableGOLDENGATE.EMP: EMPNO.
Wildcard TABLE resolved (entrygoldengate.*):
table"GOLDENGATE"."DEPT";
Using the following key columns for source tableGOLDENGATE.DEPT:DEPTNO
目标端:view reportrepl
***********************************************************************
Oracle GoldenGate Delivery for Oracle
Version 11.2.1.0.1OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64,64bit (optimized), Oracle 11g on Apr 23 2012 08:48:07
Copyright (C) 1995, 2012, Oracle and/or itsaffiliates. All rights reserved.
Starting at 2012-08-16 18:55:31
***********************************************************************
Operating System Version:
Linux
Version #1 SMP Wed Jun 13 18:24:36 EDT 2012,Release 2.6.32-279.el6.x86_64
Node: target
Machine: x86_64
soft limit hardlimit
Address SpaceSize:unlimitedunlimited
HeapSize:unlimitedunlimited
FileSize:unlimitedunlimited
CPUTime:unlimitedunlimited
Process id: 5160
Description:
***********************************************************************
**Running with the followingparameters**
***********************************************************************
2012-08-16 18:55:31INFOOGG-03035 Operating system character setidentifie
d as UTF-8. Locale: en_US, LC_ALL:.
replicat repl
userid goldengate@target,password**********
assumetargetdefs
reperror default,discard
discardfile /u01/log.file,append,megabytes100
gettruncates
map goldengate.* ,target goldengate.*;
2012-08-16 18:55:33INFOOGG-01815 Virtual Memory Facilities for:COM
anonalloc: mmap(MAP_ANON) anon free:munmap
filealloc: mmap(MAP_SHARED) file free:munmap
target directories:
/u01/ogg/dirtmp.
CACHEMGR virtual memory values (may have beenadjusted)
CACHESIZE:2G
CACHEPAGEOUTSIZE(normal):8M
PROCESS VM AVAIL FROM OS(min):4G
CACHESIZEMAX (strict force todisk): 3.41G
Database Version:
Oracle Database 11g Enterprise Edition Release11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 -Production
NLSRTL Version 11.2.0.1.0 - Production
Database Language and Character Set:
NLS_LANG= "american_america.ZHS16GBK"
NLS_LANGUAGE= "AMERICAN"
NLS_TERRITORY= "AMERICA"
NLS_CHARACTERSET = "ZHS16GBK"
***********************************************************************
**Run TimeMessages**
***********************************************************************
Opened trail file /u01/ogg/gg/r1000014 at2012-08-16 18:55:34
Switching to next trail file /u01/ogg/gg/r1000015at 2012-08-16 18:55:34 due to
EOF, with current RBA 1210
Opened trail file /u01/ogg/gg/r1000015 at2012-08-16 18:55:34
Processed extract process graceful restart recordat seq 15, rba 1117.
Processed extract process graceful restart recordat seq 15, rba 1176.
Wildcard MAP resolved (entrygoldengate.*):
map "GOLDENGATE"."EMP" ,targetgoldengate."EMP";
Using following columns in default map byname:
EMPNO, ENAME, JOB, MGR,HIREDATE, SAL, COMM, DEPTNO
Using the following key columns for target tableGOLDENGATE.EMP: EMPNO.
Wildcard MAP resolved (entrygoldengate.*):
map "GOLDENGATE"."DEPT" ,targetgoldengate."DEPT";
Using following columns in default map byname:
DEPTNO, DNAME, LOC
Using the following key columns for target tableGOLDENGATE.DEPT: DEPTNO.