RAC环境下管理OGG-HA


在本文中将介绍在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属于正常情况!

  1. [root@rac1 bin]# ./crs_stat -t -v  
  2. Name           Type           R/RA   F/FT   Target    State     Host          
  3. ----------------------------------------------------------------------  
  4. ora.ACFS.dg    ora....up.type 0/5    0/     ONLINE    ONLINE    rac1          
  5. ora.CRS.dg     ora....up.type 0/5    0/     ONLINE    ONLINE    rac1          
  6. ora.DATA.dg    ora....up.type 0/5    0/     ONLINE    ONLINE    rac1          
  7. ora.FRA.dg     ora....up.type 0/5    0/     ONLINE    ONLINE    rac1          
  8. ora....ER.lsnr ora....er.type 0/5    0/     ONLINE    ONLINE    rac1          
  9. ora....N1.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    rac2          
  10. ora....N2.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    rac1          
  11. ora....N3.lsnr ora....er.type 0/5    0/0    ONLINE    ONLINE    rac1          
  12. ora.asm        ora.asm.type   0/5    0/     ONLINE    ONLINE    rac1          
  13. ora.cvu        ora.cvu.type   0/5    0/0    ONLINE    ONLINE    rac1          
  14. ora.gsd        ora.gsd.type   0/5    0/     OFFLINE   OFFLINE                 
  15. ora....network ora....rk.type 1/5    0/     ONLINE    ONLINE    rac1          
  16. ora.oc4j       ora.oc4j.type  0/1    0/2    ONLINE    ONLINE    rac1          
  17. ora.ons        ora.ons.type   0/3    0/     ONLINE    ONLINE    rac1          
  18. ora.rac.db     ora....se.type 0/1    0/1    ONLINE    ONLINE    rac1          
  19. ora....SM1.asm application    0/5    0/0    ONLINE    ONLINE    rac1          
  20. ora....C1.lsnr application    0/5    0/0    ONLINE    ONLINE    rac1          
  21. ora.rac1.gsd   application    0/5    0/0    OFFLINE   OFFLINE                 
  22. ora.rac1.ons   application    0/3    0/0    ONLINE    ONLINE    rac1          
  23. ora.rac1.vip   ora....t1.type 0/0    0/0    ONLINE    ONLINE    rac1          
  24. ora....SM2.asm application    0/5    0/0    ONLINE    ONLINE    rac2          
  25. ora....C2.lsnr application    0/5    0/0    ONLINE    ONLINE    rac2          
  26. ora.rac2.gsd   application    0/5    0/0    OFFLINE   OFFLINE                 
  27. ora.rac2.ons   application    0/3    0/0    ONLINE    ONLINE    rac2          
  28. ora.rac2.vip   ora....t1.type 0/0    0/0    ONLINE    ONLINE    rac2          
  29. ora....ry.acfs ora....fs.type 0/5    0/     ONLINE    ONLINE    rac1          
  30. ora.scan1.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    rac2          
  31. ora.scan2.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    rac1          
  32. ora.scan3.vip  ora....ip.type 0/0    0/0    ONLINE    ONLINE    rac1   

二:在source端添加VIP,并赋权限,检查vip是否能正常启动,在本例中运行grid infrastructure的操作系统用户为grid,运行ogg的操作系统用户为oracle

  1. [root@rac1 bin]# ./crsctl stat res -p |grep -ie .network -ie subnet |grep -ie name -ie subnet  
  2. NAME=ora.net1.network  
  3. USR_ORA_SUBNET=192.168.1.0  
  4.  
  5. [root@rac1 bin]# ./appvipcfg create -network=1 \  
  6. -ip=192.168.1.150 \  
  7. -vipname=oggvip \  
  8. -user=root 
  9.  
  10. [root@rac1 bin]# ./crsctl setperm resource oggvip -u user:oracle:r-x  
  11. [root@rac1 bin]# ./crsctl status resource oggvip  
  12. NAME=oggvip 
  13. TYPE=app.appvip_net1.type  
  14. TARGET=OFFLINE 
  15. STATE=OFFLINE 
  16.  
  17. [root@rac1 bin]# ./crsctl start resource oggvip  
  18. CRS-2672: Attempting to start 'oggvip' on 'rac1'  
  19. CRS-2676: Start of 'oggvip' on 'rac1' succeeded  
  20. [root@rac1 bin]# ip a |grep 192.168.1.150  
  21.     inet 192.168.1.150/24 brd 192.168.1.255 scope global secondary eth0:2  
  22. [root@rac1 bin]# ./crsctl status resource oggvip  
  23. NAME=oggvip 
  24. TYPE=app.appvip_net1.type  
  25. TARGET=ONLINE 
  26. STATE=ONLINE on rac1 

三:配置action脚本,该脚本必须包含start,stop,check,clean,abort几个函数,才能用于后续的grid infrastructure调用,这里把脚本直接放在acfs文件系统上,以便节点间共享

  1. [root@rac1 bin]# chmod +x /vol2/ogg/11gr2_ogg_action.scr   
  2. [root@rac1 bin]# ll /vol2/ogg/11gr2_ogg_action.scr   
  3. -rwxr-xr-x 1 oracle oinstall 2483 Jul 17 21:01 /vol2/ogg/11gr2_ogg_action.scr  
  4.  
  5. [root@rac1 bin]# cat /vol2/ogg/11gr2_ogg_action.scr   
  6. #!/bin/sh  
  7. #set the Oracle Goldengate installation directory  
  8. export GGS_HOME=/vol2/ogg  
  9. #set the oracle home to the database to ensure GoldenGate will get the  
  10. #right environment settings to be able to connect to the database  
  11. export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db1  
  12. #specify delay after start before checking for successful start  
  13. start_delay_secs=5 
  14. #Include the GoldenGate home in the library path to start GGSCI  
  15. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:${GGS_HOME}:${LD_LIBRARY_PATH}  
  16. #check_process validates that a manager process is running at the PID  
  17. #that GoldenGate specifies.  
  18.    
  19. check_process () {  
  20. if ( [ -f "${GGS_HOME}/dirpcs/MGR.pcm" ] )  
  21. then  
  22.   pid=`cut -f8 "${GGS_HOME}/dirpcs/MGR.pcm"`  
  23.   if [ ${pid} = `ps -e |grep ${pid} |grep mgr |cut -d " " -f2` ]  
  24.   then  
  25.     #manager process is running on the PID exit success  
  26.     exit 0  
  27.   else  
  28.   if [ ${pid} = `ps -e |grep ${pid} |grep mgr |cut -d " " -f1` ]  
  29.   then  
  30.     #manager process is running on the PID exit success  
  31.     exit 0  
  32.   else  
  33.     #manager process is not running on the PID  
  34.     exit 1  
  35.   fi  
  36. fi  
  37. else  
  38.   #manager is not running because there is no PID file  
  39.   exit 1  
  40. fi  
  41. }  
  42.    
  43. #call_ggsci is a generic routine that executes a ggsci command  
  44. call_ggsci () {  
  45.   ggsci_command=$1  
  46.   ggsci_output=`${GGS_HOME}/ggsci<<EOF 
  47.   ${ggsci_command}  
  48.   exit  
  49.   EOF`  
  50. }  
  51.    
  52. case $1 in  
  53. 'start')  
  54.   #start manager  
  55.   call_ggsci 'start manager'  
  56.   #there is a small delay between issuing the start manager command  
  57.   #and the process being spawned on the OS. wait before checking  
  58.   sleep ${start_delay_secs}  
  59.   #check whether manager is running and exit accordingly  
  60.   check_process  
  61.   ;;  
  62. 'stop')  
  63.   #attempt a clean stop for all non-manager processes  
  64.   #call_ggsci 'stop er *'  
  65.   #ensure everything is stopped  
  66.   call_ggsci 'stop er *!'  
  67.   #call_ggsci 'kill er *'  
  68.   #stop manager without (y/n) confirmation  
  69.   call_ggsci 'stop manager!'  
  70.   #exit success  
  71.   exit 0  
  72.   ;;  
  73. 'check')  
  74.   check_process  
  75.   ;;  
  76. 'clean')  
  77.   #attempt a clean stop for all non-manager processes  
  78.   #call_ggsci 'stop er *'  
  79.   #ensure everything is stopped  
  80.   #call_ggsci 'stop er *!'  
  81.   #in case there are lingering processes  
  82.   call_ggsci 'kill er *'  
  83.   #stop manager without (y/n) confirmation  
  84.   call_ggsci 'stop manager!'  
  85.   #exit success  
  86.   exit 0  
  87.   ;;  
  88. 'abort')  
  89.   #ensure everything is stopped  
  90.   call_ggsci 'stop er *!'  
  91.   #in case there are lingering processes  
  92.   call_ggsci 'kill er *'  
  93.   #stop manager without (y/n) confirmation  
  94.   call_ggsci 'stop manager!'  
  95.   #exit success  
  96.   exit 0  
  97.   ;;  
  98. esac 
  • 1
  • 2
  • 下一页

相关内容