ITPub博客

首页 > 数据库 > Oracle > 11gRAC_SERVCER-SIDE_FAILOVER

11gRAC_SERVCER-SIDE_FAILOVER

原创 Oracle 作者:糖糖TJ 时间:2015-12-05 16:12:24 0 删除 编辑

RAC中实现FAILOVER的方式有三种,
Client-Side_Failover
TAF
Server-Side_Failover

好嘛,关于Failover另开文章再说。

Oracle10g版本中ASM、Service都可以通过dbca管理(简直不要太方便)
11g中另开GI(Grid Infastructure)软件,管理ASM
Service通过srvctl指令创建和管理。(10g中也可以通过该指令创建和管理Service,但是没有11g中的完善)

############测试步骤如下###########

点击(此处)折叠或打开

  1. 1.创建一个service
  2. srvctl add service -d orcl -s s1 -r orcl1 -a orcl2 -e session -m basic -w 10 -z 50
  3. ---数据库名orcl,service名s1,优选实例orcl1,备选实例orcl2,模式为session,basic,遇到故障每隔10s重新连接,重试50次
  4. 2.启动service
  5. srvctl start service -d orcl -s s1
  6. 3.在实例中查看service
  7. select SERVICE_ID,NAME,FAILOVER_METHOD,FAILOVER_TYPE,FAILOVER_RETRIES,FAILOVER_DELAY from dba_services where name ='s1';
  8. SERVICE_ID NAME FAILOVER_METHOD FAILOVER_TYPE FAILOVER_RETRIES FAILOVER_DELAY
  9. ---------- ------ --------------- --------------- ---------------- --------------

  10.          3 s1 BASIC SESSION 50 10
  11. 4.查看监听
  12. lsnrctl stat

  13. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-NOV-2015 15:33:31
  14. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  15. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  16. STATUS of the LISTENER
  17. ------------------------

  18. Alias LISTENER
  19. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  20. Start Date 28-NOV-2015 15:05:12
  21. Uptime 0 days 0 hr. 28 min. 18 sec
  22. Trace Level off
  23. Security ON: Local OS Authentication
  24. SNMP OFF
  25. Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
  26. Listener Log File /u01/app/grid/diag/tnslsnr/rac1/listener/alert/log.xml
  27. Listening Endpoints Summary...
  28.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  29.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.23.100)(PORT=1521)))
  30.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.23.10)(PORT=1521)))
  31. Services Summary...
  32. Service "+ASM" has 1 instance(s).
  33.   Instance "+ASM1", status READY, has 1 handler(s) for this service...
  34. Service "orcl" has 1 instance(s).
  35.   Instance "orcl1", status READY, has 1 handler(s) for this service...
  36. Service "orclXDB" has 1 instance(s).
  37.   Instance "orcl1", status READY, has 1 handler(s) for this service...
  38. Service "s1" has 1 instance(s).        ##########service s1优选实例1##########
  39.   Instance "orcl1", status READY, has 1 handler(s) for this service...
  40. The command completed successfully
  41. 5.两个节点参数查看
  42. ------节点1

  43. SQL> show parameter name
  44. NAME TYPE VALUE
  45. ------------------------------------ ----------- ------------------------------

  46. db_file_name_convert string
  47. db_name string orcl
  48. db_unique_name string orcl
  49. global_names boolean FALSE
  50. instance_name string orcl1
  51. lock_name_space string
  52. log_file_name_convert string
  53. processor_group_name string
  54. service_names string s1
  55. ------节点2

  56. SQL> show parameter name
  57. NAME TYPE VALUE
  58. ------------------------------------ ----------- ------------------------------

  59. db_file_name_convert string
  60. db_name string orcl
  61. db_unique_name string orcl
  62. global_names boolean FALSE
  63. instance_name string orcl2
  64. lock_name_space string
  65. log_file_name_convert string
  66. processor_group_name string
  67. service_names string orcl
  68. 6.tnsnames文件中对service的使用
  69. [oracle@rac2 admin]$ more tnsnames.ora
  70. # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1
  71. /network/admin/tnsnames.ora
  72. # Generated by Oracle configuration tools.
  73. ORCL_s =
  74.   (DESCRIPTION =
  75.     (ADDRESS = (PROTOCOL = TCP)(HOST = scan.example.com)(PORT = 1521))
  76.     (CONNECT_DATA =
  77.       (SERVER = DEDICATED)
  78.       (SERVICE_NAME = s1)
  79.     )
  80.   )
  81. 7.failover测试
  82. [oracle@rac2 admin]$ sqlplus scott/oracle@orcl_s
  83. SQL*Plus: Release 11.2.0.3.0 Production on Sat Nov 28 15:38:48 2015
  84. Copyright (c) 1982, 2011, Oracle. All rights reserved.

  85. Connected to:
  86. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
  87. With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
  88. Data Mining and Real Application Testing options
  89. SQL> select instance_name from v$instance;    ##########这里对scott授了dba权限##########
  90. INSTANCE_NAME
  91. ----------------

  92. orcl1
  93. SQL> select * from dba_objects;
  94. .........
  95. -----------select语句执行中-----------

  96. 在其他终端shutdown abort实例1
  97. SQL> shutdown abort;
  98. ORACLE instance shut down.
  99. -----------select语句执行中-----------

  100. .........
  101. ------------------------------

  102. 18-SEP-11 18-SEP-11 2011-09-18:17:39:06 VALID N N N 1

  103. ERROR:
  104. ORA-25401: can not continue fetches    ##########因为参数设置为session而非select##########

  105. 12780 rows selected.
  106. SQL> select instance_name from v$instance;

  107. INSTANCE_NAME
    ----------------
    orcl2

     成功failover到节点2。
     另外需要注意:  
     SYSDBA Sessions Do Not Failover with SRVCTL TAF Configured。
     不能使用SYSDBA

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29781254/viewspace-1854033/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-08-01

  • 博文量
    27
  • 访问量
    40170