1- 添加一个名为server_taf的services,用做TAF
[oracle@node01 bin]$ pwd
/u01/app/11.2.0/grid/bin
[oracle@node01 bin]$ ./srvctl add service -d racdb -s server_taf -r “racdb1,racdb2″ -P BASIC
2- 启动server_taf服务
[oracle@node01 bin]$ ./srvctl start service -d racdb -s server_taf
3- 检查server_taf是否启动
[oracle@node01 bin]$ ./srvctl config service -d racdb
Service name: server_taf
Service is enabled
Server pool: racdb_server_taf
Cardinality: 2
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: racdb1,racdb2
Available instances:
4- 查找service_id
[oracle@node01 bin]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon Feb 4 14:46:09 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> select name,service_id from dba_services where name = ‘server_taf’;
NAME SERVICE_ID
—————————————————————- ———-
server_taf 3
5- 手动添加TAF的参数到server_taf service中
SQL> col name format a15
SQL> col failover_method format a11 heading ‘METHOD’
SQL> col failover_type format a10 heading ‘TYPE’
SQL> col failover_retries format 9999999 heading ‘RETRIES’
SQL> col goal format a10
SQL> col clb_goal format a8
SQL> col AQ_HA_NOTIFICATIONS format a5 heading ‘AQNOT’
SQL> select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications
2 from dba_services where service_id =3;
NAME METHOD TYPE RETRIES GOAL CLB_GOAL AQNOT
————— ———– ———- ——– ———- ——– —–
server_taf NONE NONE 0 NONE LONG NO
METHOD,TYPE这些都是空的,这是由oracle Bug 6886239引起的,需要手动添加TAF的参数到server_taf service中,
SQL> execute dbms_service.modify_service (service_name => ‘server_taf’ –
> , aq_ha_notifications => true –
> , failover_method => dbms_service.failover_method_basic –
> , failover_type => dbms_service.failover_type_select –
> , failover_retries => 180 –
> , failover_delay => 5 –
> , clb_goal => dbms_service.clb_goal_long);
PL/SQL procedure successfully completed.
SQL> select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications
2 from dba_services where service_id =3;
NAME METHOD TYPE RETRIES GOAL CLB_GOAL AQNOT
————— ———– ———- ——– ———- ——– —–
server_taf BASIC SELECT 180 NONE LONG YES
添加成功。
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, OLAP,
Data Mining and Real Application Testing options
6- 在rac节点上,验证taf_services
[oracle@node01 bin]$ lsnrctl services
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-FEB-2013 14:48:44
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Services Summary…
Service “+ASM” has 1 instance(s).
Instance “+ASM1″, status READY, has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER
Service “racdb” has 1 instance(s).
Instance “racdb1″, status READY, has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER
Service “racdbXDB” has 1 instance(s).
Instance “racdb1″, status READY, has 1 handler(s) for this service…
Handler(s):
“D000″ established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER <machine: node01.us.oracle.com, pid: 5823>
(ADDRESS=(PROTOCOL=tcp)(HOST=node01.us.oracle.com)(PORT=40995))
Service “server_taf” has 1 instance(s).
Instance “racdb1″, status READY, has 1 handler(s) for this service…
Handler(s):
“DEDICATED” established:0 refused:0 state:ready
LOCAL SERVER
The command completed successfully
节点2
[oracle@node02 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-FEB-2013 15:23:23
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date 04-FEB-2013 10:45:33
Uptime 0 days 4 hr. 37 min. 50 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/node02/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.1.132)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.0.1.134)(PORT=1521)))
Services Summary…
Service “+ASM” has 1 instance(s).
Instance “+ASM2″, status READY, has 1 handler(s) for this service…
Service “racdb” has 1 instance(s).
Instance “racdb2″, status READY, has 1 handler(s) for this service…
Service “racdbXDB” has 1 instance(s).
Instance “racdb2″, status READY, has 1 handler(s) for this service…
Service “server_taf” has 1 instance(s).
Instance “racdb2″, status READY, has 1 handler(s) for this service…
The command completed successfully
7- 在客户端上,配置TNS记录。
taf =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan.us.oracle.com)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = server_taf)
(FAILOVER_MODE=
(TYPE=SELECT)
(METHOD=BASIC)
)
)
)
C:\>tnsping taf
TNS Ping Utility for 32-bit Windows: Version 11.2.0.3.0 – Production on 04-2月 -
2013 15:57:56
Copyright (c) 1997, 2011, Oracle. All rights reserved.
已使用的参数文件:
c:\app\Kevin\product\11.2.0\client_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
尝试连接 (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = scan.us.oracle.com)(P
ORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_
NAME = server_taf) (FAILOVER_MODE= (TYPE=SELECT) (METHOD=BASIC))))
OK (10 毫秒)
C:\>
8- 测试Load Balance
从上面的图可以看出,顺序为racdb02 –>racdb01–>racdb02–>racdb01—>racdb02
9- 测试failover
目前连接的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>
至此,测试完成。