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 

四:使用oracle用户添加oggapp,并授权给oracle用户管理

 
  1. [oracle@rac1 ~]$ crsctl add resource oggapp -type cluster_resource \  
  2. -attr "ACTION_SCRIPT=/vol2/ogg/11gr2_ogg_action.scr, \  
  3. CHECK_INTERVAL=30START_DEPENDENCIES='hard(oggvip,ora.asm) \  
  4. pullup(oggvip)', STOP_DEPENDENCIES='hard(oggvip)'"  
  5.  
  6. [oracle@rac1 ~]$ crsctl status resource oggapp  
  7. NAME=oggapp 
  8. TYPE=cluster_resource 
  9. TARGET=OFFLINE 
  10. STATE=OFFLINE 
  11.  
  12. [root@rac1 bin]# pwd  
  13. /u01/app/11.2.0/grid/bin  
  14. [root@rac1 bin]# ./crsctl setperm resource oggapp -o oracle 

五:检查target端的数据库是否可以正常连接,ogg进程是否运行正常

 
  1. [root@dg3 ~]# su - oracle  
  2. [oracle@dg3 ~]$ sqlplus test/test  
  3. SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 18 20:41:13 2012  
  4. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  5.  
  6. Connected to:  
  7. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production  
  8. With the Partitioning, OLAP, Data Mining and Real Application Testing options  
  9.  
  10. SQL> exit  
  11.  
  12. [oracle@dg3 ~]$ cd /u01/app/oracle/ogg/  
  13. [oracle@dg3 ogg]$ ./ggsci  
  14.  
  15. Oracle GoldenGate Command Interpreter for Oracle  
  16. Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO  
  17. Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14  
  18. Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.  
  19.  
  20. GGSCI (dg3.yang.com) 1> info all  
  21.  
  22. Program     Status      Group       Lag at Chkpt  Time Since Chkpt  
  23. MANAGER     RUNNING                                             
  24. REPLICAT    RUNNING     TESTRPT     00:00:00      00:00:03      
  25.  
  26. GGSCI (dg3.yang.com) 2> exit 

六:检查source端的数据库是否可以正常连接,ogg进程未启动

 
  1. [root@rac1 ~]# su - oracle  
  2. [oracle@rac1 ~]$ sqlplus test/test@rac  
  3. SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 18 20:42:40 2012  
  4. Copyright (c) 1982, 2011, Oracle.  All rights reserved.  
  5.  
  6. Connected to:  
  7. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production  
  8. With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle   
  9.  
  10. Label Security,  
  11. OLAP, Data Mining, Oracle Database Vault and Real Application Testing options  
  12.  
  13. SQL> select * from tab;  
  14.  
  15. TNAME                          TABTYPE  CLUSTERID  
  16. ------------------------------ ------- ----------  
  17. T1                             TABLE  
  18.  
  19. SQL> exit  
  20. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit   
  21.  
  22. Production  
  23. With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle   
  24.  
  25. Label Security,  
  26. OLAP, Data Mining, Oracle Database Vault and Real Application Testing options  
  27.  
  28. [oracle@rac1 ~]$ cd /vol2/ogg/  
  29. [oracle@rac1 ogg]$ ./ggsci  
  30. Oracle GoldenGate Command Interpreter for Oracle  
  31. Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO  
  32. Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14  
  33. Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.  
  34.  
  35. GGSCI (rac1.yang.com) 1> info all  
  36.  
  37. Program     Status      Group       Lag at Chkpt  Time Since Chkpt  
  38. MANAGER     STOPPED                                             
  39. EXTRACT     ABENDED     TESTEXT     00:00:00      22:54:53      
  40. EXTRACT     ABENDED     TESTPUMP    00:00:00      22:55:41     

七:使用oracle用户启动oggapp resource,检查source(rac1)上的ogg进程是否成功启动

 
  1. [oracle@rac1 ~]$ crsctl status resource oggapp  
  2. NAME=oggapp 
  3. TYPE=cluster_resource 
  4. TARGET=OFFLINE 
  5. STATE=OFFLINE 
  6.  
  7. [oracle@rac1 ~]$ crsctl start resource oggapp  
  8. CRS-2672: Attempting to start 'oggapp' on 'rac1'  
  9. CRS-2676: Start of 'oggapp' on 'rac1' succeeded  
  10.  
  11. [oracle@rac1 ~]$ cd /vol2/ogg/  
  12. [oracle@rac1 ogg]$ ./ggsci   
  13. Oracle GoldenGate Command Interpreter for Oracle  
  14. Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO  
  15. Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14  
  16. Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.  
  17.  
  18. GGSCI (rac1.yang.com) 1> info all  
  19.  
  20. Program     Status      Group       Lag at Chkpt  Time Since Chkpt  
  21. MANAGER     RUNNING                                             
  22. EXTRACT     RUNNING     TESTEXT     00:00:00      00:00:07      
  23. EXTRACT     RUNNING     TESTPUMP    00:00:00      23:18:23     
  24.  
  25. [oracle@rac1 ~]$ crs_stat -t -v oggapp  
  26. Name           Type           R/RA   F/FT   Target    State     Host          
  27. ----------------------------------------------------------------------  
  28. oggapp         clus...esource 0/1    0/0    ONLINE    ONLINE    rac1   

八:测试failover

 
  1. [oracle@rac1 ~]$ crsctl relocate resource oggapp -f  
  2. CRS-2673: Attempting to stop 'oggapp' on 'rac1'  
  3. CRS-2677: Stop of 'oggapp' on 'rac1' succeeded  
  4. CRS-2673: Attempting to stop 'oggvip' on 'rac1'  
  5. CRS-2677: Stop of 'oggvip' on 'rac1' succeeded  
  6. CRS-2672: Attempting to start 'oggvip' on 'rac2'  
  7. CRS-2676: Start of 'oggvip' on 'rac2' succeeded  
  8. CRS-2672: Attempting to start 'oggapp' on 'rac2'  
  9. CRS-2676: Start of 'oggapp' on 'rac2' succeeded  
  10. [oracle@rac1 ~]$ crs_stat -t -v oggapp  
  11. Name           Type           R/RA   F/FT   Target    State     Host          
  12. ----------------------------------------------------------------------  
  13. oggapp         clus...esource 0/1    0/0    ONLINE    ONLINE    rac2     
  14.  
  15. [root@rac2 ~]# su - oracle  
  16. [oracle@rac2 ~]$ cd /vol2/ogg/  
  17. [oracle@rac2 ogg]$ ./ggsci   
  18.  
  19. Oracle GoldenGate Command Interpreter for Oracle  
  20. Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO  
  21. Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14  
  22. Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.  
  23.  
  24. GGSCI (rac2.yang.com) 1> info all  
  25. Program     Status      Group       Lag at Chkpt  Time Since Chkpt  
  26.  
  27. MANAGER     RUNNING                                             
  28. EXTRACT     RUNNING     TESTEXT     00:00:00      00:00:05      
  29. 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

相关文章
|
8月前
|
Oracle Java 关系型数据库
RAC 环境中 gc block lost 和私网通信性能问题的诊断
对于每个节点,以及集群汇总统计信息中的global cache数据块丢失的统计信息("gc cr block lost" 和/或 "gc current block lost") 代表了私网通信的包处理效率低或者包的处理存在异常。
200 0
|
11月前
|
存储 Oracle 关系型数据库
|
存储 文字识别 Oracle
RAC日常管理(10G)
RAC日常管理(10G)
110 0
RAC日常管理(10G)
|
数据库
Oracle11G RAC日常管理,史上最全
Oracle11G RAC日常管理,史上最全
190 0
Oracle11G RAC日常管理,史上最全
|
存储 数据库 Linux
|
Oracle 关系型数据库 数据库