Oracle RAC 同时具备HA(High Availiablity) 和LB(LoadBalance). 而其高可用性的基础就是Failover(故障转移).
它指集群中任何一个节点的故障都不会影响用户的使用,连接到故障节点的用户会被自动转移到健康节点,从用户感受而言, 是感觉不到这种切换。
Oracle RAC 的Failover 可以分为3种:
1. Client-Side Connect time Failover
2. Client-Side TAF
3. Service-Side TAF
Service-Side TAF 可以看作是TAF的一种变种,首先Service-SideTAF也是TAF,所有TAF的特点它都有,其次这种TAF是在服务器上配置的,而不像TAF是在客户端配置的。
PREFERRED: 首选实例,会优先选择拥有这个角色的实例提供服务。
AVAILABLE: 后备实例,用户连接会优先连接PREFFERRED的Instance,当PREFERRED的Instance不可用时,才会被转到AVAILBALE的
Instance上。
要使用Server-Side TAF必须配置Service。 Service 可以在创建数据库时创建,也可以在创建数据库之后修改,既可以使用dbca配置向导,也可以用命令行的 方式配置。
测试结果如下:(测试数据库版本:11.2.0.4)
当把两个节点都放到preferred里面时:
1)断开节点1的public网络,会话会发生故障转移,转移到其他健康节点,VIP也会漂到另一个节点。
2)节点1宕机(数据库实例shutdown abort),会话也会发生故障转移,但是VIP未发生“漂”的动作。
当节点1为Preferred instances并且节点2为Available instances的时候
1)当节点1宕机(shutdown abort)故障发生后,不会发生故障转移(无论是DML还是DQL语句),并且VIP不做漂移动作。
2)当节点2宕机(shutdown abort)故障发生后,不会发生故障转移(无论是DML还是DQL语句),并且VIP不做漂移动作,但是此情况中节点2集群层资源全部断开(VIP除外)
[oracle@felix1 bin]$ srvctl add service -d felix-s server_taf -r "felix1,felix2" -P BASIC
--这里的felix是database name,felix1和felix2 是instance name。
[oracle@felix1 bin]$ srvctl start service -d felix-s server_taf
[oracle@felix1 ~]$ srvctl config service -d felix
Service name: felix_taf
Service is enabled
Server pool: felix_felix_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: felix1,felix2
Available instances:
Service name: server_taf
Service is enabled
Server pool: felix_server_taf
Cardinality: 2
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: true
Failover type: SELECT
Failover method: BASIC
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: felix1,felix2
Available instances:
[oracle@felix1 ~]$
SQL> set lines 200 pages 1000
SQL> col name for a20
SQL> select name,service_id from dba_services;
NAME SERVICE_ID
-------------------- ----------
SYS$BACKGROUND 1
SYS$USERS 2
felix_taf 3
server_taf 4
felixXDB 5
felix 6
6 rows selected.
SQL>
[oracle@felix2 ~]$ srvctl modify service -d felix-s server_taf -m BASIC -e SELECT -q TRUE -j LONG
[oracle@felix2 ~]$
[oracle@felix2 ~]$
确认修改信息:
col name format a15
col failover_method format a11 heading 'METHOD'
col failover_type format a10 heading 'TYPE'
col failover_retries format 9999999 heading'RETRIES'
col goal format a10
col clb_goal format a8
col AQ_HA_NOTIFICATIONS format a5 heading 'AQNOT'
select name, failover_method, failover_type,failover_retries,goal, clb_goal,aq_ha_notifications
from dba_services where service_id = 4;
NAME METHOD TYPE RETRIES GOAL CLB_GOAL AQNOT
--------------- ----------- ---------- ------------------ -------- -----
server_taf BASIC SELECT 0 NONE LONG YES
SYS >
以上是把两个节点都放到preferred里面 ,做以下两个测试。(1. 断开public网络 2 .宕掉节点1(shutdown abort方式))
---节点1 TNS文件配置信息如下:
[oracle@felix1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File:/u01/app/oracle/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
FELIX =
(DESCRIPTION =
(ADDRESS= (PROTOCOL = TCP)(HOST = felix-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = felix)
)
)
SERVERTAF =
(DESCRIPTION =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.10.254)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = server_taf)
)
)
~
"tnsnames.ora" 21L, 540C written
[oracle@felix1 admin]$
---节点2 TNS文件配置信息如下:
[oracle@felix2 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File:/u01/app/oracle/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
FELIX =
(DESCRIPTION =
(ADDRESS= (PROTOCOL = TCP)(HOST = felix-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = felix)
)
)
SERVERTAF =
(DESCRIPTION =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.10.254)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = server_taf)
)
)
~
~
~
"tnsnames.ora" 22L, 534C written
[oracle@felix2 admin]$
[oracle@felix2 admin]$
SQL> create table taf_test as select * from emp;
Table created.
SQL> select * from taf_test;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
------ -------- ------------ ------------------------- ---------- ---------- ----------
7369SMITH CLERK 7902 1980:12:1700:00:00 800 20
7499ALLEN SALESMAN 7698 1981:02:2000:00:00 1600 300 30
7521WARD SALESMAN 7698 1981:02:2200:00:00 1250 500 30
7566JONES MANAGER 7839 1981:04:0200:00:00 2975 20
7654MARTIN SALESMAN 7698 1981:09:2800:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 1981:05:0100:00:00 2850 30
7782CLARK MANAGER 7839 1981:06:0900:00:00 2450 10
7788SCOTT ANALYST 7566 1987:04:1900:00:00 3000 20
7839KING PRESIDENT 1981:11:1700:00:00 5000 10
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
7876ADAMS CLERK 7788 1987:05:2300:00:00 1100 20
7900JAMES CLERK 7698 1981:12:0300:00:00 950 30
7902FORD ANALYST 7566 1981:12:0300:00:00 3000 20
7934MILLER CLERK 7782 1982:01:2300:00:00 1300 10
测试原理:做如下会话连接,因为是通过@servertaf创建的连接,各个会话会LOAD_BALANCE平均分配各个节点,首先通过v$instance查看会话刚连接时所连接到的实例,然后当节点1故障后,再通过v$instance验证会话是否直接透明failover到另一个实例,然后对比各节点正常情况与与故障发生后的IP信息(public网络断开测试和实例1数据库宕机测试)。
(测试时会话包括:DML、DQL语句)
会话1:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
select * from taf_test where MGR=7902 FOR UPDATE;
会话2:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
select * from taf_test where MGR=7839 FOR UPDATE;
会话3:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
UPDATE taf_test SET COMM=500 where MGR=7698;
会话4:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
SELECT * FROM taf_test WHERE DEPTNO=20;
会话5:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
SELECT * FROM taf_test WHERE DEPTNO=30;
会话6:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
SELECT * FROM taf_test WHERE DEPTNO=10;
会话7:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
SELECT * FROM taf_test WHERE SAL=1500;
会话8:
sqlplus scott/oracle@servertaf
select instance_name from v$instance;
SELECT * FROM taf_test WHERE SAL=800;
/etc/hosts配置信息:
[root@felix1 ~]#cat /etc/hosts
127.0.0.1 localhost
#192.168.10.17 felix
#felix1
192.168.10.51 felix1
192.168.1.51 felix1-priv
192.168.10.53 felix1-vip
#felix2
192.168.10.52 felix2
192.168.1.52 felix2-priv
192.168.10.54 felix2-vip
#scan-ip
192.168.10.254 felix-scan
节点1的IP信息:
[root@felix1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.51 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:3340 errors:0 dropped:0 overruns:0 frame:0
TXpackets:1715 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:440627 (430.2 KiB) TX bytes:289324(282.5 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.53 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:121841 errors:0 dropped:0 overruns:0 frame:0
TXpackets:100869 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:87853684 (83.7 MiB) TXbytes:60366694 (57.5 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.142.56 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:25989 errors:0 dropped:0 overruns:0 frame:0
TXpackets:25989 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:12266490 (11.6 MiB) TXbytes:12266490 (11.6 MiB)
[root@felix1 ~]#
节点2的IP信息:
[root@felix2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.52 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:4326 errors:0 dropped:0 overruns:0 frame:0
TXpackets:1601 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:590127 (576.2 KiB) TX bytes:260423(254.3 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.54 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.52 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:104067 errors:0 dropped:0 overruns:0 frame:0
TXpackets:123922 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:61440817 (58.5 MiB) TXbytes:89887987 (85.7 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.138.193 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:34028 errors:0 dropped:0 overruns:0 frame:0
TXpackets:34028 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:18109198 (17.2 MiB) TXbytes:18109198 (17.2 MiB)
[root@felix2 ~]#
[root@felix1 ~]# cd /etc/sysconfig/network-scripts/
[root@felix1 network-scripts]# ls
ifcfg-Auto_eth1 ifdown-bnep ifdown-ipv6 ifdown-routes ifup-aliases ifup-ippp ifup-plusb ifup-sit net.hotplug
ifcfg-eth0 ifdown-eth ifdown-isdn ifdown-sit ifup-bnep ifup-ipv6 ifup-post ifup-tunnel network-functions
ifcfg-lo ifdown-ib ifdown-post ifdown-tunnel ifup-eth ifup-isdn ifup-ppp ifup-wireless network-functions-ipv6
ifdown ifdown-ippp ifdown-ppp ifup ifup-ib ifup-plip ifup-routes init.ipv6-global
[root@felix1network-scripts]# ifdown ifcfg-eth0
1. 对于select for update语句
对于select for update语句连接的会话,当故障发生时,会发生故障转移。
SCOTT >select instance_name from v$instance;
select * from taf_test where MGR=7902 FOR UPDATE;
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >SCOTT >
select * from taf_test where MGR=7902 FOR UPDATE
*
ERROR at line 1:
ORA-25408: can not safely replay call
SCOTT >SCOTT >SCOTT >SCOTT >SCOTT>SCOTT >
SCOTT >select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix2 ---public网络断开后连接到的实例
2. 对于update语句
对于update语句的会话,当故障发生时,并不会发生故障转移。
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT>select instance_name from v$instance;
UPDATE taf_test SET COMM=500 where MGR=7698;
SCOTT >SCOTT >
ERROR:
ORA-03114: not connected to ORACLE
UPDATE taf_test SET COMM=500 where MGR=7698
*
ERROR at line 1:
ORA-12153: TNS:not connected
Process ID: 10448
Session ID: 34 Serial number: 167
SCOTT >
SCOTT >
SCOTT >select instance_name from v$instance;
ERROR:
ORA-03114: not connected to ORACLE
ERROR:
ORA-03114: not connected to ORACLE
SCOTT >select instance_name from v$instance;
ERROR:
ORA-03114: not connected to ORACLE
ERROR:
ORA-03114: not connected to ORACLE
SCOTT >
对于select 语句
--对于select 语句 1
SCOTT > select instance_name from v$instance;
SELECT * FROM taf_test WHERE SAL=1000;
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >SCOTT >
no rows selected
SCOTT >SCOTT >
SCOTT >
SCOTT >select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix2 ---public网络断开后连接到的实例
SCOTT >
SCOTT >
--对于select 语句 2
SCOTT > select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >
SCOTT >SELECT * FROM taf_test WHERE DEPTNO=30;
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7499ALLEN SALESMAN 7698 1981:02:2000:00:00 1600 300 30
7521WARD SALESMAN 7698 1981:02:2200:00:00 1250 500 30
7654MARTIN SALESMAN 7698 1981:09:2800:00:00 1250 1400 30
7698BLAKE MANAGER 7839 1981:05:0100:00:00 2850 30
7844 TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
7900JAMES CLERK 76981981:12:0300:00:00 950 30
6 rows selected.
SCOTT >SCOTT >select instance_name fromv$instance;
INSTANCE_NAME
--------------------------------
felix2 ---public网络断开后连接到的实例
SCOTT >
--对于select 语句 3
SCOTT > select instance_name from v$instance;
SELECT * FROM taf_test WHERE SAL=1500;
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >SCOTT >
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
SCOTT >SCOTT >
SCOTT >select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix2 ---public网络断开后连接到的实例
SCOTT >
查看此时集群状态:
[root@felix2 ~]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.FRA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.LISTENER.lsnr
ONLINE OFFLINE felix1
ONLINE ONLINE felix2
ora.OCRVOTING.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.asm
ONLINE ONLINE felix1 Started
ONLINE ONLINE felix2 Started
ora.gsd
OFFLINE OFFLINE felix1
OFFLINE OFFLINE felix2
ora.net1.network
ONLINE OFFLINE felix1
ONLINE ONLINE felix2
ora.ons
ONLINE OFFLINE felix1
ONLINE ONLINE felix2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE felix2
ora.cvu
1 ONLINE ONLINE felix2
ora.felix.db
1 ONLINE ONLINE felix1 Open
2 ONLINE ONLINE felix2 Open
ora.felix.server_taf.svc
1 ONLINE OFFLINE
2 ONLINE ONLINE felix2
ora.felix1.vip
1 ONLINE INTERMEDIATE felix2 FAILED OVER
ora.felix2.vip
1 ONLINE ONLINE felix2
ora.oc4j
1 ONLINE ONLINE felix1
ora.scan1.vip
1 ONLINE ONLINE felix2
此时节点1主机的IP信息:
[oracle@felix2 ~]$ ssh [email protected]
The authenticity of host '192.168.1.51(192.168.1.51)' can't be established.
RSA key fingerprint is 8f:c9:7c:11:f0:11:98:51:84:55:36:76:c2:91:59:e7.
Are you sure you want to continue connecting(yes/no)? yes
Warning: Permanently added '192.168.1.51' (RSA) tothe list of known hosts.
[email protected]'s password:
Last login: Tue Dec 8 23:54:11 2015 from 192.168.10.1
[root@felix1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:5351 errors:0 dropped:0 overruns:0 frame:0
TXpackets:2147 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:659945 (644.4 KiB) TX bytes:382170(373.2 KiB)
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:151178 errors:0 dropped:0 overruns:0 frame:0
TXpackets:124346 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:105635142 (100.7 MiB) TXbytes:71654213 (68.3 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.142.56 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:33980 errors:0 dropped:0 overruns:0 frame:0
TXpackets:33980 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:14678241 (13.9 MiB) TXbytes:14678241 (13.9 MiB)
[root@felix1 ~]#
此时节点2主机的IP信息:
[root@felix2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.52 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:6128 errors:0 dropped:0 overruns:0 frame:0
TXpackets:2782 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:797678 (778.9 KiB) TX bytes:449629(439.0 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:2 Link encap:Ethernet HWaddr 08:00:27:7B:DA:59
inet addr:192.168.10.53 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr 08:00:27:7B:DA:59
inet addr:192.168.10.54 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.52 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:122508 errors:0 dropped:0 overruns:0 frame:0
TXpackets:145890 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:70401384 (67.1 MiB) TXbytes:103002678 (98.2 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.138.193 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:39254 errors:0 dropped:0 overruns:0 frame:0
TXpackets:39254 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:20275770 (19.3 MiB) TXbytes:20275770 (19.3 MiB)
[root@felix2 ~]#
从以上测试可以看出,当节点1的public网络断开后,之前连接到节点1的会话(SELECT)故障转移到了节点2上,并且节点1的VIP(192.168.10.53 felix1-vip)漂到了节点2上(从以上节点2的IP信息的标红处eth0:2可以看出)。
[root@felix1 ~]# cat /etc/hosts
127.0.0.1 localhost
#192.168.10.17 felix
#felix1
192.168.10.51 felix1
192.168.1.51 felix1-priv
192.168.10.53 felix1-vip
#felix2
192.168.10.52 felix2
192.168.1.52 felix2-priv
192.168.10.54 felix2-vip
#scan-ip
192.168.10.254 felix-scan
[root@felix1 ~]#
---节点1的IP信息:
[root@felix1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.51 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:797 errors:0 dropped:0 overruns:0 frame:0
TXpackets:553 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:149395 (145.8 KiB) TX bytes:94913(92.6 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.53 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:59469 errors:0 dropped:0 overruns:0 frame:0
TXpackets:60011 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:41132611 (39.2 MiB) TXbytes:43517816 (41.5 MiB)
eth1:1 Linkencap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.142.56 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:13151 errors:0 dropped:0 overruns:0 frame:0
TXpackets:13151 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:6366619 (6.0 MiB) TX bytes:6366619(6.0 MiB)
[root@felix1 ~]#
--节点2的IP信息:
[root@felix2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.52 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:1258 errors:0 dropped:0 overruns:0 frame:0
TXpackets:306 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:213816 (208.8 KiB) TX bytes:55999(54.6 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.54 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.52 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:60819 errors:0 dropped:0 overruns:0 frame:0
TXpackets:59361 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:43726317 (41.7 MiB) TXbytes:41286715 (39.3 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.138.193 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:13986 errors:0 dropped:0 overruns:0 frame:0
TX packets:13986 errors:0 dropped:0overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:8503012 (8.1 MiB) TX bytes:8503012(8.1 MiB)
[root@felix2 ~]#
[oracle@felix1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec8 00:21:43 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release11.2.0.4.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>
update语句
对于update语句连接的会话,当故障发生时,不会产生故障转移。
SCOTT >
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >UPDATE taf_test SET COMM=500 where MGR=7698;
5 rows updated.
SCOTT >SCOTT >select instance_name fromv$instance;
select instance_name from v$instance
*
ERROR at line 1:
ORA-25402: transaction must roll back
SCOTT >
select语句:
对于select语句连接的会话,当故障发生时,会发生故障转移。
--select语句 1
SCOTT > select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >SELECT * FROM taf_test WHERE DEPTNO=30;
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7499ALLEN SALESMAN 7698 1981:02:2000:00:00 1600 300 30
7521WARD SALESMAN 7698 1981:02:2200:00:00 1250 500 30
7654MARTIN SALESMAN 7698 1981:09:2800:00:00 1250 1400 30
7698BLAKE MANAGER 7839 1981:05:0100:00:00 2850 30
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
7900JAMES CLERK 76981981:12:0300:00:00 950 30
6 rows selected.
--'宕机后查询实例信息'
SCOTT >SCOTT >select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix2 ---public网络断开后连接到的实例
SCOTT >
-- select语句 2
SCOTT > select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >SELECT * FROM taf_test WHERE SAL=1500;
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
SCOTT >
--'宕机后查询实例信息'
SCOTT >select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix2 ---public网络断开后连接到的实例
SCOTT >SCOTT >
--select语句 3
SCOTT >
INSTANCE_NAME
--------------------------------
felix1 ---会话刚连接时连接到的实例
SCOTT >SELECT * FROM taf_test WHERE SAL=800;
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7369SMITH CLERK 79021980:12:1700:00:00 800 20
SCOTT >
--'宕机后查询实例信息'
SCOTT >select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix2 ---public网络断开后连接到的实例
SCOTT >SCOTT >
查看此时集群状态:
[root@felix2 ~]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.FRA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.LISTENER.lsnr
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.OCRVOTING.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.asm
ONLINE ONLINE felix1 Started
ONLINE ONLINE felix2 Started
ora.gsd
OFFLINE OFFLINE felix1
OFFLINE OFFLINE felix2
ora.net1.network
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.ons
ONLINE ONLINE felix1
ONLINE ONLINE felix2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE felix2
ora.cvu
1 ONLINE ONLINE felix2
ora.felix.db
1 OFFLINE OFFLINE InstanceShutdown
2 ONLINE ONLINE felix2 Open
ora.felix.server_taf.svc
1 ONLINE OFFLINE
2 ONLINE ONLINE felix2
ora.felix1.vip
1 ONLINE ONLINE felix1
ora.felix2.vip
1 ONLINE ONLINE felix2
ora.oc4j
1 ONLINE ONLINE felix1
ora.scan1.vip
1 ONLINE ONLINE felix2
[root@felix2 ~]#
可以看出servertaf服务只是OFFLINE,但是并未显示同测试1结果的failover现象。
查看此时各节点IP信息:
[oracle@felix1 ~]$ ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.51 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:2352 errors:0 dropped:0 overruns:0 frame:0
TXpackets:1044 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:324678 (317.0 KiB) TX bytes:191394(186.9 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.53 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:77405 errors:0 dropped:0 overruns:0 frame:0
TXpackets:75648 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:51046650 (48.6 MiB) TXbytes:49481430 (47.1 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.142.56 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:16642 errors:0 dropped:0 overruns:0 frame:0
TXpackets:16642 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:7794168 (7.4 MiB) TX bytes:7794168(7.4 MiB)
[oracle@felix1 ~]$
[root@felix2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.52 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:3115 errors:0 dropped:0 overruns:0 frame:0
TXpackets:1337 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:431392 (421.2 KiB) TX bytes:221128(215.9 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.54 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.52 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:77506 errors:0 dropped:0 overruns:0 frame:0
TXpackets:78085 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:50089398 (47.7 MiB) TXbytes:51824262 (49.4 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.138.193 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Linkencap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:25415 errors:0 dropped:0 overruns:0 frame:0
TXpackets:25415 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:13167923 (12.5 MiB) TXbytes:13167923 (12.5 MiB)
[root@felix2 ~]#
从以上测试可以看出,当节点1宕机后,之前连接到节点1的会话(SELECT)故障转移到了节点2上,但是节点1的VIP(192.168.10.53 felix1-vip)并未漂移到节点2上。
[oracle@felix1 ~]$ srvctl add service -d felix -sserver_taf2 -r "felix1,felix2" -P BASIC
[oracle@felix1 ~]$ srvctl start service -d felix-s server_taf2
[oracle@felix1 ~]$ srvctlmodify service -d felix -s server_taf2-n -i felix1 -a felix2
[oracle@felix1 ~]$ srvctl config service -d felix -s server_taf2
Service name: server_taf2
Service is enabled
Server pool: felix_server_taf2
Cardinality: 1
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: felix1
Available instances: felix2
[oracle@felix1 ~]$
[oracle@felix1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File:/u01/app/oracle/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
FELIX =
(DESCRIPTION =
(ADDRESS= (PROTOCOL = TCP)(HOST = felix-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = felix)
)
)
SERVERTAF2 =
(DESCRIPTION =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.10.254)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = server_taf2)
)
)
"tnsnames.ora" 32L, 758C written
[oracle@felix1 admin]$
[oracle@felix2 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File:/u01/app/oracle/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
FELIX =
(DESCRIPTION =
(ADDRESS= (PROTOCOL = TCP)(HOST = felix-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = felix)
)
)
SERVERTAF2 =
(DESCRIPTION =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.10.254)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = server_taf2)
)
)
[oracle@felix2 admin]$
SYS >show parameter service_name
NAME TYPE VALUE
---------------------------------------------------------- ------------------------------
service_names string felix_taf, server_taf
SYS >alter system set service_names='felix_taf,server_taf,server_taf2';
System altered.
SYS >show parameter service_name
NAME TYPE VALUE
---------------------------------------------------------- ------------------------------
service_names string felix_taf, server_taf,server_t
af2
SYS >
[oracle@felix1 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Productionon 09-DEC-2015 23:51:55
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version11.2.0.4.0 - Production
Start Date 09-DEC-2015 22:14:47
Uptime 0 days 1 hr. 37 min. 8 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/11.2.0/network/admin/listener.ora
Listener Log File /u01/grid/diag/tnslsnr/felix1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.10.51)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.10.53)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance"+ASM1", status READY, has 1 handler(s) for this service...
Service "felix" has 1 instance(s).
Instance"felix1", status READY, has 1 handler(s) for this service...
Service "felixXDB" has 1 instance(s).
Instance"felix1", status READY, has 1 handler(s) for this service...
Service "felix_taf" has 1 instance(s).
Instance"felix1", status READY, has 1 handler(s) for this service...
Service "server_taf" has 1 instance(s).
Instance"felix1", status READY, has 1 handler(s) for this service...
Service "server_taf2" has 1 instance(s).
Instance"felix1", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@felix1 admin]$
会话1:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
insert into taf_test select * from taf_test;
会话2:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
select * from taf_test where MGR=7839 FOR UPDATE;
会话3:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
UPDATE taf_test SET COMM=500 where MGR=7698;
会话4:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
insert into taf_test select * from taf_test;
会话5:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
SELECT * FROM taf_test WHERE DEPTNO=30;
会话6:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
SELECT * FROM taf_test WHERE DEPTNO=10;
会话7:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
SELECT * FROM taf_test WHERE SAL=1500;
会话8:
sqlplus scott/oracle@servertaf2
select instance_name from v$instance;
SELECT * FROM taf_test WHERE SAL=800;
节点1主机IP信息:
[root@felix1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.51 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:12334 errors:0 dropped:0 overruns:0 frame:0
TXpackets:2256 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:1709959 (1.6 MiB) TX bytes:397060(387.7 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.53 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:362354 errors:0 dropped:0 overruns:0 frame:0
TXpackets:317019 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:225392102 (214.9 MiB) TXbytes:176257622 (168.0 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.142.56 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:109574 errors:0 dropped:0 overruns:0 frame:0
TXpackets:109574 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:38990474 (37.1 MiB) TXbytes:38990474 (37.1 MiB)
[root@felix1 ~]#
节点2主机IP信息:
[root@felix2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.52 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:9191 errors:0 dropped:0 overruns:0 frame:0
TXpackets:6516 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:1220035 (1.1 MiB) TX bytes:1032175(1007.9 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.54 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.52 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:322182 errors:0 dropped:0 overruns:0 frame:0
TXpackets:360040 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:177507704 (169.2 MiB) TXbytes:226075671 (215.6 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.138.193 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:75326 errors:0 dropped:0 overruns:0 frame:0
TXpackets:75326 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:45743962 (43.6 MiB) TXbytes:45743962 (43.6 MiB)
[root@felix2 ~]#
各回话信息:
会话1:
1)对insert语句,未发生故障转移。
SCOTT > select instance_name from v$instance;
SELECT * FROM taf_test WHERE DEPTNO=30;
INSTANCE_NAME
--------------------------------
felix1
SCOTT >insert into taf_test select * fromtaf_test;
14 rows created.
SCOTT >select instance_namefrom v$instance;
select instance_name fromv$instance
*
ERROR at line 1:
ORA-03113: end-of-file oncommunication channel
Process ID: 11585
Session ID: 43 Serial number:123
ERROR:
ORA-03114: not connected toORACLE
SCOTT >
会话2:
1)此时对于select语句,该会话也未发生故障转移。
SCOTT > select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix1
SCOTT >SELECT * FROM taf_test WHERE DEPTNO=30;
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7499ALLEN SALESMAN 7698 1981:02:2000:00:00 1600 300 30
7521WARD SALESMAN 7698 1981:02:2200:00:00 1250 500 30
7654 MARTIN SALESMAN 7698 1981:09:2800:00:00 1250 1400 30
7698BLAKE MANAGER 7839 1981:05:0100:00:00 2850 30
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
7900JAMES CLERK 76981981:12:0300:00:00 950 30
6 rows selected.
SCOTT >select instance_namefrom v$instance;
select instance_name fromv$instance
*
ERROR at line 1:
ORA-03113: end-of-file oncommunication channel
Process ID: 11587
Session ID: 78 Serial number:115
ERROR:
ORA-03114: not connected toORACLE
SCOTT >
会话3:
SCOTT > select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
felix1
SCOTT >SELECT * FROM taf_test WHERE SAL=1500;
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
SCOTT >select instance_namefrom v$instance;
select instance_name fromv$instance
*
ERROR at line 1:
ORA-03113: end-of-file oncommunication channel
Process ID: 11606
Session ID: 80 Serial number: 61
ERROR:
ORA-03114: not connected toORACLE
SCOTT >
[root@felix2 ~]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.FRA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.LISTENER.lsnr
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.OCRVOTING.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.asm
ONLINE ONLINE felix1 Started
ONLINE ONLINE felix2 Started
ora.gsd
OFFLINE OFFLINE felix1
OFFLINE OFFLINE felix2
ora.net1.network
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.ons
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.registry.acfs
ONLINE ONLINE felix1
ONLINE ONLINE felix2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE felix1
ora.cvu
1 ONLINE ONLINE felix2
ora.felix.db
1 ONLINE ONLINE felix2 Open
2 OFFLINE OFFLINE InstanceShutdown
ora.felix.felix_taf.svc
1 ONLINE ONLINE felix2
2 ONLINE OFFLINE
ora.felix.server_taf.svc
1 ONLINE OFFLINE
2 ONLINE ONLINE felix2
ora.felix.server_taf2.svc
1 ONLINE ONLINE felix2
ora.felix1.vip
1 ONLINE ONLINE felix1
ora.felix2.vip
1 ONLINE ONLINE felix2
ora.oc4j
1 ONLINE ONLINE felix1
ora.scan1.vip
1 ONLINE ONLINE felix1
[root@felix2 ~]#
节点1主机IP信息:
[root@felix1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.51 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:13609 errors:0 dropped:0 overruns:0 frame:0
TXpackets:2508 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:1880760 (1.7 MiB) TX bytes:443499(433.1 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.53 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:376330 errors:0 dropped:0 overruns:0 frame:0
TXpackets:327765 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:234527568 (223.6 MiB) TXbytes:181535431 (173.1 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inetaddr:169.254.142.56 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:111294 errors:0 dropped:0 overruns:0 frame:0
TXpackets:111294 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:40338783 (38.4 MiB) TXbytes:40338783 (38.4 MiB)
[root@felix1 ~]#
节点2主机IP信息:
[root@felix2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.52 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:10176 errors:0 dropped:0 overruns:0 frame:0
TXpackets:7267 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:1344890 (1.2 MiB) TX bytes:1157602(1.1 MiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.54 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.52 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:333365 errors:0 dropped:0 overruns:0 frame:0
TXpackets:373430 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:182725657 (174.2 MiB) TXbytes:234748837 (223.8 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.138.193 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:80730 errors:0 dropped:0 overruns:0 frame:0
TXpackets:80730 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:50339855 (48.0 MiB) TXbytes:50339855 (48.0 MiB)
[root@felix2 ~]#
总结:当节点1为Preferredinstances并且节点2为Availableinstances的时候,当节点1宕机(shutdownabort)故障发生后,不会发生故障转移(无论是DML还是DQL语句),并且VIP不做漂移动作。
(开了八个同样的查询会话)
会话1:
select查询语句的会话未发生故障转移。
SCOTT >
INSTANCE_NAME
--------------------------------
felix2
SCOTT >
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7499ALLEN SALESMAN 7698 1981:02:2000:00:00 1600 300 30
7521WARD SALESMAN 7698 1981:02:2200:00:00 1250 500 30
7654MARTIN SALESMAN 7698 1981:09:2800:00:00 1250 1400 30
7698BLAKE MANAGER 7839 1981:05:0100:00:00 2850 30
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
7900JAMES CLERK 76981981:12:0300:00:00 950 30
6 rows selected.
SCOTT >SELECT * FROM taf_test WHERE DEPTNO=30;
SELECT * FROM taf_test WHERE DEPTNO=30
*
ERROR at line 1:
ORA-03113: end-of-file oncommunication channel
Process ID: 4242
Session ID: 61 Serial number: 5
ERROR:
ORA-03114: not connected toORACLE
SCOTT >
会话2:
select查询语句的会话未发生故障转移。
SCOTT >
INSTANCE_NAME
--------------------------------
felix2
SCOTT >
EMPNOENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ---------------------------- ------------------ ---------- ---------- ----------
7499ALLEN SALESMAN 7698 1981:02:2000:00:00 1600 300 30
7521WARD SALESMAN 7698 1981:02:2200:00:00 1250 500 30
7654MARTIN SALESMAN 7698 1981:09:2800:00:00 1250 1400 30
7698BLAKE MANAGER 7839 1981:05:0100:00:00 2850 30
7844TURNER SALESMAN 7698 1981:09:0800:00:00 1500 0 30
7900JAMES CLERK 76981981:12:0300:00:00 950 30
6 rows selected.
SCOTT >SELECT * FROM taf_test WHERE DEPTNO=30;
SELECT * FROM taf_test WHERE DEPTNO=30
*
ERROR at line 1:
ORA-03113: end-of-file oncommunication channel
Process ID: 4246
Session ID: 56 Serial number: 43
ERROR:
ORA-03114: not connected toORACLE
SCOTT >
[root@felix1 ~]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.FRA.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.LISTENER.lsnr
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.OCRVOTING.dg
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.asm
ONLINE ONLINE felix1 Started
ONLINE ONLINE felix2 Started
ora.gsd
OFFLINE OFFLINE felix1
OFFLINE OFFLINE felix2
ora.net1.network
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.ons
ONLINE ONLINE felix1
ONLINE ONLINE felix2
ora.registry.acfs
ONLINE ONLINE felix1
ONLINE ONLINE felix2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE felix1
ora.cvu
1 ONLINE ONLINE felix1
ora.felix.db
1 OFFLINE OFFLINE InstanceShutdown
2 ONLINE ONLINE felix1 Open
ora.felix.felix_taf.svc
1 ONLINE OFFLINE
2 ONLINE ONLINE felix1
ora.felix.server_taf.svc
1 ONLINE ONLINE felix1
2 ONLINE OFFLINE
ora.felix.server_taf2.svc
1 ONLINE ONLINE felix1
ora.felix1.vip
1 ONLINE ONLINE felix1
ora.felix2.vip
1 ONLINE ONLINE felix2
ora.oc4j
1 ONLINE ONLINE felix1
ora.scan1.vip
1 ONLINE ONLINE felix1
[root@felix1 ~]#
此时可以看出,节点2集群层资源全部断开(除了VIP资源)。
节点1主机IP信息:
[root@felix1 ~]# ifconfig
eth0 Linkencap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.51 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:4170 errors:0 dropped:0 overruns:0 frame:0
TXpackets:1593 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:508166 (496.2 KiB) TX bytes:252861(246.9 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.53 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.51 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:52967 errors:0 dropped:0 overruns:0 frame:0
TXpackets:66605 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:27484593 (26.2 MiB) TXbytes:48367458 (46.1 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.142.56 Bcast:169.254.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:19045 errors:0 dropped:0 overruns:0 frame:0
TXpackets:19045 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:10148885 (9.6 MiB) TXbytes:10148885 (9.6 MiB)
[root@felix1 ~]#
节点2主机IP信息:
[root@felix2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.52 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7b:da59/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:3459 errors:0 dropped:0 overruns:0 frame:0
TXpackets:1449 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:415948 (406.1 KiB) TX bytes:238660(233.0 KiB)
eth0:1 Link encap:Ethernet HWaddr08:00:27:7B:DA:59
inet addr:192.168.10.54 Bcast:192.168.10.255 Mask:255.255.255.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:192.168.1.52 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fedf:c4f4/64 Scope:Link
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RXpackets:66276 errors:0 dropped:0 overruns:0 frame:0
TXpackets:50944 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RXbytes:47968867 (45.7 MiB) TXbytes:26668108 (25.4 MiB)
eth1:1 Link encap:Ethernet HWaddr08:00:27:DF:C4:F4
inet addr:169.254.138.193 Bcast:169.254.255.255 Mask:255.255.0.0
UPBROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UPLOOPBACK RUNNING MTU:16436 Metric:1
RXpackets:12860 errors:0 dropped:0 overruns:0 frame:0
TXpackets:12860 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RXbytes:8775183 (8.3 MiB) TX bytes:8775183(8.3 MiB)
[root@felix2 ~]#
总结:当节点1为Preferredinstances并且节点2为Availableinstances的时候,当节点2宕机(shutdownabort)故障发生后,不会发生故障转移(无论是DML还是DQL语句),并且VIP不做漂移动作,但是此情况中节点2集群层资源全部断开(VIP除外)(此情况可与2.5的集群信息做对比)。