1- 添加一个名为server_taf的services,用做TAF

 
  
  1. [oracle@node01 bin]$ pwd 
  2. /u01/app/11.2.0/grid/bin 
  3. [oracle@node01 bin]$ ./srvctl add service -d racdb -s server_taf -r “racdb1,racdb2″ -P BASIC 

2- 启动server_taf服务

 
  
  1. [oracle@node01 bin]$ ./srvctl start service -d racdb -s server_taf 

 

3- 检查server_taf是否启动

 
  
  1. [oracle@node01 bin]$ ./srvctl config service -d racdb 
  2. Service name: server_taf 
  3. Service is enabled 
  4. Server pool: racdb_server_taf 
  5. Cardinality: 2 
  6. Disconnect: false 
  7. Service role: PRIMARY 
  8. Management policy: AUTOMATIC 
  9. DTP transaction: false 
  10. AQ HA notifications: false 
  11. Failover type: NONE 
  12. Failover method: NONE 
  13. TAF failover retries: 0 
  14. TAF failover delay: 0 
  15. Connection Load Balancing Goal: LONG 
  16. Runtime Load Balancing Goal: NONE 
  17. TAF policy specification: BASIC 
  18. Edition:  
  19. Preferred instances: racdb1,racdb2 
  20. Available instances: 

4- 查找service_id

 
  
  1. [oracle@node01 bin]$ sqlplus / as sysdba 
  2.  
  3. SQL*Plus: Release 11.2.0.3.0 Production on Mon Feb 4 14:46:09 2013 
  4.  
  5. Copyright (c) 19822011, Oracle.  All rights reserved. 
  6.  
  7. Connected to: 
  8. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production 
  9. With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 
  10. Data Mining and Real Application Testing options 
  11.  
  12. SQL> select name,service_id from dba_services where name = ‘server_taf’; 
  13.  
  14. NAME                                                             SERVICE_ID 
  15. —————————————————————- ———- 
  16. server_taf                                                                3 

5- 手动添加TAF的参数到server_taf service中

 
  
  1. SQL> col name format a15   
  2. SQL> col failover_method format a11 heading ‘METHOD’  
  3. SQL> col failover_type format a10 heading ‘TYPE’  
  4. SQL> col failover_retries format 9999999 heading ‘RETRIES’  
  5. SQL> col goal format a10 
  6. SQL> col clb_goal format a8  
  7. SQL> col AQ_HA_NOTIFICATIONS format a5 heading ‘AQNOT’  
  8. SQL> select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications   
  9.   2  from dba_services where service_id =3
  10.  
  11. NAME            METHOD      TYPE        RETRIES GOAL       CLB_GOAL AQNOT 
  12. ————— ———– ———- ——– ———- ——– —– 
  13. server_taf      NONE        NONE              0 NONE       LONG     NO 
  14.  
  15. METHOD,TYPE这些都是空的,这是由oracle Bug 6886239引起的,需要手动添加TAF的参数到server_taf service中, 
  16.  
  17. SQL> execute dbms_service.modify_service (service_name => ‘server_taf’ –  
  18. > , aq_ha_notifications => true –  
  19. > , failover_method => dbms_service.failover_method_basic –  
  20. > , failover_type => dbms_service.failover_type_select –  
  21. > , failover_retries => 180 –  
  22. > , failover_delay => 5 –  
  23. > , clb_goal => dbms_service.clb_goal_long); 
  24.  
  25. PL/SQL procedure successfully completed. 
  26.  
  27. SQL> select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications 
  28.   2  from dba_services where service_id =3
  29.  
  30. NAME            METHOD      TYPE        RETRIES GOAL       CLB_GOAL AQNOT 
  31. ————— ———– ———- ——– ———- ——– —– 
  32. server_taf      BASIC       SELECT          180 NONE       LONG     YES 
  33.  
  34. 添加成功。 
  35.  
  36. SQL> exit 
  37. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production 
  38. With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, 
  39. Data Mining and Real Application Testing options 

6- 在rac节点上,验证taf_services

 
  
  1. [oracle@node01 bin]$ lsnrctl services 
  2.  
  3. LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-FEB-2013 14:48:44 
  4.  
  5. Copyright (c) 19912011, Oracle.  All rights reserved. 
  6.  
  7. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) 
  8. Services Summary… 
  9. Service “+ASM” has 1 instance(s). 
  10.   Instance “+ASM1″, status READY, has 1 handler(s) for this service… 
  11.     Handler(s): 
  12.       “DEDICATED” established:0 refused:0 state:ready 
  13.          LOCAL SERVER 
  14. Service “racdb” has 1 instance(s). 
  15.   Instance “racdb1″, status READY, has 1 handler(s) for this service… 
  16.     Handler(s): 
  17.       “DEDICATED” established:0 refused:0 state:ready 
  18.          LOCAL SERVER 
  19. Service “racdbXDB” has 1 instance(s). 
  20.   Instance “racdb1″, status READY, has 1 handler(s) for this service… 
  21.     Handler(s): 
  22.       “D000″ established:0 refused:0 current:0 max:1022 state:ready 
  23.          DISPATCHER <machine: node01.us.oracle.com, pid: 5823
  24.          (ADDRESS=(PROTOCOL=tcp)(HOST=node01.us.oracle.com)(PORT=40995)) 
  25. Service “server_taf” has 1 instance(s). 
  26.   Instance “racdb1″, status READY, has 1 handler(s) for this service… 
  27.     Handler(s): 
  28.       “DEDICATED” established:0 refused:0 state:ready 
  29.          LOCAL SERVER 
  30. The command completed successfully 
  31.  
  32. 节点2 
  33. [oracle@node02 admin]$ lsnrctl status 
  34.  
  35. LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-FEB-2013 15:23:23 
  36.  
  37. Copyright (c) 19912011, Oracle.  All rights reserved. 
  38.  
  39. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) 
  40. STATUS of the LISTENER 
  41. ———————— 
  42. Alias                     LISTENER 
  43. Version                   TNSLSNR for Linux: Version 11.2.0.3.0 – Production 
  44. Start Date                04-FEB-2013 10:45:33 
  45. Uptime                    0 days 4 hr. 37 min. 50 sec 
  46. Trace Level               off 
  47. Security                  ON: Local OS Authentication 
  48. SNMP                      OFF 
  49. Listener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.ora 
  50. Listener Log File         /u01/app/grid/diag/tnslsnr/node02/listener/alert/log.xml 
  51. Listening Endpoints Summary… 
  52.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) 
  53.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.1.132)(PORT=1521))) 
  54.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.1.134)(PORT=1521))) 
  55. Services Summary… 
  56. Service “+ASM” has 1 instance(s). 
  57.   Instance “+ASM2″, status READY, has 1 handler(s) for this service… 
  58. Service “racdb” has 1 instance(s). 
  59.   Instance “racdb2″, status READY, has 1 handler(s) for this service… 
  60. Service “racdbXDB” has 1 instance(s). 
  61.   Instance “racdb2″, status READY, has 1 handler(s) for this service… 
  62. Service “server_taf” has 1 instance(s). 
  63.   Instance “racdb2″, status READY, has 1 handler(s) for this service… 
  64. The command completed successfully 

7- 在客户端上,配置TNS记录。

 
  
  1. taf = 
  2.   (DESCRIPTION = 
  3.     (ADDRESS = (PROTOCOL = TCP)(HOST = scan.us.oracle.com)(PORT = 1521)) 
  4.     (LOAD_BALANCE = yes) 
  5.     (CONNECT_DATA = 
  6.       (SERVER = DEDICATED) 
  7.       (SERVICE_NAME = server_taf) 
  8.       (FAILOVER_MODE= 
  9.       (TYPE=SELECT) 
  10.       (METHOD=BASIC) 
  11.      ) 
  12.     ) 
  13.   ) 
  14.  
  15. C:\>tnsping taf 
  16.  
  17. TNS Ping Utility for 32-bit Windows: Version 11.2.0.3.0 – Production on 04-2月 - 
  18. 2013 15:57:56 
  19.  
  20. Copyright (c) 19972011, Oracle.  All rights reserved. 
  21.  
  22. 已使用的参数文件: 
  23. c:\app\Kevin\product\11.2.0\client_1\network\admin\sqlnet.ora 
  24.  
  25. 已使用 TNSNAMES 适配器来解析别名 
  26. 尝试连接 (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = scan.us.oracle.com)(P 
  27. ORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_ 
  28. NAME = server_taf) (FAILOVER_MODE= (TYPE=SELECT) (METHOD=BASIC)))) 
  29. OK (10 毫秒) 
  30.  
  31. C:\> 

8- 测试Load Balance

p_w_picpath

 

p_w_picpath

p_w_picpath

 

p_w_picpath

p_w_picpath

从上面的图可以看出,顺序为racdb02 –>racdb01–>racdb02–>racdb01—>racdb02

9- 测试failover

p_w_picpath

 

目前连接的instance是racdb2,接下来shutdown掉racdb2

[oracle@node02 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Feb 4 16:18:55 2013

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, OLAP,
Data Mining and Real Application Testing options

SQL> shutdown abort
ORACLE instance shut down.
SQL>

p_w_picpath

至此,测试完成。