轉發一份GoldenGate 配置文檔

轉發一份GoldenGate 配置文檔,裏面有參數說明,值得看


1       GoldenGate簡要說明

GoldenGate現在是業內成熟的數據容災與複製產品,經過多年的發展與完善,現在已經成爲業內事實上的標準之一。

GoldenGate軟件是一種基於日誌的結構化數據複製軟件,它通過解析源數據庫在線日誌或歸檔日誌獲得數據的增刪改變化,再將這些變化應用到目標數據庫,實現源數據庫與目標數據庫同步。

1.1  Golden Gate技術結構

GoldenGate軟件的技術結構如圖1.1所示:

圖1.1GoldenGate技術架構

從圖中可以看到:GoldenGate主要包含Manager進程、Extract進程、Pump進程、Replicat進程,下面對其一一說明:

Manager進程是GoldenGate的控制進程,它主要作用有以下幾個方面:啓動、監控、重啓GoldenGate的其他進程,報告錯誤及時間,分配數據存儲空間,發佈閥值報告等。

Extract進程運行在數據庫源端,負責從源端數據表或日誌中捕獲數據。Extract進程利用其內在的checkpoint機制,週期性地檢查並記錄其讀寫的位置,通常是寫入到本地的trail文件。這種機制是爲了保證如果Extract進程終止或者操作系統宕機,我們重啓Extract進程後,GoldenGate能夠恢復到以前的狀態,從上一個斷點處繼續往下運行,而不會有任何數據損失。

Pump進程運行在數據庫源端,其作用非常簡單。如果源端使用了本地trail文件,那麼Pump進程就會把Trail文件以數據塊的形式通過TCP/IP協議發送到目標端,我們下面的配置都是這種方式。Pump進程本質是Extract進程的一種特殊形式,如果不使用Trail文件,那麼Extract進程在抽取完數據後,直接投遞到目標端。

與Pump進程相對應的叫Server Collector進程,這個進程不需要引起我們關注,因爲在實際操作過程中無需對其進行任何配置,它運行在目標端,任務就是把Extract/Pump進程投遞過來的數據塊重新組裝成Trail文件。

Replicat進程運行在目標端,是數據投遞的最後一站,負責讀取目標端Trail文件中的內容,並將解析其解析爲DML或DDL語句,然後應用到目標數據庫中。

1.2  Golden Gate拓撲結構

GoldenGate提供了靈活的應用方案,基於其先進、靈活的技術架構可以根據用戶需求組成各種拓撲結構,如圖1.2所示:

圖1.2GoldenGate應用方案示意圖

根據實際需求情況,我們需要進行的是一對一複製,且只是複製部分表數據,所以這裏僅探討一對一複製的安裝配置,而且對於DDL複製的支持這裏也不做研究。

2       單機à單機複製配置

2.1  環境簡介

性質

IP

系統

Oracle版本

源端

10.122.0.110

AIX 5.3

10.2.0.1

目標端

10.122.0.113

WINDOWS 2003

10.2.0.1

 

2.2  源端安裝GoldenGate

創建GoldenGate安裝目錄並解壓安裝文件

unzip ogg112101_ggs_AIX_ppc_ora10.2_64bit.zip

tar –xf ggs_AIX_ppc_ora10.2_64bit.tar

注意:使用的安裝包一定要與平臺一致

 

設置環境變量

在用戶參數文件中添加以下內容:

export GGATE_HOME=/u01/oracle/oracle/ogg

export LIBPATH=$GGATE_HOME:$ORACLE_HOME/lib

注意:添加後需使參數文件生效

HPLinux平臺下用LD_LIBRARY_PATH替換LIBPATH

 

安裝GoldenGate

進入OGG控制檯創建OGG工作目錄

然後在安裝目錄下執行 ./ggsci  進入OGG控制檯

執行命令 createsubdirs創建工作目錄,顯示如下:

GGSCI (NDSCDB1)1> create subdirs

Creatingsubdirectories under current directory /u01/oracle/oracle/ogg

 

Parameterfiles              /u01/oracle/oracle/ogg/dirprm: already exists

Reportfiles                 /u01/oracle/oracle/ogg/dirrpt: created

Checkpointfiles             /u01/oracle/oracle/ogg/dirchk: created

Process statusfiles            /u01/oracle/oracle/ogg/dirpcs: created

SQL scriptfiles               /u01/oracle/oracle/ogg/dirsql:created

Databasedefinitions files       /u01/oracle/oracle/ogg/dirdef: created

Extract datafiles              /u01/oracle/oracle/ogg/dirdat: created

Temporaryfiles              /u01/oracle/oracle/ogg/dirtmp: created

Stdout files                  /u01/oracle/oracle/ogg/dirout: created

2.3 目標端安裝GoldenGate

建立OGG安裝目錄,然後將壓縮包解壓到目錄中,進入cmd控制檯,創建工作目錄,

操作步驟顯示如下:

 

2.4  配置源端數據庫

數據庫模式配置

源端數據庫必須開啓歸檔模式

Alter databasearchivelog;

開啓最小附加日誌

Alter databaseadd supplemental log data;

使用SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

可查看是否開啓了最小附加日誌;

 

源端數據庫創建GoldenGate數據庫用戶並授權:(我們這裏以ogg爲例,使用其他亦可)

create user ogg identified by oracle defaulttablespace DATA_OL;

grant connect,resource,unlimited tablespace to ogg;

grant executeon utl_file to ogg;

grant select any dictionary,select any table to ogg;

grant alter any table to ogg;

grant flashback any table to ogg;

grant execute onDBMS_FLASHBACK to ogg;

添加表級transdata

GGSCI (NDSCDB1) 2>dblogin userid ogg,password oracle

Successfully logged intodatabase.

GGSCI(NDSCDB1) 3> add trandata olive.ol$_objects

Logging of supplemental redo dataenabled for table OLIVE.OL$_OBJECTS.

 

2.5  配置源端進程組

配置管理進程mgr:

GGSCI(NDSCDB1) 1> edit param mgr

(粘貼下面這段配置)

PORT 7839

DYNAMICPORTLIST 7840-7939

--AUTOSTART ER *

AUTORESTART EXTRACT *,RETRIES5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS 1

LAGINFOMINUTES 30

LAGCRITICALMINUTES 45

MANAGER進程參數配置說明:

PORT:指定服務監聽端口;這裏以7839爲例,默認端口爲7809

DYNAMICPORTLIST:動態端口:可以制定最大256個可用端口的動態列表,當指定的端口不可用時,管理進程將會從列表中選擇一個可用的端口,源端和目標段的CollectorReplicatGGSCI進程通信也會使用這些端口;

COMMENT:註釋行,也可以用--來代替;

AUTOSTART:指定在管理進程啓動時自動啓動哪些進程;

AUTORESTART:自動重啓參數設置:本處設置表示每3分鐘嘗試重新啓動所有EXTRACT進程,共嘗試5次;

PURGEOLDEXTRACTS:定期清理trail文件設置:本處設置表示對於超過3天的trail文件進行刪除。

LAGREPORT、LAGINFO、LAGCRITICAL:

定義數據延遲的預警機制:本處設置表示MGR進程每隔1小時檢查EXTRACT的延遲情況,如果超過了30分鐘就把延遲作爲信息記錄到錯誤日誌中,如果延遲超過了45分鐘,則把它作爲警告寫到錯誤日誌中。

 

啓動管理進程:

GGSCI(NDSCDB1) 2> start mgr

Managerstarted.

查看進程狀態可發現 MANAGER狀態爲 RUNNING:

GGSCI(NDSCDB1) 3> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING

配置抽取進程:

GGSCI(NDSCDB1) 12> add extract extnd,tranlog,begin now

EXTRACTadded.

GGSCI(NDSCDB1) 14> add exttrail ./dirdat/nd,extract extnd,megabytes 100

EXTTRAILadded.

Megabytes:指定隊列大小,本處設置表示100M

GGSCI(NDSCDB1) 15> edit params extnd

(粘貼下面這段配置)

EXTRACTextnd

setenv(NLS_LANG = "AMERICAN_AMERICA.UTF8")

SETENV(ORACLE_HOME = "/u01/oracle/oracle/product/10.2.0/db_1")

SETENV(ORACLE_SID = "ndtest")

USERIDogg, PASSWORD oracle

--GETTRUNCATES

REPORTCOUNTEVERY 1 MINUTES, RATE

DISCARDFILE./dirrpt/extnd.dsc,APPEND,MEGABYTES 1024

--THREADOPTIONS  MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS60000

DBOPTIONS  ALLOWUNUSEDCOLUMN

WARNLONGTRANS2h,CHECKINTERVAL 3m

EXTTRAIL./dirdat/nd

--TRANLOGOPTIONSEXCLUDEUSER USERNAME

FETCHOPTIONSNOUSESNAPSHOT

TRANLOGOPTIONS  CONVERTUCS2CLOBS

TABLEolive.ol$_objects

 

添加傳輸進程,配置參數

GGSCI(NDSCDB1) 2> add extract dpend,exttrailsource ./dirdat/nd

EXTRACTadded.

GGSCI(NDSCDB1) 3> add rmttrail F:\ogg\dirdat\nd, EXTRACT DPEND

RMTTRAILadded.

 

GGSCI(NDSCDB1) 4> edit params dpend

(粘貼下面這段配置)

EXTRACTdpend

SETENV(NLS_LANG = "AMERICAN_AMERICA.UTF8")

USERIDogg, PASSWORD oracle

PASSTHRU

RMTHOST10.122.0.113, MGRPORT 7839, compress

RMTTRAILF:\ogg\dirdat\nd

TABLEolive.ol$_objects;

 

抽取進程和傳輸進程其實都是EXTRACT進程,也可以配置在一個進程完成這兩個功能,但是當網絡傳輸有問題時,這樣抽取也就不能繼續運行了,所以推薦分開配置爲兩個進程;

EXTRACT進程參數配置說明:

SETENV:配置系統環境變量

USERID/ PASSWORD:指定OGG連接數據庫的用戶名和密碼,這裏使用3.4部分中創建的數據庫用戶OGG;

COMMENT:註釋行,也可以用--來代替;

TABLE:定義需複製的表,後面需以;結尾

TABLEEXCLUDE:定義需要排除的表,如果在TABLE參數中使用了通配符,可以使用該參數指定排除掉得表。

GETUPDATEAFTERS|IGNOREUPDATEAFTERS:

是否在隊列中寫入後影像,缺省複製

GETUPDATEBEFORES| IGNOREUPDATEBEFORES:

是否在隊列中寫入前影像,缺省不復制

GETUPDATES|IGNOREUPDATES:

是否複製UPDATE操作,缺省複製

GETDELETES|IGNOREDELETES:

是否複製DELETE操作,缺省複製

GETINSERTS|IGNOREINSERTS:

是否複製INSERT操作,缺省複製

GETTRUNCATES|IGNORETRUNDATES:

是否複製TRUNCATE操作,缺省不復制;

RMTHOST:指定目標系統及其GoldengateManager進程的端口號,還用於定義是否使用壓縮進行傳輸,本例中的compress爲壓縮傳輸;

RMTTRAIL:指定寫入到目標斷的哪個隊列;

EXTTRAIL:指定寫入到本地的哪個隊列;

SQLEXEC:extract進程運行時首先運行一個SQL語句;

PASSTHRU:禁止extract進程與數據庫交互,適用於Data Pump傳輸進程;

REPORT:定義自動定時報告;

STATOPTIONS:定義每次使用stat時統計數字是否需要重置;

REPORTCOUNT:報告已經處理的記錄條數統計數字;

TLTRACE:打開對於數據庫日誌的跟蹤日誌;

DISCARDFILE:定義discardfile文件位置,如果處理中油記錄出錯會寫入到此文件中;

DBOPTIONS:指定對於某種特定數據庫所需要的特殊參數;

TRANLOGOPTIONS:指定在解析數據庫日誌時所需要的特殊參數,例如:對於裸設備,可能需要加入以下參數 rawdeviceoggset 0

WARNLONGTRANS:指定對於超過一定時間的長交易可以在gsserr.log裏面寫入警告信息,本處配置爲每隔3分鐘檢查一次場交易,對於超過2小時的進行警告;

 

2.6  配置目標數據庫

目標庫創建GoldenGate數據庫用戶並授權:

createuser ogg identified by oracle default tablespace DATA_OL;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

grantinsert any table to ogg;

grantdelete any table to ogg;

grantupdate any table to ogg;

 

添加checkpoint表

然後在參數文件中輸入

GGSCHEMAogg

CHECKPOINTTABLEogg.checkpoint

 

2.7 配置目標端進程組

配置管理進程

 

配置複製進程

REPLICAT進程參數配置說明:

ASSUMETARGETDEFS:假定兩端數據結構一致使用此參數;

SOURCEDEFS:假定兩端數據結構不一致,使用此參數指定源端的數據結構定義文件,該文件需要由GlodenGate工具產生。

MAP:用於指定源端與目標端表的映射關係;

MAPEXCLUDE:用於使用在MAP中使用*匹配時排除掉指定的表;

REPERROR:定義出錯以後進程的響應,一般可以定義爲兩種:

ABEND,即一旦出現錯誤即停止複製,此爲缺省配置;

DISCARD,出現錯誤後繼續複製,只是把錯誤的數據放到discard文件中。

DISCARDFILE:定義discardfile文件位置,如果處理中油記錄出錯會寫入到此文件中;

SQLEXEC:在進程運行時首先運行一個SQL語句;

GROUPTRANSOPS:將小交易合併成一個大的交易進行提交,減少提交次數,降低系統IO消耗。

MAXTRANSOPS:將大交易拆分,每XX條記錄提交一次。

 

2.8 啓動進程進行數據同步

啓動源端進程組

啓動抽取進程和傳輸進程:

start extnd

start dpend

啓動後使用info all查看進程狀態,正常status應該RUNNING,顯示如下:

GGSCI (NDSCDB1)11> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING                                     

EXTRACT     RUNNING    DPEND       00:00:00      00:15:32

EXTRACT     RUNNING    EXTND       00:00:00      00:00:04

 

啓動目標端進程

start repnd

顯示如下:

到此OGG的安裝配置就完成了,可以進行數據同步測試了。

 

3       RACà單機複製配置

3.1  環境簡介

性質

IP

系統

ORACLE版本

源端

10.123.112.201/10.123.112.202

linux rhel5 64位

10.2.0.1

目標端

10.123.112.235

LINUX rhel5 32位

10.2.0.1

 

3.2 源端安裝OCFS2集羣文件系統

RAC環境中爲了實現高可用性,需將OGG安裝在集羣文件系統中,這樣OGG可以訪問RAC中的所有節點,我們這裏測試採用OCFS2文件系統。

從http://oss.oracle.com下載與LINUX內核相符的OCFS2 RPM包

LINUX下執行uname –r查看系統內核版本 eg:

[oracle@node2ocfs]$ uname -r

2.6.18-92.el5

 

使用ROOT用戶安裝OCFS2的RPM包

[root@node1ocfs]# rpm -ivh ocfs2-tools-1.2.7-1.el5.x86_64.rpm \

ocfs2console-1.2.7-1.el5.x86_64.rpm\

ocfs2-2.6.18-92.el5-1.2.9-1.el5.x86_64.rpm

進入OCFS2控制檯界面

[root@node1 ~]#ocfs2console

在出現的窗體中選擇[Clucster]-[ConfigureNodes]在"NodeConfiguration"對話框中,輸入2個專用互連的節點名、IP 地址、端口號後,選擇 [Clucster]-[PropagateCluster Configuration] ,提示"Finished"。

配置後的信息顯示如下:

在集羣中的所有節點上以 root 用戶帳戶的身份運行以下命令
    export PATH=$PATH:/sbin:/usr/sbin
    /etc/init.d/o2cb enable

創建ocfs2文件系統,其中-N選項用於指明最多允許多少個節點同時使用此文件系統:

# mkfs -t ocfs2-N 2 /dev/sdh1

掛載分區:

# mount /dev/sdh1/ggate

 

配置啓動自動載入(所有節點):
    export PATH=$PATH:/sbin:/usr/sbin
    chkconfig --add o2cb
    /etc/init.d/o2cb configure
 在/etc/rc.local增加入下內容:       

chown -Roracle:dba /ggate
chmod -R 775 /ggate

 

3.3 源端安裝GoldenGate

在GoldenGate安裝目錄(OCFS2目錄/ggate)解壓安裝文件

unzipogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip

tar–xvf fbo_ggs_Linux_x64_ora10g_64bit.tar

 

設置環境變量

在用戶參數文件中添加以下內容:

exportGGATE_HOME=/ggate

exportLD_LIBRARY_PATH=$GGATE_HOME:$ORACLE_HOME/lib

注意:添加後需使參數文件生效

 

安裝GoldenGate

進入OGG控制檯創建OGG工作目錄

然後在安裝目錄下執行 ./ggsci  進入OGG控制檯

執行命令 createsubdirs創建工作目錄,顯示如下:

GGSCI(node1) 1> create subdirs

 

Creatingsubdirectories under current directory /ggate

 

Parameterfiles                /ggate/dirprm:already exists

Reportfiles                   /ggate/dirrpt:created

Checkpointfiles               /ggate/dirchk:created

Processstatus files             /ggate/dirpcs: created

SQLscript files               /ggate/dirsql:created

Databasedefinitions files       /ggate/dirdef: created

Extractdata files              /ggate/dirdat: created

Temporaryfiles               /ggate/dirtmp:created

Stdoutfiles                   /ggate/dirout:created

 

3.4 目標端安裝GoldenGate

環境相同,安裝方法與4.3一致,僅僅是安裝位置不同,安裝過程略,注意安裝包與平臺一致。

3.5 配置源端數據庫

數據庫模式配置

源端數據庫必須開啓歸檔模式

Alterdatabase archivelog;

開啓最小附加日誌

Alterdatabase add supplemental log data;

使用SELECTSUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

可查看是否開啓了最小附加日誌;

 

源端數據庫創建GoldenGate數據庫用戶並授權:(我們這裏以ogg爲例,使用其他亦可)

createuser ogg identified by oracle default tablespace DATA_OL;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

添加表級transdata

GGSCI(node1) 1> dblogin userid ogg,password oracle

Successfullylogged into database.

GGSCI(node1) 2> add trandata SCOTT.DEPT

Loggingof supplemental redo data enabled for table SCOTT.DEPT.

GGSCI(node1) 3> add trandata SCOTT.EMP

Loggingof supplemental redo data enabled for table SCOTT.EMP.

3.6  配置源端進程組

配置管理進程mgr:

GGSCI(node1) 1> edit param mgr

(粘貼下面這段配置)

PORT7839

DYNAMICPORTLIST7840-7939

--AUTOSTARTER *

AUTORESTARTEXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS1

LAGINFOMINUTES30

LAGCRITICALMINUTES45

參數說明均與單點配置相同,參考3.5部分

啓動管理進程:

GGSCI(node1) 2> start mgr

Managerstarted.

GGSCI(node1) 3> info all

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

 

配置抽取進程:

GGSCI(node1) 6> add extract extnd,tranlog,begin now,threads 2

EXTRACTadded.

GGSCI(node1) 7> add exttrail ./dirdat/nd,extract extnd,megabytes 100

EXTTRAILadded.

GGSCI(node1) 8> edit params extnd

(粘貼下面這段配置)

EXTRACTextnd

SETENV(NLS_LANG = "AMERICAN_AMERICA.UTF8")

SETENV(ORACLE_HOME = "/u01/app/oracle/product/10.2.0/db_1")

USERID ogg@RAC, PASSWORDoracle

--GETTRUNCATES

REPORTCOUNTEVERY 1 MINUTES, RATE

DISCARDFILE./dirrpt/extnd.dsc,APPEND,MEGABYTES 1024

--THREADOPTIONS  MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS60000

DBOPTIONS  ALLOWUNUSEDCOLUMN

WARNLONGTRANS2h,CHECKINTERVAL 3m

EXTTRAIL./dirdat/nd

--TRANLOGOPTIONSEXCLUDEUSER USERNAME

FETCHOPTIONSNOUSESNAPSHOT

TRANLOGOPTIONS  CONVERTUCS2CLOBS

TABLEscott.dept;

TABLEscott.emp;

 

注意:threadsRAC節點數相同即可,RAC中不再使用ORACLE_SID設置,而使用USERID ogg@RAC,注意兩個節點均可連接數據庫。

 

添加傳輸進程,配置參數

GGSCI(node1) 2> add extract dpend,exttrailsource ./dirdat/nd

EXTRACTadded.

GGSCI(node1) 3> add rmttrail /uo1/app/ogg/dirdat/nd, EXTRACT DPEND

RMTTRAILadded.

GGSCI(node1) 4> edit params dpend

(粘貼下面這段配置)

EXTRACTdpend

SETENV(NLS_LANG = AMERICAN_AMERICA.UTF8)

USERID ogg@RAC, PASSWORDoracle

PASSTHRU

RMTHOST10.123.112.235, MGRPORT 7839, compress

RMTTRAIL/uo1/app/ogg/dirdat/nd

TABLEscott.dept;

TABLEscott.emp;

 

3.7 配置目標數據庫

目標庫創建GoldenGate數據庫用戶並授權:

createuser ogg identified by oracle default tablespace USERS;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

grantinsert any table to ogg;

grantdelete any table to ogg;

grantupdate any table to ogg;

 

添加checkpoint表

GGSCI(sun.linux) 2> edit params GLOBALS

 

然後在參數文件中輸入

GGSCHEMAogg

CHECKPOINTTABLEogg.checkpoint

 

GGSCI(sun.linux) 4> dblogin userid ogg,password oracle

Successfullylogged into database.

 

GGSCI(sun.linux) 5> add checkpointtable ogg.checkpoint

 

Successfullycreated checkpoint table ogg.checkpoint.

3.8 配置目標端進程組

配置MGR參數

GGSCI(sun.linux) 6> edit params mgr

(粘貼下面這段配置)

PORT7839

DYNAMICPORTLIST7840-7939

--AUTOSTARTER *

AUTORESTARTEXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS1

LAGINFOMINUTES30

LAGCRITICALMINUTES45

 

配置複製隊列

GGSCI(sun.linux)8> add replicat repnd,exttrail/uo1/app/ogg/dirdat/nd,checkpointtable ogg.checkpoint

REPLICATadded.

 

GGSCI(sun.linux) 10> edit params repnd

(粘貼下面這段配置)

REPLICATrepnd

SETENV(NLS_LANG = AMERICAN_AMERICA.UTF8)

USERIDogg, PASSWORD oracle

ASSUMETARGETDEFS

REPERRORdefault,discard

discardfile./dirrpt/repnd.dsc,append,megabytes 50

mapscott.*,target pmsbi.*;

 

3.9 啓動進程進行數據同步

啓動源端進程組

啓動抽取進程和傳輸進程:

startextnd

startdpend

啓動後使用info all查看進程狀態,正常status應該RUNNING,顯示如下:

GGSCI(node1) 19> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING                                          

EXTRACT     RUNNING    DPEND       00:00:00      00:00:09   

EXTRACT     RUNNING    EXTND       00:00:00      00:00:04

 

啓動目標端進程

startrepnd

顯示如下:

GGSCI(sun.linux) 2> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING                                          

REPLICAT    RUNNING    REPND       00:00:00      00:00:03 

到此RAC到單點OGG的安裝配置就完成了,可以進行數據同步測試了。

 

4       RACà單機下的HA配置

    第4部分的RACà單機的配置僅僅完成了數據複製的功能,不包含高可用的配置,當運行GoldenGate的節點出現故障時複製功能就將終止,如何使複製功能繼續可用呢,有如下兩種方式:

4.1 節點故障的手工處理方式

因爲GoldenGate 安裝在共享目錄下,我們可以通過任一個節點連接到共享目錄,啓動GoldenGate運行界面。如果其中一個節點失敗,導致GoldenGate進程中止,可以直接手工在另外一個節點啓動進程組即可。

4.2 GoldenGate的HA配置

我們可以通過使用CRS來管理GoldenGate資源組,並且使用RAC的vip連接到GoldenGate,一旦數據庫的某一個節點宕掉,Oracleclusterware將自動切換到另一個可用節點。

添加一個應用程序VIP資源

爲GoldenGate vip資源創建一個profile

[oracle@node1ggate]$ cd $ORA_CRS_HOME/bin

[oracle@node1bin]$ pwd

/u01/app/oracle/product/10.2.0/crs_1/bin

[oracle@node1 bin]$crs_profile –create ggvip –t application \

–a /u01/app/oracle/product/10.2.0/crs_1\

-o oi=eth0,ov=192.168.73.203,on=255.255.255.0

其中:ggvip爲創建的應用程序vip的名字

把這個資源註冊到CRS:

[oracle@node1 bin]$crs_register ggvip

把vip 的所有權給root,在root用戶下執行:

[root@node1 bin]#./crs_setperm ggvip –o root

爲oracle用戶分配啓動這個資源的權限:

[root@node1 bin]#./crs_setperm ggvip –u user:oracle:r-x

通過oracle用戶啓動這個資源:

[oracle@node1bin]$ crs_start ggvip

Attempting tostart `ggvip` on member `node1`

Start of`ggvip` on member `node1` succeeded.

查看資源狀態顯示如下:

[oracle@node1bin]$ crs_stat ggvip -t

Name           Type           Target    State    Host       

------------------------------------------------------------

ggvip          application    ONLINE   ONLINE    node1

 

創建一個action程序

action程序我們這裏放到共享磁盤上,action程序最少需要可以接受三個參數:start,stop,check

start和stop:返回0成功,1 失敗;

check     :返回0表示GoldenGate在運行,1 表示不運行;

下面爲示例程序 gg_action.scr的內容:

 

#!/bin/sh

#set the OracleGoldengate installation directory

exportGGS_HOME=/ggate

#set the oraclehome to the database to ensure GoldenGate will get the

#rightenvironment settings to be able to connect to the database

exportORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

#specify delayafter start before checking for successful start

start_delay_secs=5

#Include theGoldenGate home in the library path to start GGSCI

exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:${GGS_HOME}:${LD_LIBRARY_PATH}

#check_processvalidates that a manager process is running at the PID

#thatGoldenGate specifies.

 

check_process() {

if ( [ -f"${GGS_HOME}/dirpcs/MGR.pcm" ] )

then

  pid=`cut -f8"${GGS_HOME}/dirpcs/MGR.pcm"`

  if [ ${pid} = `ps -e |grep ${pid} |grep mgr|cut -d " " -f2` ]

  then

    #manager process is running on the PID exitsuccess

    exit 0

  else

  if [ ${pid} = `ps -e |grep ${pid} |grep mgr|cut -d " " -f1` ]

  then

    #manager process is running on the PID exitsuccess

    exit 0

  else

    #manager process is not running on the PID

    exit 1

  fi

fi

else

  #manager is not running because there is noPID file

  exit 1

fi

}

 

#call_ggsci isa generic routine that executes a ggsci command

call_ggsci () {

  ggsci_command=$1

  ggsci_output=`${GGS_HOME}/ggsci << EOF

  ${ggsci_command}

  exit

  EOF`

}

 

case $1 in

'start')

  #start manager

  call_ggsci 'start manager'

  #there is a small delay between issuing thestart manager command

  #and the process being spawned on the OS.wait before checking

  sleep ${start_delay_secs}

  #check whether manager is running and exitaccordingly

  check_process

  ;;

 

'stop')

  #attempt a clean stop for all non-managerprocesses

  #call_ggsci 'stop er *'

  #ensure everything is stopped

  call_ggsci 'stop er *!'

  #call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

 

'check')

  check_process

  ;;

 

'clean')

  #attempt a clean stop for all non-managerprocesses

  #call_ggsci 'stop er *'

  #ensure everything is stopped

  #call_ggsci 'stop er *!'

  #in case there are lingering processes

  call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

 

'abort')

  #ensure everything is stopped

  call_ggsci 'stop er *!'

  #in case there are lingering processes

  call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

 

esac

 

添加一個應用程序profile

[oracle@node1 ggate]$cd $ORA_CRS_HOME/bin

[oracle@node1bin]$ pwd

/u01/app/oracle/product/10.2.0/crs_1/bin

[oracle@node1 bin]$crs_profile –create GG_app –t application \

–r ggvip –a/ggate/gg_action.scr –o ci=10

 

其中:-r ggvip表示ggvip必須在GoldenGate啓動之前運行,

-a /ggate/gg_action.scr指定action 腳本的位置,在每個節點必須都可用

–o ci=10:檢查的時間間隔設置爲10

 

把這個資源註冊到CRS:

[oracle@node1 bin]$crs_register GG_app

 

把vip 的所有權給root,在root用戶下執行:

[root@node1 bin]#./crs_setperm ggvip –o oracle

爲oracle用戶分配啓動這個資源的權限:

[root@node1 bin]#./crs_setperm GG_app –u user:oracle:r-x

通過oracle用戶啓動這個資源:

[oracle@node1bin]$ crs_start GG_app

Attempting tostart `GG_app` on member `node1`

Start of`GG_app` on member `node1` succeeded.

查看資源狀態顯示如下:

[oracle@node1bin]$ crs_stat GG_app -t

Name           Type           Target    State     Host       

------------------------------------------------------------

GG_app         application    ONLINE   ONLINE    node1 

 

測試節點遷移

在測試環境中可以使用crs_relocate –fGG_app使它強行漂移:過程顯示如下:

[oracle@node1~]$ crs_stat -t

Name           Type           Target    State    Host       

------------------------------------------------------------

GG_app         application   ONLINE    ONLINE    node1      

ggvip           application   ONLINE    ONLINE    node1      

ora....AC1.srv    application   ONLINE    ONLINE    node1      

ora....AC2.srv    application   ONLINE    ONLINE    node2      

ora.RAC.RAC.cs application    ONLINE   ONLINE    node2      

ora....C1.inst    application   ONLINE    ONLINE    node1      

ora....C2.inst    application   ONLINE    ONLINE    node2      

ora.RAC.db     application    ONLINE   ONLINE    node1      

ora....E1.lsnr    application   ONLINE    ONLINE    node1      

ora.node1.gsd   application   ONLINE    ONLINE    node1      

ora.node1.ons   application   ONLINE    ONLINE    node1      

ora.node1.vip   application   ONLINE    ONLINE    node1      

ora....E2.lsnr    application   ONLINE    ONLINE    node2      

ora.node2.gsd   application   ONLINE    ONLINE    node2      

ora.node2.ons   application   ONLINE    ONLINE   node2      

ora.node2.vip   application   ONLINE    ONLINE    node2      

[oracle@node1 ~]$ crs_relocate -f GG_app

Attempting to stop `GG_app` on member `node1`

Stop of `GG_app` on member `node1` succeeded.

Attempting to stop `ggvip` on member `node1`

Stop of `ggvip` on member `node1` succeeded.

Attempting to start `ggvip` on member `node2`

Start of `ggvip` on member `node2` succeeded.

Attempting to start `GG_app` on member `node2`

Start of `GG_app` on member `node2` succeeded.

[oracle@node1~]$ crs_stat -t

Name           Type           Target    State    Host       

------------------------------------------------------------

GG_app         application    ONLINE   ONLINE    node2      

ggvip           application    ONLINE   ONLINE    node2      

ora....AC1.srv    application   ONLINE    ONLINE    node1      

ora....AC2.srv    application   ONLINE    ONLINE    node2      

ora.RAC.RAC.cs  application   ONLINE    ONLINE    node2      

ora....C1.inst     application   ONLINE    ONLINE    node1      

ora....C2.inst     application   ONLINE    ONLINE    node2      

ora.RAC.db      application   ONLINE    ONLINE    node1      

ora....E1.lsnr     application   ONLINE    ONLINE    node1      

ora.node1.gsd    application   ONLINE    ONLINE   node1      

ora.node1.ons    application   ONLINE    ONLINE    node1      

ora.node1.vip    application   ONLINE    ONLINE    node1      

ora....E2.lsnr     application   ONLINE    ONLINE    node2      

ora.node2.gsd    application   ONLINE    ONLINE    node2      

ora.node2.ons    application   ONLINE    ONLINE    node2      

ora.node2.vip    application   ONLINE    ONLINE    node2      

可以看到GoldenGate成功轉移到2節點運行了。

 

 

5       常見錯誤及解決方法

5.1 OGG-00446

啓動源端抽取進程extnd,ggserr.log錯誤顯示如下:

2012-08-1711:11:38  ERROR   OGG-00446 Oracle GoldenGate Capture for Oracle, extnd.prm:  Could not find archived log for sequence45835 thread 1 under default destinations SQL <SELECT  name   FROM v$archived_log   WHEREsequence# = :ora_seq_no AND         thread#= :ora_thread AND         resetlogs_id =:ora_resetlog_id AND         archived ='YES' AND         deleted = 'NO' AND         name not like '+%'         AND standby_dest = 'NO' >, errorretrieving redo file name for sequence 45835, archived = 1, use_alternate =0Not able to establish initial position for begin time 2012-08-15 17:28:28.

導致原因:早期歸檔日誌被刪除或已備份,導致找不到歸檔日誌文件;

處理方法:

將備份的歸檔日誌恢復到歸檔日誌目錄下,即可解決錯誤;

測試庫可以指定抽取進程從某個時間點開始讀取日誌,跳過已刪除的歸檔日誌文件,命令如下:alterextract extnd,begin 2012-8-16 16:38;

 

5.2 OGG-01223

啓動源端傳輸進程DPEND,ggserr.log錯誤顯示如下:

2012-08-1711:43:50  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle,dpend.prm:  TCP/IP error 79 (Connectionrefused).

2012-08-1711:45:01  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle,dpend.prm:  TCP/IP error 79 (Connectionrefused).

導致原因:因爲目標端110上MGR進程沒有啓動,導致報錯

處理方法:

在目標端啓動startmgr啓動進程後,再啓動源端的傳輸進程DPEND,錯誤消失,文件順利傳輸過來了。

 

正常的日誌如下:

2012-08-1714:31:51  INFO    OGG-00993 Oracle GoldenGate Capture for Oracle, dpend.prm:  EXTRACT DPEND started.

2012-08-1714:33:13  INFO    OGG-01226 Oracle GoldenGate Capture for Oracle, dpend.prm:  Socket buffer size set to 27985 (flush size27985).

2012-08-1714:33:26  INFO    OGG-01052 Oracle GoldenGate Capture for Oracle, dpend.prm:  No recovery is required for target file F:\ogg\dirdat\nd000000,at RBA 0 (file not opened).

2012-08-1714:33:26  INFO    OGG-01478 Oracle GoldenGate Capture for Oracle, dpend.prm:  Output file F:\ogg\dirdat\nd is using formatRELEASE 11.2.

 

5.3 OGG-01224

啓動源端傳輸進程DPEND,ggserr.log錯誤顯示如下:

2012-08-2205:33:10  ERROR   OGG-01224 Oracle GoldenGate Capture for Oracle, dpend.prm:  TCP/IP error 113 (No route to host).

2012-08-2205:33:10  ERROR   OGG-01668 Oracle GoldenGate Capture for Oracle, dpend.prm:  PROCESS ABENDING.

導致原因:因爲目標端235上的防火牆沒有關閉,導致報錯

處理方法:

在目標端機器關閉防火牆後,再啓動源端的傳輸進程DPEND,錯誤消失,文件順利傳輸過來了。

5.4 OGG-01031

啓動源端傳輸進程DPEND,ggserr.log錯誤顯示如下:

2012-08-28 15:09:39  ERROR  OGG-01031  Oracle GoldenGateCapture for Oracle, dpend.prm:  There isa problem in network communication, a remote file problem, encryption keys fortarget and source do not match (if using ENCRYPT) or an unknown error. (Replyreceived is Unable to open file "/uo1/app/ogg/dirdat/nd000004" (error2, No such file or directory)).

2012-08-28 15:09:41  ERROR  OGG-01668  Oracle GoldenGateCapture for Oracle, dpend.prm:  PROCESSABENDING.目標端ggserr.log錯誤顯示如下:

2012-08-2815:06:30  WARNING OGG-01223  Oracle GoldenGate Collector for Oracle:  Unable to lock file"/uo1/app/ogg/dirdat/nd000004" (error 11, Resource temporarilyunavailable).  Lock currently held byprocess id (PID) 13854.

2012-08-2815:06:30  WARNING OGG-01223  Oracle GoldenGate Collector for Oracle:  Unable to open file"/uo1/app/ogg/dirdat/nd000004" (error 2, No such file or directory).

導致原因:可能是網絡出現過故障,OGG源端的Data Pump進程與目標斷了聯繫,目標端mgr爲其啓動的server進程一直還在運行,下次data pump重啓時目標mgr會試圖生成另外一個server進程,這樣兩個進程會爭同一個隊列文件。

處理方法:

1、停掉源端的所有data pump,使用ps –ef|grep server(或OGG安裝目錄)看看是不是還有OGG的server進程在跑,如果有,殺死它(一定要確認源端data pump全停掉,並且殺的是server進程,不要殺其它extract/replicat/mgr等),重啓源端data pump即可。

 

2、可能是目標端的trail file出問題了,前滾重新生成一個新的隊列文件

SEND EXTRACT xxx ETROLLOVER

或者:alter extract xxx etrollover

xxx爲datapump的名稱

 

5.5 OGG-01154

錯誤信息:2011-03-29 15:53:57  WARNINGOGG-01154  Oracle GoldenGate Delivery forOracle, repya.prm:  SQL error 14402mapping EPMA.D_METER to E

PMA.D_METER OCIError ORA-14402: updating partition key column would cause a partition change(status = 14402), SQL <UPDATE "EPMA"."D_METER" SET"PR_ORG" = :a1,"BELONG_DEPT" = :a2 WHERE"METER_ID" = :b0>.

導致原因:源端更新了分區列,但目標端沒有打開行移動,導致更新時報錯;

處理方法:SQLPLUS>alter table SCHEMA.TABLENAME enable row movement;轉發一份GoldenGate 配置文檔,裏面有參數說明,值得看

 15253人閱讀 評論(1) 收藏 舉報
 分類:
 

目錄(?)[+]

 

1       GoldenGate簡要說明

GoldenGate現在是業內成熟的數據容災與複製產品,經過多年的發展與完善,現在已經成爲業內事實上的標準之一。

GoldenGate軟件是一種基於日誌的結構化數據複製軟件,它通過解析源數據庫在線日誌或歸檔日誌獲得數據的增刪改變化,再將這些變化應用到目標數據庫,實現源數據庫與目標數據庫同步。

1.1  Golden Gate技術結構

GoldenGate軟件的技術結構如圖1.1所示:

圖1.1GoldenGate技術架構

從圖中可以看到:GoldenGate主要包含Manager進程、Extract進程、Pump進程、Replicat進程,下面對其一一說明:

Manager進程是GoldenGate的控制進程,它主要作用有以下幾個方面:啓動、監控、重啓GoldenGate的其他進程,報告錯誤及時間,分配數據存儲空間,發佈閥值報告等。

Extract進程運行在數據庫源端,負責從源端數據表或日誌中捕獲數據。Extract進程利用其內在的checkpoint機制,週期性地檢查並記錄其讀寫的位置,通常是寫入到本地的trail文件。這種機制是爲了保證如果Extract進程終止或者操作系統宕機,我們重啓Extract進程後,GoldenGate能夠恢復到以前的狀態,從上一個斷點處繼續往下運行,而不會有任何數據損失。

Pump進程運行在數據庫源端,其作用非常簡單。如果源端使用了本地trail文件,那麼Pump進程就會把Trail文件以數據塊的形式通過TCP/IP協議發送到目標端,我們下面的配置都是這種方式。Pump進程本質是Extract進程的一種特殊形式,如果不使用Trail文件,那麼Extract進程在抽取完數據後,直接投遞到目標端。

與Pump進程相對應的叫Server Collector進程,這個進程不需要引起我們關注,因爲在實際操作過程中無需對其進行任何配置,它運行在目標端,任務就是把Extract/Pump進程投遞過來的數據塊重新組裝成Trail文件。

Replicat進程運行在目標端,是數據投遞的最後一站,負責讀取目標端Trail文件中的內容,並將解析其解析爲DML或DDL語句,然後應用到目標數據庫中。

1.2  Golden Gate拓撲結構

GoldenGate提供了靈活的應用方案,基於其先進、靈活的技術架構可以根據用戶需求組成各種拓撲結構,如圖1.2所示:

圖1.2GoldenGate應用方案示意圖

根據實際需求情況,我們需要進行的是一對一複製,且只是複製部分表數據,所以這裏僅探討一對一複製的安裝配置,而且對於DDL複製的支持這裏也不做研究。

2       單機à單機複製配置

2.1  環境簡介

性質

IP

系統

Oracle版本

源端

10.122.0.110

AIX 5.3

10.2.0.1

目標端

10.122.0.113

WINDOWS 2003

10.2.0.1

 

2.2  源端安裝GoldenGate

創建GoldenGate安裝目錄並解壓安裝文件

unzip ogg112101_ggs_AIX_ppc_ora10.2_64bit.zip

tar –xf ggs_AIX_ppc_ora10.2_64bit.tar

注意:使用的安裝包一定要與平臺一致

 

設置環境變量

在用戶參數文件中添加以下內容:

export GGATE_HOME=/u01/oracle/oracle/ogg

export LIBPATH=$GGATE_HOME:$ORACLE_HOME/lib

注意:添加後需使參數文件生效

HPLinux平臺下用LD_LIBRARY_PATH替換LIBPATH

 

安裝GoldenGate

進入OGG控制檯創建OGG工作目錄

然後在安裝目錄下執行 ./ggsci  進入OGG控制檯

執行命令 createsubdirs創建工作目錄,顯示如下:

GGSCI (NDSCDB1)1> create subdirs

Creatingsubdirectories under current directory /u01/oracle/oracle/ogg

 

Parameterfiles              /u01/oracle/oracle/ogg/dirprm: already exists

Reportfiles                 /u01/oracle/oracle/ogg/dirrpt: created

Checkpointfiles             /u01/oracle/oracle/ogg/dirchk: created

Process statusfiles            /u01/oracle/oracle/ogg/dirpcs: created

SQL scriptfiles               /u01/oracle/oracle/ogg/dirsql:created

Databasedefinitions files       /u01/oracle/oracle/ogg/dirdef: created

Extract datafiles              /u01/oracle/oracle/ogg/dirdat: created

Temporaryfiles              /u01/oracle/oracle/ogg/dirtmp: created

Stdout files                  /u01/oracle/oracle/ogg/dirout: created

2.3 目標端安裝GoldenGate

建立OGG安裝目錄,然後將壓縮包解壓到目錄中,進入cmd控制檯,創建工作目錄,

操作步驟顯示如下:

 

2.4  配置源端數據庫

數據庫模式配置

源端數據庫必須開啓歸檔模式

Alter databasearchivelog;

開啓最小附加日誌

Alter databaseadd supplemental log data;

使用SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

可查看是否開啓了最小附加日誌;

 

源端數據庫創建GoldenGate數據庫用戶並授權:(我們這裏以ogg爲例,使用其他亦可)

create user ogg identified by oracle defaulttablespace DATA_OL;

grant connect,resource,unlimited tablespace to ogg;

grant executeon utl_file to ogg;

grant select any dictionary,select any table to ogg;

grant alter any table to ogg;

grant flashback any table to ogg;

grant execute onDBMS_FLASHBACK to ogg;

添加表級transdata

GGSCI (NDSCDB1) 2>dblogin userid ogg,password oracle

Successfully logged intodatabase.

GGSCI(NDSCDB1) 3> add trandata olive.ol$_objects

Logging of supplemental redo dataenabled for table OLIVE.OL$_OBJECTS.

 

2.5  配置源端進程組

配置管理進程mgr:

GGSCI(NDSCDB1) 1> edit param mgr

(粘貼下面這段配置)

PORT 7839

DYNAMICPORTLIST 7840-7939

--AUTOSTART ER *

AUTORESTART EXTRACT *,RETRIES5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS 1

LAGINFOMINUTES 30

LAGCRITICALMINUTES 45

MANAGER進程參數配置說明:

PORT:指定服務監聽端口;這裏以7839爲例,默認端口爲7809

DYNAMICPORTLIST:動態端口:可以制定最大256個可用端口的動態列表,當指定的端口不可用時,管理進程將會從列表中選擇一個可用的端口,源端和目標段的CollectorReplicatGGSCI進程通信也會使用這些端口;

COMMENT:註釋行,也可以用--來代替;

AUTOSTART:指定在管理進程啓動時自動啓動哪些進程;

AUTORESTART:自動重啓參數設置:本處設置表示每3分鐘嘗試重新啓動所有EXTRACT進程,共嘗試5次;

PURGEOLDEXTRACTS:定期清理trail文件設置:本處設置表示對於超過3天的trail文件進行刪除。

LAGREPORT、LAGINFO、LAGCRITICAL:

定義數據延遲的預警機制:本處設置表示MGR進程每隔1小時檢查EXTRACT的延遲情況,如果超過了30分鐘就把延遲作爲信息記錄到錯誤日誌中,如果延遲超過了45分鐘,則把它作爲警告寫到錯誤日誌中。

 

啓動管理進程:

GGSCI(NDSCDB1) 2> start mgr

Managerstarted.

查看進程狀態可發現 MANAGER狀態爲 RUNNING:

GGSCI(NDSCDB1) 3> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING

配置抽取進程:

GGSCI(NDSCDB1) 12> add extract extnd,tranlog,begin now

EXTRACTadded.

GGSCI(NDSCDB1) 14> add exttrail ./dirdat/nd,extract extnd,megabytes 100

EXTTRAILadded.

Megabytes:指定隊列大小,本處設置表示100M

GGSCI(NDSCDB1) 15> edit params extnd

(粘貼下面這段配置)

EXTRACTextnd

setenv(NLS_LANG = "AMERICAN_AMERICA.UTF8")

SETENV(ORACLE_HOME = "/u01/oracle/oracle/product/10.2.0/db_1")

SETENV(ORACLE_SID = "ndtest")

USERIDogg, PASSWORD oracle

--GETTRUNCATES

REPORTCOUNTEVERY 1 MINUTES, RATE

DISCARDFILE./dirrpt/extnd.dsc,APPEND,MEGABYTES 1024

--THREADOPTIONS  MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS60000

DBOPTIONS  ALLOWUNUSEDCOLUMN

WARNLONGTRANS2h,CHECKINTERVAL 3m

EXTTRAIL./dirdat/nd

--TRANLOGOPTIONSEXCLUDEUSER USERNAME

FETCHOPTIONSNOUSESNAPSHOT

TRANLOGOPTIONS  CONVERTUCS2CLOBS

TABLEolive.ol$_objects

 

添加傳輸進程,配置參數

GGSCI(NDSCDB1) 2> add extract dpend,exttrailsource ./dirdat/nd

EXTRACTadded.

GGSCI(NDSCDB1) 3> add rmttrail F:\ogg\dirdat\nd, EXTRACT DPEND

RMTTRAILadded.

 

GGSCI(NDSCDB1) 4> edit params dpend

(粘貼下面這段配置)

EXTRACTdpend

SETENV(NLS_LANG = "AMERICAN_AMERICA.UTF8")

USERIDogg, PASSWORD oracle

PASSTHRU

RMTHOST10.122.0.113, MGRPORT 7839, compress

RMTTRAILF:\ogg\dirdat\nd

TABLEolive.ol$_objects;

 

抽取進程和傳輸進程其實都是EXTRACT進程,也可以配置在一個進程完成這兩個功能,但是當網絡傳輸有問題時,這樣抽取也就不能繼續運行了,所以推薦分開配置爲兩個進程;

EXTRACT進程參數配置說明:

SETENV:配置系統環境變量

USERID/ PASSWORD:指定OGG連接數據庫的用戶名和密碼,這裏使用3.4部分中創建的數據庫用戶OGG;

COMMENT:註釋行,也可以用--來代替;

TABLE:定義需複製的表,後面需以;結尾

TABLEEXCLUDE:定義需要排除的表,如果在TABLE參數中使用了通配符,可以使用該參數指定排除掉得表。

GETUPDATEAFTERS|IGNOREUPDATEAFTERS:

是否在隊列中寫入後影像,缺省複製

GETUPDATEBEFORES| IGNOREUPDATEBEFORES:

是否在隊列中寫入前影像,缺省不復制

GETUPDATES|IGNOREUPDATES:

是否複製UPDATE操作,缺省複製

GETDELETES|IGNOREDELETES:

是否複製DELETE操作,缺省複製

GETINSERTS|IGNOREINSERTS:

是否複製INSERT操作,缺省複製

GETTRUNCATES|IGNORETRUNDATES:

是否複製TRUNCATE操作,缺省不復制;

RMTHOST:指定目標系統及其GoldengateManager進程的端口號,還用於定義是否使用壓縮進行傳輸,本例中的compress爲壓縮傳輸;

RMTTRAIL:指定寫入到目標斷的哪個隊列;

EXTTRAIL:指定寫入到本地的哪個隊列;

SQLEXEC:extract進程運行時首先運行一個SQL語句;

PASSTHRU:禁止extract進程與數據庫交互,適用於Data Pump傳輸進程;

REPORT:定義自動定時報告;

STATOPTIONS:定義每次使用stat時統計數字是否需要重置;

REPORTCOUNT:報告已經處理的記錄條數統計數字;

TLTRACE:打開對於數據庫日誌的跟蹤日誌;

DISCARDFILE:定義discardfile文件位置,如果處理中油記錄出錯會寫入到此文件中;

DBOPTIONS:指定對於某種特定數據庫所需要的特殊參數;

TRANLOGOPTIONS:指定在解析數據庫日誌時所需要的特殊參數,例如:對於裸設備,可能需要加入以下參數 rawdeviceoggset 0

WARNLONGTRANS:指定對於超過一定時間的長交易可以在gsserr.log裏面寫入警告信息,本處配置爲每隔3分鐘檢查一次場交易,對於超過2小時的進行警告;

 

2.6  配置目標數據庫

目標庫創建GoldenGate數據庫用戶並授權:

createuser ogg identified by oracle default tablespace DATA_OL;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

grantinsert any table to ogg;

grantdelete any table to ogg;

grantupdate any table to ogg;

 

添加checkpoint表

然後在參數文件中輸入

GGSCHEMAogg

CHECKPOINTTABLEogg.checkpoint

 

2.7 配置目標端進程組

配置管理進程

 

配置複製進程

REPLICAT進程參數配置說明:

ASSUMETARGETDEFS:假定兩端數據結構一致使用此參數;

SOURCEDEFS:假定兩端數據結構不一致,使用此參數指定源端的數據結構定義文件,該文件需要由GlodenGate工具產生。

MAP:用於指定源端與目標端表的映射關係;

MAPEXCLUDE:用於使用在MAP中使用*匹配時排除掉指定的表;

REPERROR:定義出錯以後進程的響應,一般可以定義爲兩種:

ABEND,即一旦出現錯誤即停止複製,此爲缺省配置;

DISCARD,出現錯誤後繼續複製,只是把錯誤的數據放到discard文件中。

DISCARDFILE:定義discardfile文件位置,如果處理中油記錄出錯會寫入到此文件中;

SQLEXEC:在進程運行時首先運行一個SQL語句;

GROUPTRANSOPS:將小交易合併成一個大的交易進行提交,減少提交次數,降低系統IO消耗。

MAXTRANSOPS:將大交易拆分,每XX條記錄提交一次。

 

2.8 啓動進程進行數據同步

啓動源端進程組

啓動抽取進程和傳輸進程:

start extnd

start dpend

啓動後使用info all查看進程狀態,正常status應該RUNNING,顯示如下:

GGSCI (NDSCDB1)11> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING                                     

EXTRACT     RUNNING    DPEND       00:00:00      00:15:32

EXTRACT     RUNNING    EXTND       00:00:00      00:00:04

 

啓動目標端進程

start repnd

顯示如下:

到此OGG的安裝配置就完成了,可以進行數據同步測試了。

 

3       RACà單機複製配置

3.1  環境簡介

性質

IP

系統

ORACLE版本

源端

10.123.112.201/10.123.112.202

linux rhel5 64位

10.2.0.1

目標端

10.123.112.235

LINUX rhel5 32位

10.2.0.1

 

3.2 源端安裝OCFS2集羣文件系統

RAC環境中爲了實現高可用性,需將OGG安裝在集羣文件系統中,這樣OGG可以訪問RAC中的所有節點,我們這裏測試採用OCFS2文件系統。

從http://oss.oracle.com下載與LINUX內核相符的OCFS2 RPM包

LINUX下執行uname –r查看系統內核版本 eg:

[oracle@node2ocfs]$ uname -r

2.6.18-92.el5

 

使用ROOT用戶安裝OCFS2的RPM包

[root@node1ocfs]# rpm -ivh ocfs2-tools-1.2.7-1.el5.x86_64.rpm \

ocfs2console-1.2.7-1.el5.x86_64.rpm\

ocfs2-2.6.18-92.el5-1.2.9-1.el5.x86_64.rpm

進入OCFS2控制檯界面

[root@node1 ~]#ocfs2console

在出現的窗體中選擇[Clucster]-[ConfigureNodes]在"NodeConfiguration"對話框中,輸入2個專用互連的節點名、IP 地址、端口號後,選擇 [Clucster]-[PropagateCluster Configuration] ,提示"Finished"。

配置後的信息顯示如下:

在集羣中的所有節點上以 root 用戶帳戶的身份運行以下命令
    export PATH=$PATH:/sbin:/usr/sbin
    /etc/init.d/o2cb enable

創建ocfs2文件系統,其中-N選項用於指明最多允許多少個節點同時使用此文件系統:

# mkfs -t ocfs2-N 2 /dev/sdh1

掛載分區:

# mount /dev/sdh1/ggate

 

配置啓動自動載入(所有節點):
    export PATH=$PATH:/sbin:/usr/sbin
    chkconfig --add o2cb
    /etc/init.d/o2cb configure
 在/etc/rc.local增加入下內容:       

chown -Roracle:dba /ggate
chmod -R 775 /ggate

 

3.3 源端安裝GoldenGate

在GoldenGate安裝目錄(OCFS2目錄/ggate)解壓安裝文件

unzipogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip

tar–xvf fbo_ggs_Linux_x64_ora10g_64bit.tar

 

設置環境變量

在用戶參數文件中添加以下內容:

exportGGATE_HOME=/ggate

exportLD_LIBRARY_PATH=$GGATE_HOME:$ORACLE_HOME/lib

注意:添加後需使參數文件生效

 

安裝GoldenGate

進入OGG控制檯創建OGG工作目錄

然後在安裝目錄下執行 ./ggsci  進入OGG控制檯

執行命令 createsubdirs創建工作目錄,顯示如下:

GGSCI(node1) 1> create subdirs

 

Creatingsubdirectories under current directory /ggate

 

Parameterfiles                /ggate/dirprm:already exists

Reportfiles                   /ggate/dirrpt:created

Checkpointfiles               /ggate/dirchk:created

Processstatus files             /ggate/dirpcs: created

SQLscript files               /ggate/dirsql:created

Databasedefinitions files       /ggate/dirdef: created

Extractdata files              /ggate/dirdat: created

Temporaryfiles               /ggate/dirtmp:created

Stdoutfiles                   /ggate/dirout:created

 

3.4 目標端安裝GoldenGate

環境相同,安裝方法與4.3一致,僅僅是安裝位置不同,安裝過程略,注意安裝包與平臺一致。

3.5 配置源端數據庫

數據庫模式配置

源端數據庫必須開啓歸檔模式

Alterdatabase archivelog;

開啓最小附加日誌

Alterdatabase add supplemental log data;

使用SELECTSUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

可查看是否開啓了最小附加日誌;

 

源端數據庫創建GoldenGate數據庫用戶並授權:(我們這裏以ogg爲例,使用其他亦可)

createuser ogg identified by oracle default tablespace DATA_OL;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

添加表級transdata

GGSCI(node1) 1> dblogin userid ogg,password oracle

Successfullylogged into database.

GGSCI(node1) 2> add trandata SCOTT.DEPT

Loggingof supplemental redo data enabled for table SCOTT.DEPT.

GGSCI(node1) 3> add trandata SCOTT.EMP

Loggingof supplemental redo data enabled for table SCOTT.EMP.

3.6  配置源端進程組

配置管理進程mgr:

GGSCI(node1) 1> edit param mgr

(粘貼下面這段配置)

PORT7839

DYNAMICPORTLIST7840-7939

--AUTOSTARTER *

AUTORESTARTEXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS1

LAGINFOMINUTES30

LAGCRITICALMINUTES45

參數說明均與單點配置相同,參考3.5部分

啓動管理進程:

GGSCI(node1) 2> start mgr

Managerstarted.

GGSCI(node1) 3> info all

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

 

配置抽取進程:

GGSCI(node1) 6> add extract extnd,tranlog,begin now,threads 2

EXTRACTadded.

GGSCI(node1) 7> add exttrail ./dirdat/nd,extract extnd,megabytes 100

EXTTRAILadded.

GGSCI(node1) 8> edit params extnd

(粘貼下面這段配置)

EXTRACTextnd

SETENV(NLS_LANG = "AMERICAN_AMERICA.UTF8")

SETENV(ORACLE_HOME = "/u01/app/oracle/product/10.2.0/db_1")

USERID ogg@RAC, PASSWORDoracle

--GETTRUNCATES

REPORTCOUNTEVERY 1 MINUTES, RATE

DISCARDFILE./dirrpt/extnd.dsc,APPEND,MEGABYTES 1024

--THREADOPTIONS  MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS60000

DBOPTIONS  ALLOWUNUSEDCOLUMN

WARNLONGTRANS2h,CHECKINTERVAL 3m

EXTTRAIL./dirdat/nd

--TRANLOGOPTIONSEXCLUDEUSER USERNAME

FETCHOPTIONSNOUSESNAPSHOT

TRANLOGOPTIONS  CONVERTUCS2CLOBS

TABLEscott.dept;

TABLEscott.emp;

 

注意:threadsRAC節點數相同即可,RAC中不再使用ORACLE_SID設置,而使用USERID ogg@RAC,注意兩個節點均可連接數據庫。

 

添加傳輸進程,配置參數

GGSCI(node1) 2> add extract dpend,exttrailsource ./dirdat/nd

EXTRACTadded.

GGSCI(node1) 3> add rmttrail /uo1/app/ogg/dirdat/nd, EXTRACT DPEND

RMTTRAILadded.

GGSCI(node1) 4> edit params dpend

(粘貼下面這段配置)

EXTRACTdpend

SETENV(NLS_LANG = AMERICAN_AMERICA.UTF8)

USERID ogg@RAC, PASSWORDoracle

PASSTHRU

RMTHOST10.123.112.235, MGRPORT 7839, compress

RMTTRAIL/uo1/app/ogg/dirdat/nd

TABLEscott.dept;

TABLEscott.emp;

 

3.7 配置目標數據庫

目標庫創建GoldenGate數據庫用戶並授權:

createuser ogg identified by oracle default tablespace USERS;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

grantinsert any table to ogg;

grantdelete any table to ogg;

grantupdate any table to ogg;

 

添加checkpoint表

GGSCI(sun.linux) 2> edit params GLOBALS

 

然後在參數文件中輸入

GGSCHEMAogg

CHECKPOINTTABLEogg.checkpoint

 

GGSCI(sun.linux) 4> dblogin userid ogg,password oracle

Successfullylogged into database.

 

GGSCI(sun.linux) 5> add checkpointtable ogg.checkpoint

 

Successfullycreated checkpoint table ogg.checkpoint.

3.8 配置目標端進程組

配置MGR參數

GGSCI(sun.linux) 6> edit params mgr

(粘貼下面這段配置)

PORT7839

DYNAMICPORTLIST7840-7939

--AUTOSTARTER *

AUTORESTARTEXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS1

LAGINFOMINUTES30

LAGCRITICALMINUTES45

 

配置複製隊列

GGSCI(sun.linux)8> add replicat repnd,exttrail/uo1/app/ogg/dirdat/nd,checkpointtable ogg.checkpoint

REPLICATadded.

 

GGSCI(sun.linux) 10> edit params repnd

(粘貼下面這段配置)

REPLICATrepnd

SETENV(NLS_LANG = AMERICAN_AMERICA.UTF8)

USERIDogg, PASSWORD oracle

ASSUMETARGETDEFS

REPERRORdefault,discard

discardfile./dirrpt/repnd.dsc,append,megabytes 50

mapscott.*,target pmsbi.*;

 

3.9 啓動進程進行數據同步

啓動源端進程組

啓動抽取進程和傳輸進程:

startextnd

startdpend

啓動後使用info all查看進程狀態,正常status應該RUNNING,顯示如下:

GGSCI(node1) 19> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING                                          

EXTRACT     RUNNING    DPEND       00:00:00      00:00:09   

EXTRACT     RUNNING    EXTND       00:00:00      00:00:04

 

啓動目標端進程

startrepnd

顯示如下:

GGSCI(sun.linux) 2> info all

 

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING                                          

REPLICAT    RUNNING    REPND       00:00:00      00:00:03 

到此RAC到單點OGG的安裝配置就完成了,可以進行數據同步測試了。

 

4       RACà單機下的HA配置

    第4部分的RACà單機的配置僅僅完成了數據複製的功能,不包含高可用的配置,當運行GoldenGate的節點出現故障時複製功能就將終止,如何使複製功能繼續可用呢,有如下兩種方式:

4.1 節點故障的手工處理方式

因爲GoldenGate 安裝在共享目錄下,我們可以通過任一個節點連接到共享目錄,啓動GoldenGate運行界面。如果其中一個節點失敗,導致GoldenGate進程中止,可以直接手工在另外一個節點啓動進程組即可。

4.2 GoldenGate的HA配置

我們可以通過使用CRS來管理GoldenGate資源組,並且使用RAC的vip連接到GoldenGate,一旦數據庫的某一個節點宕掉,Oracleclusterware將自動切換到另一個可用節點。

添加一個應用程序VIP資源

爲GoldenGate vip資源創建一個profile

[oracle@node1ggate]$ cd $ORA_CRS_HOME/bin

[oracle@node1bin]$ pwd

/u01/app/oracle/product/10.2.0/crs_1/bin

[oracle@node1 bin]$crs_profile –create ggvip –t application \

–a /u01/app/oracle/product/10.2.0/crs_1\

-o oi=eth0,ov=192.168.73.203,on=255.255.255.0

其中:ggvip爲創建的應用程序vip的名字

把這個資源註冊到CRS:

[oracle@node1 bin]$crs_register ggvip

把vip 的所有權給root,在root用戶下執行:

[root@node1 bin]#./crs_setperm ggvip –o root

爲oracle用戶分配啓動這個資源的權限:

[root@node1 bin]#./crs_setperm ggvip –u user:oracle:r-x

通過oracle用戶啓動這個資源:

[oracle@node1bin]$ crs_start ggvip

Attempting tostart `ggvip` on member `node1`

Start of`ggvip` on member `node1` succeeded.

查看資源狀態顯示如下:

[oracle@node1bin]$ crs_stat ggvip -t

Name           Type           Target    State    Host       

------------------------------------------------------------

ggvip          application    ONLINE   ONLINE    node1

 

創建一個action程序

action程序我們這裏放到共享磁盤上,action程序最少需要可以接受三個參數:start,stop,check

start和stop:返回0成功,1 失敗;

check     :返回0表示GoldenGate在運行,1 表示不運行;

下面爲示例程序 gg_action.scr的內容:

 

#!/bin/sh

#set the OracleGoldengate installation directory

exportGGS_HOME=/ggate

#set the oraclehome to the database to ensure GoldenGate will get the

#rightenvironment settings to be able to connect to the database

exportORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

#specify delayafter start before checking for successful start

start_delay_secs=5

#Include theGoldenGate home in the library path to start GGSCI

exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:${GGS_HOME}:${LD_LIBRARY_PATH}

#check_processvalidates that a manager process is running at the PID

#thatGoldenGate specifies.

 

check_process() {

if ( [ -f"${GGS_HOME}/dirpcs/MGR.pcm" ] )

then

  pid=`cut -f8"${GGS_HOME}/dirpcs/MGR.pcm"`

  if [ ${pid} = `ps -e |grep ${pid} |grep mgr|cut -d " " -f2` ]

  then

    #manager process is running on the PID exitsuccess

    exit 0

  else

  if [ ${pid} = `ps -e |grep ${pid} |grep mgr|cut -d " " -f1` ]

  then

    #manager process is running on the PID exitsuccess

    exit 0

  else

    #manager process is not running on the PID

    exit 1

  fi

fi

else

  #manager is not running because there is noPID file

  exit 1

fi

}

 

#call_ggsci isa generic routine that executes a ggsci command

call_ggsci () {

  ggsci_command=$1

  ggsci_output=`${GGS_HOME}/ggsci << EOF

  ${ggsci_command}

  exit

  EOF`

}

 

case $1 in

'start')

  #start manager

  call_ggsci 'start manager'

  #there is a small delay between issuing thestart manager command

  #and the process being spawned on the OS.wait before checking

  sleep ${start_delay_secs}

  #check whether manager is running and exitaccordingly

  check_process

  ;;

 

'stop')

  #attempt a clean stop for all non-managerprocesses

  #call_ggsci 'stop er *'

  #ensure everything is stopped

  call_ggsci 'stop er *!'

  #call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

 

'check')

  check_process

  ;;

 

'clean')

  #attempt a clean stop for all non-managerprocesses

  #call_ggsci 'stop er *'

  #ensure everything is stopped

  #call_ggsci 'stop er *!'

  #in case there are lingering processes

  call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

 

'abort')

  #ensure everything is stopped

  call_ggsci 'stop er *!'

  #in case there are lingering processes

  call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

 

esac

 

添加一個應用程序profile

[oracle@node1 ggate]$cd $ORA_CRS_HOME/bin

[oracle@node1bin]$ pwd

/u01/app/oracle/product/10.2.0/crs_1/bin

[oracle@node1 bin]$crs_profile –create GG_app –t application \

–r ggvip –a/ggate/gg_action.scr –o ci=10

 

其中:-r ggvip表示ggvip必須在GoldenGate啓動之前運行,

-a /ggate/gg_action.scr指定action 腳本的位置,在每個節點必須都可用

–o ci=10:檢查的時間間隔設置爲10

 

把這個資源註冊到CRS:

[oracle@node1 bin]$crs_register GG_app

 

把vip 的所有權給root,在root用戶下執行:

[root@node1 bin]#./crs_setperm ggvip –o oracle

爲oracle用戶分配啓動這個資源的權限:

[root@node1 bin]#./crs_setperm GG_app –u user:oracle:r-x

通過oracle用戶啓動這個資源:

[oracle@node1bin]$ crs_start GG_app

Attempting tostart `GG_app` on member `node1`

Start of`GG_app` on member `node1` succeeded.

查看資源狀態顯示如下:

[oracle@node1bin]$ crs_stat GG_app -t

Name           Type           Target    State     Host       

------------------------------------------------------------

GG_app         application    ONLINE   ONLINE    node1 

 

測試節點遷移

在測試環境中可以使用crs_relocate –fGG_app使它強行漂移:過程顯示如下:

[oracle@node1~]$ crs_stat -t

Name           Type           Target    State    Host       

------------------------------------------------------------

GG_app         application   ONLINE    ONLINE    node1      

ggvip           application   ONLINE    ONLINE    node1      

ora....AC1.srv    application   ONLINE    ONLINE    node1      

ora....AC2.srv    application   ONLINE    ONLINE    node2      

ora.RAC.RAC.cs application    ONLINE   ONLINE    node2      

ora....C1.inst    application   ONLINE    ONLINE    node1      

ora....C2.inst    application   ONLINE    ONLINE    node2      

ora.RAC.db     application    ONLINE   ONLINE    node1      

ora....E1.lsnr    application   ONLINE    ONLINE    node1      

ora.node1.gsd   application   ONLINE    ONLINE    node1      

ora.node1.ons   application   ONLINE    ONLINE    node1      

ora.node1.vip   application   ONLINE    ONLINE    node1      

ora....E2.lsnr    application   ONLINE    ONLINE    node2      

ora.node2.gsd   application   ONLINE    ONLINE    node2      

ora.node2.ons   application   ONLINE    ONLINE   node2      

ora.node2.vip   application   ONLINE    ONLINE    node2      

[oracle@node1 ~]$ crs_relocate -f GG_app

Attempting to stop `GG_app` on member `node1`

Stop of `GG_app` on member `node1` succeeded.

Attempting to stop `ggvip` on member `node1`

Stop of `ggvip` on member `node1` succeeded.

Attempting to start `ggvip` on member `node2`

Start of `ggvip` on member `node2` succeeded.

Attempting to start `GG_app` on member `node2`

Start of `GG_app` on member `node2` succeeded.

[oracle@node1~]$ crs_stat -t

Name           Type           Target    State    Host       

------------------------------------------------------------

GG_app         application    ONLINE   ONLINE    node2      

ggvip           application    ONLINE   ONLINE    node2      

ora....AC1.srv    application   ONLINE    ONLINE    node1      

ora....AC2.srv    application   ONLINE    ONLINE    node2      

ora.RAC.RAC.cs  application   ONLINE    ONLINE    node2      

ora....C1.inst     application   ONLINE    ONLINE    node1      

ora....C2.inst     application   ONLINE    ONLINE    node2      

ora.RAC.db      application   ONLINE    ONLINE    node1      

ora....E1.lsnr     application   ONLINE    ONLINE    node1      

ora.node1.gsd    application   ONLINE    ONLINE   node1      

ora.node1.ons    application   ONLINE    ONLINE    node1      

ora.node1.vip    application   ONLINE    ONLINE    node1      

ora....E2.lsnr     application   ONLINE    ONLINE    node2      

ora.node2.gsd    application   ONLINE    ONLINE    node2      

ora.node2.ons    application   ONLINE    ONLINE    node2      

ora.node2.vip    application   ONLINE    ONLINE    node2      

可以看到GoldenGate成功轉移到2節點運行了。

 

 

5       常見錯誤及解決方法

5.1 OGG-00446

啓動源端抽取進程extnd,ggserr.log錯誤顯示如下:

2012-08-1711:11:38  ERROR   OGG-00446 Oracle GoldenGate Capture for Oracle, extnd.prm:  Could not find archived log for sequence45835 thread 1 under default destinations SQL <SELECT  name   FROM v$archived_log   WHEREsequence# = :ora_seq_no AND         thread#= :ora_thread AND         resetlogs_id =:ora_resetlog_id AND         archived ='YES' AND         deleted = 'NO' AND         name not like '+%'         AND standby_dest = 'NO' >, errorretrieving redo file name for sequence 45835, archived = 1, use_alternate =0Not able to establish initial position for begin time 2012-08-15 17:28:28.

導致原因:早期歸檔日誌被刪除或已備份,導致找不到歸檔日誌文件;

處理方法:

將備份的歸檔日誌恢復到歸檔日誌目錄下,即可解決錯誤;

測試庫可以指定抽取進程從某個時間點開始讀取日誌,跳過已刪除的歸檔日誌文件,命令如下:alterextract extnd,begin 2012-8-16 16:38;

 

5.2 OGG-01223

啓動源端傳輸進程DPEND,ggserr.log錯誤顯示如下:

2012-08-1711:43:50  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle,dpend.prm:  TCP/IP error 79 (Connectionrefused).

2012-08-1711:45:01  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle,dpend.prm:  TCP/IP error 79 (Connectionrefused).

導致原因:因爲目標端110上MGR進程沒有啓動,導致報錯

處理方法:

在目標端啓動startmgr啓動進程後,再啓動源端的傳輸進程DPEND,錯誤消失,文件順利傳輸過來了。

 

正常的日誌如下:

2012-08-1714:31:51  INFO    OGG-00993 Oracle GoldenGate Capture for Oracle, dpend.prm:  EXTRACT DPEND started.

2012-08-1714:33:13  INFO    OGG-01226 Oracle GoldenGate Capture for Oracle, dpend.prm:  Socket buffer size set to 27985 (flush size27985).

2012-08-1714:33:26  INFO    OGG-01052 Oracle GoldenGate Capture for Oracle, dpend.prm:  No recovery is required for target file F:\ogg\dirdat\nd000000,at RBA 0 (file not opened).

2012-08-1714:33:26  INFO    OGG-01478 Oracle GoldenGate Capture for Oracle, dpend.prm:  Output file F:\ogg\dirdat\nd is using formatRELEASE 11.2.

 

5.3 OGG-01224

啓動源端傳輸進程DPEND,ggserr.log錯誤顯示如下:

2012-08-2205:33:10  ERROR   OGG-01224 Oracle GoldenGate Capture for Oracle, dpend.prm:  TCP/IP error 113 (No route to host).

2012-08-2205:33:10  ERROR   OGG-01668 Oracle GoldenGate Capture for Oracle, dpend.prm:  PROCESS ABENDING.

導致原因:因爲目標端235上的防火牆沒有關閉,導致報錯

處理方法:

在目標端機器關閉防火牆後,再啓動源端的傳輸進程DPEND,錯誤消失,文件順利傳輸過來了。

5.4 OGG-01031

啓動源端傳輸進程DPEND,ggserr.log錯誤顯示如下:

2012-08-28 15:09:39  ERROR  OGG-01031  Oracle GoldenGateCapture for Oracle, dpend.prm:  There isa problem in network communication, a remote file problem, encryption keys fortarget and source do not match (if using ENCRYPT) or an unknown error. (Replyreceived is Unable to open file "/uo1/app/ogg/dirdat/nd000004" (error2, No such file or directory)).

2012-08-28 15:09:41  ERROR  OGG-01668  Oracle GoldenGateCapture for Oracle, dpend.prm:  PROCESSABENDING.目標端ggserr.log錯誤顯示如下:

2012-08-2815:06:30  WARNING OGG-01223  Oracle GoldenGate Collector for Oracle:  Unable to lock file"/uo1/app/ogg/dirdat/nd000004" (error 11, Resource temporarilyunavailable).  Lock currently held byprocess id (PID) 13854.

2012-08-2815:06:30  WARNING OGG-01223  Oracle GoldenGate Collector for Oracle:  Unable to open file"/uo1/app/ogg/dirdat/nd000004" (error 2, No such file or directory).

導致原因:可能是網絡出現過故障,OGG源端的Data Pump進程與目標斷了聯繫,目標端mgr爲其啓動的server進程一直還在運行,下次data pump重啓時目標mgr會試圖生成另外一個server進程,這樣兩個進程會爭同一個隊列文件。

處理方法:

1、停掉源端的所有data pump,使用ps –ef|grep server(或OGG安裝目錄)看看是不是還有OGG的server進程在跑,如果有,殺死它(一定要確認源端data pump全停掉,並且殺的是server進程,不要殺其它extract/replicat/mgr等),重啓源端data pump即可。

 

2、可能是目標端的trail file出問題了,前滾重新生成一個新的隊列文件

SEND EXTRACT xxx ETROLLOVER

或者:alter extract xxx etrollover

xxx爲datapump的名稱

 

5.5 OGG-01154

錯誤信息:2011-03-29 15:53:57  WARNINGOGG-01154  Oracle GoldenGate Delivery forOracle, repya.prm:  SQL error 14402mapping EPMA.D_METER to E

PMA.D_METER OCIError ORA-14402: updating partition key column would cause a partition change(status = 14402), SQL <UPDATE "EPMA"."D_METER" SET"PR_ORG" = :a1,"BELONG_DEPT" = :a2 WHERE"METER_ID" = :b0>.

導致原因:源端更新了分區列,但目標端沒有打開行移動,導致更新時報錯;

處理方法:SQLPLUS>alter table SCHEMA.TABLENAME enable row movement;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章