如何在11gR2 RAC上配置GoldenGate

來源:互聯網
上載者:User

Oracle 11gR2 RAC和GoldenGate都是Oracle比較熱門的產品,經過簡單的學習和閱讀文檔,配置單節點的GoldenGate進行資料的複製相信不是什麼太有難度的事情,但是對於利用GoldenGate進行RAC系統到RAC系統的複製,還是有些配置的技巧和原則設定的,前陣子就遇到一個這樣一個問題:假設源和目標分別是兩節點的RAC系統,如何保證目標部分節點失效的時候replicate會自動切換? 其實如果瞭解GG的工作機制和RAC的資源管理,問題的解決就十分清晰了。

今天就從系統的介紹下11gR2 RAC上OGG (Oracle GoldenGate的簡稱,下同)的完整配置步驟,並簡單談談如何解決上面這個情境的問題。

第一階段:下載OGG(可以參考之前的單節點的複製例子,不再贅述)
OGG的

第二階段:OGG的安裝

1)登入源端的RAC系統中的任一個節點,並在ACFS上建立一個供OGG使用的共用目錄,比如叫/cloudfs/goldengate

2)解壓OGG的安裝包到/cloudfs/goldengate目錄

3) 設定好OGG工作的環境變數,比如

export LIBRARY_PATH=/cloudfs/goldengate:$ORACLE_HOME/lib:$LD_LIBRARY_PATH

4)啟動ggsci並建立目錄,然後進行必要的設定,啟動manager

$ ggsci
 
GGSCI > create subdirs
 
(optional, support for DDL/Sequence)
Create and edit the parameter file for GLOBALS:
 
GGSCI > EDIT PARAMS ./GLOBALS
Add this line to GLOBALS parameter file:
 
GGSCHEMA ggs
 
NOTE: 'ggs' is the example OGG user and will be used in the rest of this document.
 
GGSCI > EDIT PARAMS mgr
 
Add the following lines to Manager parameter file:
 
PORT 7809
AUTOSTART ER *
AUTORESTART ER *
 
GGSCI > START mgr

5)在目標端重複上面的步驟1-4,注意目錄名的使用,我們在目標端使用/mycloudfs/goldengate以示區分。

第三階段:源和目標RAC資料庫準備步驟


1) Create OGG user 'ggs' on both the source and target database, connect to database using SQL*Plus as SYSDBA:
 
SQL> CREATE USER ggs IDENTIFIED BY ggs;
SQL> GRANT CONNECT,RESOURCE,DBA TO ggs;
 
2)(optional, add Oracle sequence replication support) On both source and target database, go to OGG directory and run this SQL, enter OGG user 'ggs' as prompted:
SQL> @sequence.sql
 
3) Enable supplemental logging on source ODA database:
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (UNIQUE) COLUMNS;
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (FOREIGN KEY) COLUMNS;
SQL> ALTER SYSTEM SWITCH LOGFILE;
 
(Optional) Add Oracle DDL replication support
4) On the source system, go to OGG directory, connect to database using SQL*Plus as SYSDBA.
 
SQL> GRANT EXECUTE ON utl_file TO ggs;
 
5 On the source system, run the following script, provide OGG user 'ggs' as prompted.
 
SQL> @marker_setup.sql
SQL> @ddl_setup.sql
 
NOTE: enter 'INITIALSETUP' when prompted for the mode of installation.
 
SQL> @role_setup.sql
SQL> @ddl_enable.sql
SQL> @ddl_pin ggs
 
NOTE: 'ggs' here is the OGG user.

第四階段:配置源端的extract group


1) Issue the following command to log on to the database.
GGSCI > DBLOGIN USERID ggs, PASSWORD ggs
 
2) Create a primary Extract group 'myext':
 
GGSCI > ADD EXTRACT myext, TRANLOG, BEGIN NOW, THREADS 2
NOTE: THREADS value is the number of your RAC instances.
 
3) Create a local trail. The primary Extract writes to this trail, and the data-pump Extract reads it.
 
GGSCI > ADD EXTTRAIL /cloudfs/goldengate/dirdat/et, EXTRACT myext
NOTE: 'et' is the example trail identifier for Extract 'myext'.
 
4) Create and edit the parameter file for Extract 'myext':
 
GGSCI > EDIT PARAMS myext
Add following lines to this parameter file:
 
EXTRACT myext
SETENV (ORACLE_HOME = "/u01/app/oracle/product/11.2.0/dbhome_1")
USERID ggs@ggdb, PASSWORD ggs
TRANLOGOPTIONS DBLOGREADER
THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 20000
EXTTRAIL /cloudfs/goldengate/dirdat/et
DYNAMICRESOLUTION
DDL INCLUDE ALL
TABLE hr.*;
 
NOTE 1: make sure the SQL*Net connection string 'ggdb' works.
NOTE 2: 'hr' is the example schema which will be synchronized to the target system.

第五階段:在源端配置data pump extract group


1)Create a data pump group 'mypump':
GGSCI > ADD EXTRACT mypump, EXTTRAILSOURCE /cloudfs/goldengate/dirdat/et, BEGIN now
 
2) Specify a remote trail that will be created on the target system.
 
GGSCI > ADD RMTTRAIL /mycloudfs/goldengate/dirdat/rt, EXTRACT mypump
NOTE: 'rt' is the example trail identifier for Extract 'mypump', and use the target OGG directory '/mycloudfs/goldengate' here.
 
3) Create and edit the parameter file for Extract 'mypump':
GGSCI > EDIT PARAMS mypump
 
Add following lines to this parameter file:
 
EXTRACT mypump
RMTHOST rac12box-scan, MGRPORT 7809
RMTTRAIL /mycloudfs/goldengate/dirdat/rt
PASSTHRU
TABLE hr.*;
 
NOTE: RMTHOST is the target host. If you also prefer to set up HA on the target system, specify the VIP for your target system as RMTHOST,
otherwise just use the IP address/hostname of your target system.
 
4) Start Extract 'myext' and 'mypump':
 
GGSCI > START myext
GGSCI > START mypump
 
5) Check the status of OGG processes:
GGSCI > info all

第六階段:在目標端配置Replicat group


1) Create a Replicat group 'rept', which reads trails from Extract 'mypump':
 
GGSCI > ADD REPLICAT rept, EXTTRAIL /mycloudfs/goldengate/dirdat/rt, nodbcheckpoint
 
2) Create and edit the parameter file for Replicat 'rept':
 
GGSCI > EDIT PARAMS rept
Add following lines to this parameter file, assume the same ORACLE_HOME and target database 'ggdb' as in source ODA environment:
 
REPLICAT rept
SETENV (ORACLE_HOME = "/u01/app/oracle/product/11.2.0/dbhome_1")
USERID ggs@ggdb,PASSWORD ggs
ASSUMETARGETDEFS
HANDLECOLLISIONS
REPERROR (DEFAULT, DISCARD)
DDLERROR DEFAULT DISCARD
DDLOPTIONS REPORT
DISCARDFILE /mycloudfs/goldengate/repsz.dsc,append,megabytes 100
MAP hr.*, TARGET hr.*;
 
NOTE: make sure the SQL*Net connection string 'ggdb' works.
 
3) Start Replicat 'rept':
 
GGSCI > START rept
 
4) Check the status of OGG processes:
GGSCI > info all

第七階段:驗證Goldengate功能

1) Log on to source database as user 'hr', do some simple DDL and DML operations. 2) Check the data change has been captured by Extract on source system:   GGSCI > STATS myext GGSCI > STATS mypump   3)Log on to target system as oracle user, check the status of Replicat 'rept':   GGSCI > STATS rept   4) Compare the output and make sure data change is synchronized. 5)(optional, for further HA setup) Stop OGG on source system:   GGSCI > STOP myext GGSCI > STOP mypump GGSCI > STOP mgr   6)(optional, for further HA setup) Stop OGG on target system:   GGSCI > STOP rept GGSCI > STOP mgr 

關於HA的設定,請繼續關注下篇。

  • 1
  • 2
  • 下一頁
【內容導航】
第1頁:上 第2頁:下

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.