Oracle GoldenGate安裝配置

來源:互聯網
上載者:User

Oracle GoldenGate軟體基於資料庫日誌結構變化,通過解析源端線上日誌或歸檔日誌獲得資料增量,再將這些變化應用到目標資料庫,從而實現源庫和目標庫的資料同步。下面通過一個簡單的樣本,詳細介紹利用GoldenGate實現Oracle資料庫之間的同步。基本架構如所示:

 

1. 安裝

1.1 下載介質

GoldenGate的安裝介質可以從Oracle的官網上下載。

http://www.oracle.com/technetwork/middleware/goldengate/overview/index.html

1.2 配置GoldenGate使用者

下載完成後將其拷貝到源和目標的相應位置解壓完成後,即可以開始進行配置。

# useradd -g oinstall -G dba ggate
# su – ggate
$ mkdir /u01/app/oracle/ggate
$ cd /u01/app/oracle/ggate
$ tar ……

注意,如果使用Oracle 11g的資料庫,需要建立一個link檔案。

$ ln -s /u01/app/oracle/product/11.2.0/db_1/lib/libnnz11.so -
/u01/app/oracle/product/11.2.0/db_1/lib/libnnz10.so

$ vi ~/.bash_profile

添加如下的內容:

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/app/oracle/ggate
export GGATE=/u01/app/oracle/ggate

1.3 建立目錄

使用ggsci工具,建立必要的目錄。

$ cd /u01/app/oracle/ggate
$ ./ggsci

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.

GGSCI (gridcontrol) 1> create subdirs

至此,GoldenGate基本的安裝完成。

Note. 此部分需要在源端和目標端完成。

2. 來源資料庫配置

GoldenGate主要通過抓取源端資料庫重做日誌進行分析,將擷取的資料應用到目標端,實現資料同步。因此,為了讓GoldenGate能夠正常工作,來源資料庫需要進行一定配置。

2.1 設定源庫為歸檔模式

SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;

2.2 開啟minimal supplemental logging

SQL> alter database add supplemental log data;

SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;

SUPPLEME
——–
YES

2.3 關閉資料庫的recyblebin

SQL> alter system set recyclebin=off scope=spfile;

如果資料庫是10g,需要關閉recyclebin並重啟;或者手工purge recyclebin。

2.4 配置複製的DDL支援

SQL> create user ggate identified by ggate default tablespace users temporary tablespace temp;
SQL> grant connect,resource,unlimited tablespace to ggate;
SQL> grant execute on utl_file to ggate;

SQL> @$GGATE/marker_setup.sql;
SQL> @$GGATE/ddl_setup.sql;
SQL> @$GGATE/role_setup.sql;
SQL> grant GGS_GGSUSER_ROLE to ggate;
SQL> @$GGATE/ddl_enable.sql;

2.5 建立源端和目標端的測試使用者

source

SQL> create user sender identified by oracle default tablespace users temporary tablespace temp;
SQL> grant connect,resource,unlimited tablespace to sender;

destination

SQL> create user receiver identified by oracle default tablespace users temporary tablespace temp;
SQL> grant connect,resource,unlimited tablespace to receiver;

3. 配置manager

在源端和目標端分別執行下面的步驟。

3.1 建立manager

[ggate@gridcontrol gg]$ ./ggsci

GGSCI (gridcontrol) 1> info all

Program     Status      Group       Lag           Time Since Chkpt
MANAGER     STOPPED

GGSCI (gridcontrol) 2> edit params mgr

PORT 7809

ggate (gridcontrol) 3> start manager

Manager started.

4. 配置源端複製隊列

GGSCI (gridcontrol) 1> add extract ext1, tranlog, begin now

EXTRACT added.

GGSCI (gridcontrol) 2> add exttrail /u01/app/oracle/ggate/dirdat/lt, extract ext1

EXTTRAIL added.

GGSCI (gridcontrol) 3> edit params ext1

extract ext1
userid ggate@source, password oracle
rmthost centos4, mgrport 7809
rmttrail /u01/app/oracle/ggate/dirdat/lt
ddl include mapped objname sender.*;
table sender.*;

GGSCI (gridcontrol) 6> info all

Program     Status      Group       Lag           Time Since Chkpt

MANAGER     STOPPED
EXTRACT     STOPPED     EXT1        00:00:00      00:10:55

5. 配置目標端同步隊列

5.1 在目標端添加checkpoint表

[oracle@centos4 ggate]$ ./ggsci

GGSCI (centos4) 1> edit params ./GLOBAL   –添加下列內容

GGSCHEMA ggate
CHECKPOINTTABLE ggate.checkpoint
 
GGSCI (centos4) 2> dblogin userid ggate@target
Password:

Successfully logged into database.
 
GGSCI (centos4) 3> add checkpointtable ggate.checkpoint
 
Successfully created checkpoint table GGATE.CHECKPOINT.

5.2 建立同步隊列
 

GGSCI (centos4) 4> add replicat rep1, exttrail /u01/app/oracle/ggate/dirdat/lt, checkpointtable ggate.checkpoint
 
REPLICAT added.

GGSCI (centos4) 5> edit params rep1

replicat rep1
ASSUMETARGETDEFS
userid ggate@target, password ggate
discardfile /u01/app/oracle/ggate/dirdat/rep1_discard.txt, append, megabytes 10
DDL
map sender.*, target receiver.*;

6. 開啟同步

GGSCI (gridcontrol) 14> start extract ext1

GGSCI (gridcontrol) 15> info all
 
Program     Status      Group       Lag           Time Since Chkpt
 
MANAGER     RUNNING
EXTRACT     RUNNING     EXT1        00:00:00      00:00:05

GGSCI (centos4) 7> start replicat rep1

GGSCI (centos4) 8> info all
 
Program     Status      Group       Lag           Time Since Chkpt
 
MANAGER     RUNNING
REPLICAT    RUNNING     REP1        00:00:00      00:00:00

7. 驗證結果

源端:

SQL> create table sender.test_tab_1 (id number,rnd_str varchar2(12));
SQL> insert into sender.test_tab_1 values (1,’test_1′);
SQL> commit;

目標端:

SQL> select * from receiver.test_tab_1;
 
ID RND_STR
———- ————
1 test_1

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.