引言:最近在論壇裡經常會看到有朋友諮詢Oracle GG 實施案例的文章,誠然 GG 目前在各大論壇裡的資料都不是很多 很全,尤其是真實實施案例就更鳳毛麟角了,鑒於此我今天就為大家轉一份朋友做過的GG實施給大家分享,本次分享的是“相同資料庫之間的複製”,話不多說,趕緊上乾貨。
實驗環境:oracle10g+RedHat4+goldengate
一、安裝redhat4,安裝步驟略
二、安裝oracle10g安裝步驟略
三、安裝goldengate,注意要選對版本
1、源端安裝配置
1.1安裝goldengate
linux: mkdir /u01/oracle/ggate
cd /u01/oracle/ggate
通過ftp,將goldengate的zip軟體上傳到/u01/oracle/ggate
unzip解壓,將產生一個tar檔案
tar -xvf *.tar
1.2配置.bash_profile
vi .bash_profile
添加:
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/oracle/ggate
export GGATE_HOME=/u01/oracle/ggate
注意LD_LIBRARY_PATH,那一行,可以在原來安裝oracle的基礎上添加在後面便可
配置完,運行source ~./bash_profile
1.3建立goldengate目錄
cd /u01/oracle/ggate
./ggsci(進入goldengate命令列介面)
Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.0.0 Build 078
Linux, x86, 32bit (optimized), Oracle 10 on Jul 28 2010 13:24:18
Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved
現在在goldengate命令列工作
create subdirs
1.4設定資料庫歸檔模式,進入sql命令列(如果關閉,建議開啟)
sqlplus "/as sysdba"
alter system set log_archive_format='%s_%t_%r.log' scope=spfile;
alter system set log_archive_dest_1='location=/u02/oracle/arc';
shutdown immediate;
startup mount;
alter database archivelog;
開啟強制記錄模式:alter database force logging;
alter database open;
這下可以看一下歸檔是否已經起來,archive log list
1.5開啟minimal supplemental logging
--alter database add supplemental log data;這種設定是許多文檔介紹的,但是對於非主鍵或唯一索引表的會有問題,在測試過程中,發覺update會報錯,可能其它地方沒搞好!
alter database add supplemental log data(primary key,unique) columns;這是我的配置!
1.6關閉資源回收筒
alter system set recyclebin=off scope=spfile;
1.7配置複製的DDL支援
建立使用者授權:
create user ggate identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;
grant connect,resource,dba to ggate;
grant execute on utl_file to ggate;
grant restricted session to ggate;
@$GGATE_HOME/marker_setup.sql;
SCHEMA:GGATE
@$GGATE_HOME/ddl_setup.sql;
這裡要看清楚,選擇輸入,否則會有問題!
@$GGATE_HOME/role_setup.sql;
授予角色權力:
grant GGS_GGSUSER_ROLE to ggate;
@$GGATE_HOME/ddl_enable.sql;
1.8建立源端使用者(用於同步的使用者)
create user sender identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;
grant dba,connect,resource to ggate;
grant select on v_$session to ggate;