【轉】GoldenGate資料庫複製實施案例

leonarding發表於2012-07-18
引言:最近在論壇裡經常會看到有朋友諮詢Oracle GG 實施案例的帖子,誠然 GG 目前在各大論壇裡的資料都不是很多 很全,尤其是真實實施案例就更鳳毛麟角了,鑑於此我今天就為大家轉一份朋友做過的GG實施給大家分享,本次分享的是“相同資料庫之間的複製”,話不多說,趕緊上乾貨【轉】GoldenGate資料庫複製實施案例
 

實驗環境:oracle10g+redhat4+goldengate

一、安裝redhat4,安裝步驟略

二、安裝oracle10g 安裝步驟略

三、安裝goldengate,注意要選對版本

1
、源端安裝配置

1.1
安裝goldengate

linux: mkdir /u01/oracle/ggate
cd /u01/oracle/ggate

通過ftp,將goldengatezip軟體上傳到/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;

2
、源端複製佇列配置
2.1
配置manager
cd /u01/oracle/ggate
./ggsci (
進入goldengate命令列)
edit params mgr
輸入:PORT 7809
vi操作基本相同


2.2
配置源端複製佇列
同樣是在goldengate命令列裡做
add extract ext1, tranlog, begin now
add exttrail /u01/oracle/ggate/dirdat/lt, extract ext1
edit params ext1
輸入如下內容:
extract ext1
userid ggate, password ggate
rmthost
目標機, mgrport 7809
rmttrail /u01/oracle/ggate/dirdat/lt
ddl include mapped objname sender.*;
table sender.*;
到這裡,可以用info all檢視一下,

關閉程式:
stop mgr
stop ext1

到這裡源端基本上配置完畢
3
、目標端安裝配置

3.1
安裝goldengate

linux: mkdir /u01/oracle/ggate
cd /u01/oracle/ggate

通過ftp,將goldengatezip軟體上傳到/u01/oracle/ggate

unzip
解壓,將生成一個tar檔案

tar -xvf *.tar

3.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


3.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


3.4

建立目標端使用者
create user ggate identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;
create user receiver 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;

grant connect,resource,dba to receiver;

grant select on v_$session to receiver;

3.5
配置replicat
./ggsci

edit params ./GLOBALS

輸入:
GGSCHEMA ggate
CHECKPOINTTABLE ggate.checkpoint

edit params mgr

輸入:PORT 7809

goldengate命令列登入資料庫

dblogin userid ggate,password ggate

add checkpointtable ggate.checkpoint (
增加檢測點)

add replicat rep1, exttrail /u01/oracle/ggate/dirdat/lt, checkpointtable ggate.checkpoint(
增加同不佇列)

edit params rep1

新增如下內容:
replicat rep1
ASSUMETARGETDEFS
userid ggate, password ggate
discardfile /u01/oracle/ggate/dirdat/rep1_discard.txt, append, megabytes 10
DDL include all
map sender.*, target receiver.*;

到這裡上標端配置基本結束

四、額外增加的一個步驟,我是這樣做

分別在源端、目標端增加

mkdir -p /u01/oracle/ggate/dirdat/lt

五、在goldengate命令列開啟

源端:start manager
start ext1

目標:start manager
start rep1

六、測試:

源端:create table sender.test(empid number(4),names varchar2(10),oldage number(3));

目標:select * from receiver.test;

七、其它的一些錯誤查詢等,去搜集相關資料
Leonarding
2012.7.23
天津&summer
分享技術~收穫快樂

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26686207/viewspace-735889/,如需轉載,請註明出處,否則將追究法律責任。

相關文章