一.安装条件
1.前提条件:
1).源、目标Oracle数据库监听启动
2).gg安装目录为/u01/app/ogg
3).被复制表必须存在主键
4).进程配置的抽取日志目录是否有效,如果进程配置正确,
目录不一致很可能导致复制不成功
5).操作系统
rhel 5.4 X64(2.6.18-164.el5)
LANG=en_US.UTF-8
数据库软件
Oracle 11.2.0.3.0_X64
Database Language and Character Set:
NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK"
NLS_LANGUAGE = "AMERICAN"
NLS_TERRITORY = "AMERICA"
NLS_CHARACTERSET = "ZHS16GBK"
goldengate软件
ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
6)主机信息
source: 192.168.100.5 linux1
target: 192.168.100.6 linux2
2.目录权限
chown -R oracle.oinstall /u01/app/ogg
chmod -R 775 /u01/app/ogg
3.设置环境变量
LD_LIBRARY_PATH 、PATH
oracle用户环境文件尾添加
su - oracle
vi .bash_profile
# User specific environment and startup programs
export ORACLE_BASE=/u01/app/oracle -- oracle base目录
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 -- Oracle Home目录
export ORACLE_SID=oradb1 -- Oracle SID
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin -- Oracle PATH目录
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib -- Oracle Share LIB目录
export LD_LIBRARY_PATH=/u01/app/ogg:$LD_LIBRARY_PATH -- gg Share LIB目录
export PATH=/u01/app/ogg:$PATH -- gg PATH目录
alias gg="cd /u01/app/ogg;./ggsci" -- 命令别名
4.gg目录初始化
su - oracle
gg
GGSCI (linux1) 1>create subdirs
GGSCI (linux1) 2>exit
5.进程分布
1) source:
mgr 管理进程
ep01 抽取进程
dp01 投递进程
2)target:
mgr 管理进程
rp01 应用进程
二、源端数据库配置
1.归档模式
查看归档
archive log list;
非归档时处理
shutdown immediate
startup mount
alter database archivelog;
alter database open;
archive log list;
2.强制日志
数据库打开状态
alter database force logging;
select force_logging from v$database;
输出为yes
修改归档之后切换日志文件
alter system switch logfile;
3.补充日志
alter database add supplemental log data;
select supplemental_log_data_min from v$database;
4.关闭回收站
goldengate 10中如果需要使用DDL复制,需要关闭回收站,
goldengate 11已经不需要
10.1
alter system set "recyclebin"=false;
10.2
alter system set recyclebin=off;
5.创建gg用户和授权
create tablespace tbs_gg datafile '/u01/app/oracle/ogg1.dbf' size 50m;
create user ogg identified by ogg default tablespace tbs_gg;
grant connect,resource to ogg;
grant dba to ogg;
建立测试用户和表
create user user1 identified by user1;
grant connect,resource to user1;
conn user1/user1
create table table1(id number,name varchar2(100));
6.GoldenGate设置
1)添加检查点
su - oracle
gg
GGSCI (linux1) 8>dblogin userid ogg,password ogg
GGSCI (linux1) 9>add checkpointtable ogg.checkpoint
GGSCI (linux1) 10> edit params ./GLOBALS
checkpointtable ogg.checkpoint
2)配置manager进程
GGSCI (linux1) 11> edit params mgr
port 7809
dynamicportlist 7810-7830
purgeoldextracts /u01/app/ogg/dirdat/lt*,usecheckpoints,minkeepdays 7,minkeepfiles 20
保存退出
start mgr
3)配置extract进程
GGSCI (linux1) 4> edit params ep01
extract ep01
userid ogg,password ogg
exttrail /u01/app/ogg/dirdat/lt
table user1.table1;
保存退出
add extract ep01,tranlog,begin now
add exttrail /u01/app/ogg/dirdat/lt,extract ep01,megabytes 20
start ep01
5)配置pump进程
GGSCI (linux1) 8> edit params dp01
extract dp01
passthru
rmthost 192.168.100.6,mgrport 7809
rmttrail /u01/app/ogg/dirdat/rt
table user1.table1;
保存退出
add extract dp01,exttrailsource /u01/app/ogg/dirdat/lt
add rmttrail /u01/app/ogg/dirdat/rt,extract dp01,megabytes 20
start dp01
三、目标数据库
1. 创建用户和表
create tablespace tbs_gg datafile '/u01/app/oracle/ogg1.dbf' size 50m;
create user ogg identified by ogg default tablespace tbs_gg;
grant connect,resource to ogg;
grant dba to ogg;
创建测试用户和表
create user user1 identified by user1;
grant connect,resource to user1;
conn user1/user1
create table table1(id number,name varchar2(100));
2.配置管理进程
GGSCI (linux2) 6> edit params mgr
port 7809
dynamicportlist 7810-7830
purgeoldextracts /u01/app/ogg/dirdat/rt*,usecheckpoints,minkeepdays 7,minkeepfiles 20
保存退出
启动mgr进程
GGSCI (linux2) 25>start mgr
3.配置replicate进程
1)编辑replicate配置
GGSCI (linux2) 26> edit params rp01
replicat rp01
SETENV(NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
userid ogg,password ogg
dboptions suppresstriggers
assumetargetdefs
map user1.table1,target user1.table1;
保存退出
2)添加检查点
GGSCI (linux2) 13>dblogin userid ogg,password ogg
GGSCI (linux2) 14>add checkpointtable ogg.checkpoint
GGSCI (linux2) 11> edit params ./GLOBALS
checkpointtable ogg.checkpoint
3)添加replicat进程
GGSCI (linux2) 15>add replicat rp01,exttrail /u01/app/ogg/dirdat/rt,begin now,CHECKPOINTTABLE ogg.checkpoint
启动rp01进程
GGSCI (linux2) 16>start rp01
进行DML插入测试