1、Client-Side Connect Time Failover
1.1)在用户端tnsname中配置了多个地址,用户发起连接请求时,会先尝试连接地址表中的第一个地址,如果这个连接尝试失败,则继续尝试使用第二个地址,直至连接成功或者遍历了所有的地址。
1.2)这种Failover的特点是:在建立连接那一时刻起作用,一旦连接建立之后,节点出现故障都不会作处理,从而客户端的表现就是会话断开,用户程序必须重新建立连接。
启用该方法:在客户端tnsname.ora中添加FAILOVER=ON条目,因为这个参数默认值就是为NO,所以即使客户端不加该条目,也有这种Failover功能。
1、client-side connect time failover
1.1 在客户端tnsnames中配置了多个地址(及rac的VIP),用户发起链接请求时,首先尝试链接第一个地址,如果尝试失败则自动尝试使用第二个地址,直至把连接池的地址遍历完或者链接成功。
1.2 这种方式只在建立连接的时候起作用,一旦连接建立之后,节点出现故障不会做处理,直接断开连接,用户必须重新进行新的链接。默认情况下默认是开启的即客户端的tnsnames文件中的中FAILOVER=ON这个条目。
默认情况下客户端的tnsnames.ora文件包含下面的内容(node1/2-vip能够进行解析)
HNZZ =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ndoe1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = hnzz)
)
)
服务端的监听状态里面能够看到下面的信息
[oracle@node1]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 14-FEB-2014 14:44:27
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date 14-FEB-2014 14:43:13
Uptime 0 days 0 hr. 1 min. 13 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/app/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /oracle/app/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=node1)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
Service "+ASM_XPT" has 1 instance(s).
Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
Service "hnzz" has 1 instance(s).
Instance "hnzz1", status READY, has 2 handler(s) for this service...
Service "hnzzXDB" has 1 instance(s).
Instance "hnzz1", status READY, has 1 handler(s) for this service...
Service "hnzz_XPT" has 1 instance(s).
Instance "hnzz1", status READY, has 2 handler(s) for this service...
The command completed successfully
SQL> show parameter service;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string hnzz
在客户端进行链接
C:\Documents and Settings\zzu>sqlplus system/oracle@hnzz
SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 2月 14 14:47:39 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> show parameter instance_name;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
instance_name string
hnzz1
SQL>
在服务器端将hnzz1关闭,
$ srvctl stop instance -d hnzz -i hnzz1
在客户端查看状态
SQL> select status from v$instance;
ERROR:
ORA-03114: 未连接到 ORALCE
SQL> quit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options 断开
C:\Documents and Settings\zzu>sqlplus system/oracle@hnzz
SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 2月 14 14:53:29 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> show parameter instance_name;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
instance_name string
hnzz2
可以看到直接连接到实例2了。
阅读(1288) | 评论(0) | 转发(0) |