GoldenGate如今是業內成熟的數據容災與複製產品,通過多年的發展與完善,如今已經成爲業內事實上的標準之一。 node
GoldenGate軟件是一種基於日誌的結構化數據複製軟件,它經過解析源數據庫在線日誌或歸檔日誌得到數據的增刪改變化,再將這些變化應用到目標數據庫,實現源數據庫與目標數據庫同步。 linux
GoldenGate軟件的技術結構如圖1.1所示: sql
圖1.1GoldenGate技術架構圖 數據庫
從圖中能夠看到:GoldenGate主要包含Manager進程、Extract進程、Pump進程、Replicat進程,下面對其一一說明: 網絡
Manager進程是GoldenGate的控制進程,它主要做用有如下幾個方面:啓動、監控、重啓GoldenGate的其餘進程,報告錯誤及時間,分配數據存儲空間,發佈閥值報告等。 antd
Extract進程運行在數據庫源端,負責從源端數據表或日誌中捕獲數據。Extract進程利用其內在的checkpoint機制,週期性地檢查並記錄其讀寫的位置,一般是寫入到本地的trail文件。這種機制是爲了保證若是Extract進程終止或者操做系統宕機,咱們重啓Extract進程後,GoldenGate可以恢復到之前的狀態,從上一個斷點處繼續往下運行,而不會有任何數據損失。 數據結構
Pump進程運行在數據庫源端,其做用很是簡單。若是源端使用了本地trail文件,那麼Pump進程就會把Trail文件以數據塊的形式經過TCP/IP協議發送到目標端,咱們下面的配置都是這種方式。Pump進程本質是Extract進程的一種特殊形式,若是不使用Trail文件,那麼Extract進程在抽取完數據後,直接投遞到目標端。 架構
與Pump進程相對應的叫Server Collector進程,這個進程不須要引發咱們關注,由於在實際操做過程當中無需對其進行任何配置,它運行在目標端,任務就是把Extract/Pump進程投遞過來的數據塊從新組裝成Trail文件。 oracle
Replicat進程運行在目標端,是數據投遞的最後一站,負責讀取目標端Trail文件中的內容,並將解析其解析爲DML或DDL語句,而後應用到目標數據庫中。 app
GoldenGate提供了靈活的應用方案,基於其先進、靈活的技術架構能夠根據用戶需求組成各類拓撲結構,如圖1.2所示:
圖1.2GoldenGate應用方案示意圖
根據實際需求狀況,咱們須要進行的是一對一複製,且只是複製部分表數據,因此這裏僅探討一對一複製的安裝配置,並且對於DDL複製的支持這裏也不作研究。
性質 |
IP |
系統 |
ORACLE版本 |
源端 |
10.122.0.110 |
AIX 5.3 |
10.2.0.1 |
目標端 |
10.122.0.113 |
WINDOWS 2003 |
10.2.0.1 |
建立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
注意:添加後需使參數文件生效
HP及LINUX平臺下用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
創建OGG安裝目錄,而後將壓縮包解壓到目錄中,進入cmd控制檯,建立工做目錄,
操做步驟顯示以下:
數據庫模式配置
源端數據庫必須開啓歸檔模式
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.
配置管理進程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個可用端口的動態列表,當指定的端口不可用時,管理進程將會從列表中選擇一個可用的端口,源端和目標段的Collector、Replicat、GGSCI進程通訊也會使用這些端口;
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小時的進行警告;
目標庫建立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
配置管理進程
配置複製進程
REPLICAT進程參數配置說明:
ASSUMETARGETDEFS:假定兩端數據結構一導致用此參數;
SOURCEDEFS:假定兩端數據結構不一致,使用此參數指定源端的數據結構定義文件,該文件須要由GlodenGate工具產生。
MAP:用於指定源端與目標端表的映射關係;
MAPEXCLUDE:用於使用在MAP中使用*匹配時排除掉指定的表;
REPERROR:定義出錯之後進程的響應,通常能夠定義爲兩種:
ABEND,即一旦出現錯誤即中止複製,此爲缺省配置;
DISCARD,出現錯誤後繼續複製,只是把錯誤的數據放到discard文件中。
DISCARDFILE:定義discardfile文件位置,若是處理中油記錄出錯會寫入到此文件中;
SQLEXEC:在進程運行時首先運行一個SQL語句;
GROUPTRANSOPS:將小交易合併成一個大的交易進行提交,減小提交次數,下降系統IO消耗。
MAXTRANSOPS:將大交易拆分,每XX條記錄提交一次。
啓動源端進程組
啓動抽取進程和傳輸進程:
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的安裝配置就完成了,能夠進行數據同步測試了。
性質 |
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 |
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
在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
環境相同,安裝方法與4.3一致,僅僅是安裝位置不一樣,安裝過程略,注意安裝包與平臺一致。
數據庫模式配置
源端數據庫必須開啓歸檔模式
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.
配置管理進程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;
注意:threads與RAC節點數相同便可,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;
目標庫建立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.
配置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.*;
啓動源端進程組
啓動抽取進程和傳輸進程:
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à單機的配置僅僅完成了數據複製的功能,不包含高可用的配置,當運行GoldenGate的節點出現故障時複製功能就將終止,如何使複製功能繼續可用呢,有以下兩種方式:
由於GoldenGate 安裝在共享目錄下,咱們能夠經過任一個節點鏈接到共享目錄,啓動GoldenGate運行界面。若是其中一個節點失敗,致使GoldenGate進程停止,能夠直接手工在另一個節點啓動進程組便可。
咱們能夠經過使用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節點運行了。
啓動源端抽取進程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;
啓動源端傳輸進程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.
啓動源端傳輸進程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,錯誤消失,文件順利傳輸過來了。
啓動源端傳輸進程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進程,這樣兩個進程會爭同一個隊列文件。
處理方法:
一、停掉源端的全部data pump,使用ps –ef|grep server(或OGG安裝目錄)看看是否是還有OGG的server進程在跑,若是有,殺死它(必定要確認源端data pump全停掉,而且殺的是server進程,不要殺其它extract/replicat/mgr等),重啓源端data pump便可。
二、多是目標端的trail file出問題了,前滾從新生成一個新的隊列文件
SEND EXTRACT xxx ETROLLOVER
或者:alter extract xxx etrollover
xxx爲datapump的名稱
錯誤信息: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;