在本文中將介紹在oracle 11g r2 rac環境下使用grid infrastructure來管理ogg服務,在開始以前,請先按照前文的步驟配置好rac(source)同單實例(target)數據庫之間的ogg單向同步,同時確保rac數據庫各項服務運行正常,同時啓動target端的數據庫實例和ogg的mgr,replicat進程,source端ogg的mgr,extract,extract dump進程能夠關閉!html
一:查看rac各服務是否online,這裏3個gsd服務offline屬於正常狀況!sql
- [root@rac1 bin]# ./crs_stat -t -v
- Name Type R/RA F/FT Target State Host
- ----------------------------------------------------------------------
- ora.ACFS.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
- ora.CRS.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
- ora.DATA.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
- ora.FRA.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
- ora....ER.lsnr ora....er.type 0/5 0/ ONLINE ONLINE rac1
- ora....N1.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac2
- ora....N2.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac1
- ora....N3.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac1
- ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE rac1
- ora.cvu ora.cvu.type 0/5 0/0 ONLINE ONLINE rac1
- ora.gsd ora.gsd.type 0/5 0/ OFFLINE OFFLINE
- ora....network ora....rk.type 1/5 0/ ONLINE ONLINE rac1
- ora.oc4j ora.oc4j.type 0/1 0/2 ONLINE ONLINE rac1
- ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE rac1
- ora.rac.db ora....se.type 0/1 0/1 ONLINE ONLINE rac1
- ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
- ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
- ora.rac1.gsd application 0/5 0/0 OFFLINE OFFLINE
- ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
- ora.rac1.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac1
- ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
- ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
- ora.rac2.gsd application 0/5 0/0 OFFLINE OFFLINE
- ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
- ora.rac2.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac2
- ora....ry.acfs ora....fs.type 0/5 0/ ONLINE ONLINE rac1
- ora.scan1.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac2
- ora.scan2.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac1
- ora.scan3.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac1
二:在source端添加VIP,並賦權限,檢查vip是否能正常啓動,在本例中運行grid infrastructure的操做系統用戶爲grid,運行ogg的操做系統用戶爲oracle數據庫
- [root@rac1 bin]# ./crsctl stat res -p |grep -ie .network -ie subnet |grep -ie name -ie subnet
- NAME=ora.net1.network
- USR_ORA_SUBNET=192.168.1.0
- [root@rac1 bin]# ./appvipcfg create -network=1 \
- -ip=192.168.1.150 \
- -vipname=oggvip \
- -user=root
- [root@rac1 bin]# ./crsctl setperm resource oggvip -u user:oracle:r-x
- [root@rac1 bin]# ./crsctl status resource oggvip
- NAME=oggvip
- TYPE=app.appvip_net1.type
- TARGET=OFFLINE
- STATE=OFFLINE
- [root@rac1 bin]# ./crsctl start resource oggvip
- CRS-2672: Attempting to start 'oggvip' on 'rac1'
- CRS-2676: Start of 'oggvip' on 'rac1' succeeded
- [root@rac1 bin]# ip a |grep 192.168.1.150
- inet 192.168.1.150/24 brd 192.168.1.255 scope global secondary eth0:2
- [root@rac1 bin]# ./crsctl status resource oggvip
- NAME=oggvip
- TYPE=app.appvip_net1.type
- TARGET=ONLINE
- STATE=ONLINE on rac1
三:配置action腳本,該腳本必須包含start,stop,check,clean,abort幾個函數,才能用於後續的grid infrastructure調用,這裏把腳本直接放在acfs文件系統上,以便節點間共享oracle
- [root@rac1 bin]# chmod +x /vol2/ogg/11gr2_ogg_action.scr
- [root@rac1 bin]# ll /vol2/ogg/11gr2_ogg_action.scr
- -rwxr-xr-x 1 oracle oinstall 2483 Jul 17 21:01 /vol2/ogg/11gr2_ogg_action.scr
- [root@rac1 bin]# cat /vol2/ogg/11gr2_ogg_action.scr
- #!/bin/sh
- #set the Oracle Goldengate installation directory
- export GGS_HOME=/vol2/ogg
- #set the oracle home to the database to ensure GoldenGate will get the
- #right environment settings to be able to connect to the database
- export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db1
- #specify delay after start before checking for successful start
- start_delay_secs=5
- #Include the GoldenGate home in the library path to start GGSCI
- export LD_LIBRARY_PATH=$ORACLE_HOME/lib:${GGS_HOME}:${LD_LIBRARY_PATH}
- #check_process validates that a manager process is running at the PID
- #that GoldenGate 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 exit success
- exit 0
- else
- if [ ${pid} = `ps -e |grep ${pid} |grep mgr |cut -d " " -f1` ]
- then
- #manager process is running on the PID exit success
- exit 0
- else
- #manager process is not running on the PID
- exit 1
- fi
- fi
- else
- #manager is not running because there is no PID file
- exit 1
- fi
- }
- #call_ggsci is a 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 the start manager command
- #and the process being spawned on the OS. wait before checking
- sleep ${start_delay_secs}
- #check whether manager is running and exit accordingly
- check_process
- ;;
- 'stop')
- #attempt a clean stop for all non-manager processes
- #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-manager processes
- #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
四:使用oracle用戶添加oggapp,並受權給oracle用戶管理app
- [oracle@rac1 ~]$ crsctl add resource oggapp -type cluster_resource \
- -attr "ACTION_SCRIPT=/vol2/ogg/11gr2_ogg_action.scr, \
- CHECK_INTERVAL=30, START_DEPENDENCIES='hard(oggvip,ora.asm) \
- pullup(oggvip)', STOP_DEPENDENCIES='hard(oggvip)'"
- [oracle@rac1 ~]$ crsctl status resource oggapp
- NAME=oggapp
- TYPE=cluster_resource
- TARGET=OFFLINE
- STATE=OFFLINE
- [root@rac1 bin]# pwd
- /u01/app/11.2.0/grid/bin
- [root@rac1 bin]# ./crsctl setperm resource oggapp -o oracle
五:檢查target端的數據庫是否能夠正常鏈接,ogg進程是否運行正常ide
- [root@dg3 ~]# su - oracle
- [oracle@dg3 ~]$ sqlplus test/test
- SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 18 20:41:13 2012
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- SQL> exit
- [oracle@dg3 ~]$ cd /u01/app/oracle/ogg/
- [oracle@dg3 ogg]$ ./ggsci
- Oracle GoldenGate Command Interpreter for Oracle
- Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
- Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
- Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
- GGSCI (dg3.yang.com) 1> info all
- Program Status Group Lag at Chkpt Time Since Chkpt
- MANAGER RUNNING
- REPLICAT RUNNING TESTRPT 00:00:00 00:00:03
- GGSCI (dg3.yang.com) 2> exit
六:檢查source端的數據庫是否能夠正常鏈接,ogg進程未啓動函數
- [root@rac1 ~]# su - oracle
- [oracle@rac1 ~]$ sqlplus test/test@rac
- SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 18 20:42:40 2012
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
- With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle
- Label Security,
- OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
- SQL> select * from tab;
- TNAME TABTYPE CLUSTERID
- ------------------------------ ------- ----------
- T1 TABLE
- SQL> exit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit
- Production
- With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle
- Label Security,
- OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
- [oracle@rac1 ~]$ cd /vol2/ogg/
- [oracle@rac1 ogg]$ ./ggsci
- Oracle GoldenGate Command Interpreter for Oracle
- Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
- Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
- Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
- GGSCI (rac1.yang.com) 1> info all
- Program Status Group Lag at Chkpt Time Since Chkpt
- MANAGER STOPPED
- EXTRACT ABENDED TESTEXT 00:00:00 22:54:53
- EXTRACT ABENDED TESTPUMP 00:00:00 22:55:41
七:使用oracle用戶啓動oggapp resource,檢查source(rac1)上的ogg進程是否成功啓動測試
- [oracle@rac1 ~]$ crsctl status resource oggapp
- NAME=oggapp
- TYPE=cluster_resource
- TARGET=OFFLINE
- STATE=OFFLINE
- [oracle@rac1 ~]$ crsctl start resource oggapp
- CRS-2672: Attempting to start 'oggapp' on 'rac1'
- CRS-2676: Start of 'oggapp' on 'rac1' succeeded
- [oracle@rac1 ~]$ cd /vol2/ogg/
- [oracle@rac1 ogg]$ ./ggsci
- Oracle GoldenGate Command Interpreter for Oracle
- Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
- Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
- Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
- GGSCI (rac1.yang.com) 1> info all
- Program Status Group Lag at Chkpt Time Since Chkpt
- MANAGER RUNNING
- EXTRACT RUNNING TESTEXT 00:00:00 00:00:07
- EXTRACT RUNNING TESTPUMP 00:00:00 23:18:23
- [oracle@rac1 ~]$ crs_stat -t -v oggapp
- Name Type R/RA F/FT Target State Host
- ----------------------------------------------------------------------
- oggapp clus...esource 0/1 0/0 ONLINE ONLINE rac1
八:測試failoverui
- [oracle@rac1 ~]$ crsctl relocate resource oggapp -f
- CRS-2673: Attempting to stop 'oggapp' on 'rac1'
- CRS-2677: Stop of 'oggapp' on 'rac1' succeeded
- CRS-2673: Attempting to stop 'oggvip' on 'rac1'
- CRS-2677: Stop of 'oggvip' on 'rac1' succeeded
- CRS-2672: Attempting to start 'oggvip' on 'rac2'
- CRS-2676: Start of 'oggvip' on 'rac2' succeeded
- CRS-2672: Attempting to start 'oggapp' on 'rac2'
- CRS-2676: Start of 'oggapp' on 'rac2' succeeded
- [oracle@rac1 ~]$ crs_stat -t -v oggapp
- Name Type R/RA F/FT Target State Host
- ----------------------------------------------------------------------
- oggapp clus...esource 0/1 0/0 ONLINE ONLINE rac2
- [root@rac2 ~]# su - oracle
- [oracle@rac2 ~]$ cd /vol2/ogg/
- [oracle@rac2 ogg]$ ./ggsci
- Oracle GoldenGate Command Interpreter for Oracle
- Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
- Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
- Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
- GGSCI (rac2.yang.com) 1> info all
- Program Status Group Lag at Chkpt Time Since Chkpt
- MANAGER RUNNING
- EXTRACT RUNNING TESTEXT 00:00:00 00:00:05
- EXTRACT ABENDED TESTPUMP 00:00:00 23:24:30
九:排錯與中止oggapp服務,view report testpump查看日誌報錯以下spa
2012-07-18 21:05:59 ERROR OGG-01031 There is a problem in network communication, a remote file problem, encryption keys for target and source do not match (if using ENCRYPT) or an unknown error.(Reply received is Unable to open file "/vol2/ogg/dirdat/rt000001" (error 11, Resource temporarily unavailable)).
2012-07-18 21:05:59 ERROR OGG-01668 PROCESS ABENDING.
GGSCI (rac2.yang.com) 15> alter extract testpump etrollover
2012-07-18 21:20:40 INFO OGG-01520 Rollover performed. For each affected output trail of Version 10 or higher format, after starting the source extract, issue ALTER EXTSEQNO for that trail's reader (either pump EXTRACT or REPLICAT) to move the reader's scan to the new trail file; it will not happen automatically.
EXTRACT altered.
GGSCI (rac2.yang.com) 18> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING TESTEXT 00:00:00 00:00:00
EXTRACT RUNNING TESTPUMP 00:00:00 00:00:10
[oracle@rac2 ogg]$ crsctl stop resource oggapp
CRS-2673: Attempting to stop 'oggapp' on 'rac2'
CRS-2677: Stop of 'oggapp' on 'rac2' succeeded
[oracle@rac2 ogg]$ crsctl status resource oggapp
NAME=oggapp
TYPE=cluster_resource
TARGET=OFFLINE
STATE=OFFLINE
若是中止使用grid infrastructure來管理ogg進程,只須要使用crsctl命令刪除oggapp和oggvip服務便可!須要值得注意的是,若是使用grid infrastructure來管理ogg,則mgr進程的參數文件中必需要配置autostart和autorestart選項!參考文檔:(感謝做者分享)
http://blog.sina.com.cn/s/blog_6f1123420100qgl8.html
http://www.rickyzhu.com/2311_config-ha-goldengate.html
http://www.oracle.com/technetwork/middleware/goldengate/overview/ha-goldengate-whitepaper-128197.pdf