分类: Oracle
2011-01-10 13:10:57
Oracle RAC Failover
Oracle 10g RAC 的Failover 可以分为3种:
1. Client-Side Connect time Failover
2. TAF
3. Service-Side TAF
1>Client-Side Connect time Failover
RAC_CSC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(FAILOVER= ON)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = NODE)
)
)
注:node1-vip,node2-vip需要能被解析
If node1-vip failed ,then will turn node2-vip
发起端的感知,故障,客户端重新连接
测试:
[oracle@node1 admin]$ sqlplus system/ank88ank@RAC_CSC
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 9 12:29:38 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining option
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
NODE1
--模拟故障
[oracle@node2 admin]$ srvctl stop instance -d node -i node1
SQL> select instacne_name from v$instance;
ERROR:
ORA-03114: not connected to ORACLE
2>TAF
参考
10g & 11g Configuration of TAF(Transparent Application Failover) and Load Balancing [ID 453293.1]
RAC_TAF =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
(LOAD_BALANCE=YES)
(
CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=NODE)
(
FAILOVER_MODE=
(TYPE=session)
(METHOD=basic)
(RETRIES=180)
(DELAY=5)
)
)
)
注:
连接后的实例,出现故障,转移到其他实例上,对应用是透明的
不能在listener.ora 配置文件的SID_LIST_listener_name 部分设置GLOBAL_DBNAME参数, 这个静态的global配置会禁用TAF.
测试
[oracle@node2 admin]$ sqlplus system/ank88ank@RAC_TAF
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 9 11:58:18 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
NODE1
--在节点1上模拟故障
[oracle@node2 admin]$ srvctl stop instance -d node -i node1
SQL> select instance_name from v$instance;
select instance_name from v$instance
*
ERROR at line 1:
ORA-25408: can not safely replay call
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
NODE2
3>Service-Side TAF
配置在服务器上
用srvctl 命令配置Service
1创建service
srvctl add service -d node -s Service2 -r "NODE1" -a "NODE2" -P basic
注意:
srvctl add service中,只有perferred才会创建服务。 即在OCR中注册一个ora.raw.dmm.Raw1.Srv的服务。
Srvctl创建service,TAF策略必须通过dbms_service包来创建
Begin
Dbms_service.modify_service(
Service_name=>'Service2',
Failover_method=>dbms_service.failover_method_basic,
Failover_type=>dbms_service.failover_type_select,
Failover_retries=>180,
Failover_delay=>5
);
End;
[oracle@node2 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora....E1.inst application 0/5 0/0 ONLINE ONLINE node1
ora....E2.inst application 0/5 0/0 ONLINE ONLINE node2
ora....DE1.srv application 0/0 0/0 OFFLINE OFFLINE
//ora.NODE.Service2.NODE1.srv
ora....ice2.cs application 0/0 0/1 OFFLINE OFFLINE
//ora.NODE.Service2.cs
ora.NODE.db application 0/1 0/1 ONLINE ONLINE node2
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE node1
ora....E1.lsnr application 0/5 0/0 ONLINE ONLINE node1
ora.node1.gsd application 0/5 0/0 ONLINE ONLINE node1
ora.node1.ons application 0/3 0/0 ONLINE ONLINE node1
ora.node1.vip application 0/0 0/0 ONLINE ONLINE node1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE node2
ora....E2.lsnr application 0/5 0/0 ONLINE ONLINE node2
ora.node2.gsd application 0/5 0/0 ONLINE ONLINE node2
ora.node2.ons application 0/3 0/0 ONLINE ONLINE node2
ora.node2.vip application 0/0 0/0 ONLINE ONLINE node2
2查看配置信息
3是否自动运行
数据库启动时,会自动启动所有的Service,维护需要,可以禁用这个特性
[oracle@node2 ~]$ srvctl enable service -d node -s Service2
4启动service
[oracle@node2 ~]$ srvctl start service -d node -s Service2
[oracle@node2 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora....E1.inst application 0/5 0/0 ONLINE ONLINE node1
ora....E2.inst application 0/5 0/0 ONLINE ONLINE node2
ora....DE1.srv application 0/0 0/0 ONLINE ONLINE node1
ora....ice2.cs application 0/0 0/1 ONLINE ONLINE node1
ora.NODE.db application 0/1 0/1 ONLINE ONLINE node2
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE node1
ora....E1.lsnr application 0/5 0/0 ONLINE ONLINE node1
ora.node1.gsd application 0/5 0/0 ONLINE ONLINE node1
ora.node1.ons application 0/3 0/0 ONLINE ONLINE node1
ora.node1.vip application 0/0 0/0 ONLINE ONLINE node1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE node2
ora....E2.lsnr application 0/5 0/0 ONLINE ONLINE node2
ora.node2.gsd application 0/5 0/0 ONLINE ONLINE node2
ora.node2.ons application 0/3 0/0 ONLINE ONLINE node2
ora.node2.vip application 0/0 0/0 ONLINE ONLINE node2
NODE1
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string NODE, Service2
SQL>
NODE2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string NODE
5停止service
[oracle@node2 ~]$ srvctl stop service -d node -s Service2
6查看service状态
[oracle@node2 ~]$ srvctl status service -d node -s Service2
Service Service2 is running on instance(s) NODE1
7删除service
[oracle@node2 ~]$ srvctl remove service -d node -s taf //-f 强制
taf PREF: node1 AVAIL: node2
Service taf is disabled.
Remove service dmm from the database node? (y/[n]) y
OCR信息被删除,数据字典中的还有该service的内容
SQL> select name,failover_method,failover_type,goal,clb_goal from dba_services;
NAME FAILOVER FAILOVER GOAL CLB_G
-------- -------- -------- ------------ -----
SYS$BACK NONE SHORT
GROUND
SYS$USER NONE SHORT
S
NODEXDB LONG
NODE LONG
Service2 BASIC SELECT LONG
taf LONG
6 rows selected.
--清楚数据字典中的数据
SQL> execute dbms_service.delete_service(service_name=>'taf');
--查询是否被清除
SQL> select name,failover_method,failover_type,goal,clb_goal from dba_services;
NAME FAILOVER FAILOVER GOAL CLB_G
-------- -------- -------- ------------ -----
SYS$BACK NONE SHORT
GROUND
SYS$USER NONE SHORT
S
NODEXDB LONG
NODE LONG
Service2 BASIC SELECT LONG
6 rows selected.
chinaunix网友2011-06-05 01:55:52
大连法律咨询在线 http://www.fabowang.com 大连律师在线咨询 http://www.fabowang.com 大连法律顾问网 http://www.fabowang.com 大连律师咨询 http://www.fabowang.com
chinaunix网友2011-03-08 15:47:52
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com