一.安裝條件
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插入測試
本文出自 “yiyi” 部落格,請務必保留此出處http://heyiyi.blog.51cto.com/205455/1294264