在本文中将介绍在oracle 11g r2 rac环境下使用grid infrastructure来管理ogg服务,在开始之前,请先按照前文的步骤配置好rac(source)同单实例(target)数据库之间的ogg单向同步,同时确保rac数据库各项服务运行正常,同时启动target端的数据库实例和ogg的mgr,replicat进程,source端ogg的mgr,extract,extract dump进程可以关闭!
一:查看rac各服务是否online,这里3个gsd服务offline属于正常情况!
- [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文件系统上,以便节点间共享
- [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用户管理
- [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进程是否运行正常
- [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
八:测试failover
- [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查看日志报错如下
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
本文转自斩月博客51CTO博客,原文链接http://blog.51cto.com/ylw6006/934965如需转载请自行联系原作者
ylw6006