ORACLE官方文档中有这样一段描述:
When you define a service for an administrator-managed database, you define which
instances normally support that service using SRVCTL with the -preferred
parameter. These are known as the preferred instances. You can also define other
instances to support a service if the service's preferred instance fails using SRVCTL
with the -available parameter.
==》大致意思说,administrator-managed的数据库,在创建service时,我们可以指定preferred参数,指定
service首选运行在该实例,该实例失败后可以在available参数所指定的实例上运行。
针对上述我们来做个测试,测试环境:oracle linux7.2 + 12.1.0.2两节点RAC
1)新建service并指定preferred和available参数
[oracle@db1 ~]$ srvctl add servic -db db -service falsrv -pdb pdb1 -preferred db1 -available db2
2)启动service并查看状态
[oracle@db1 ~]$ srvctl start service -db db -service falsrv
[oracle@db1 ~]$ srvctl status service -db db -service falsrv
Service falsrv is running on instance(s) db1
==》运行在实例1
3)kill实例1
[root@db1 ~]# ps -ef | grep ora_smon | grep -v grep
oracle 18839 1 0 14:42 ? 00:00:00 ora_smon_db1
[root@db1 ~]# kill -9 18839
4)查看节点1的crsd_oraagent_oracle.trc
2016-07-12 14:41:56.260439 : AGFW:1510827776: {0:59:6} ora.db.falsrv.svc 1 1 state changed from: ONLINE to: OFFLINE
==》状态online变为offline
5)查看此时service状态
[root@db1 ~]# srvctl status service -db db -service falsrv
Service falsrv is running on instance(s) db2
==》service运行在节2了
6)查看节点2的crsd_oraagent_oracle.trc
2016-07-12 14:41:56.301545 : AGFW:207623936: {0:59:10} : UNKNOWN to: STARTING
2016-07-12 14:41:57.144786 : AGFW:207623936: {0:59:10} ora.db.falsrv.svc 1 1 state changed from: STARTING to: ONLINE
==》service在节点2启动,状态为online
但是通过shutdown abort方式来测试,该版本下会遇到bug,service将不会failover,具体可参考MOS ID 2087538.1
下面来看测试
1)service运行在节点2,shutdown abort节点2
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> shutdown abort
ORACLE instance shut down.
2)查看各节点的crsd_oraagent_oracle.trc
节点1无该service的信息输出
节点2有以下信息输出
2016-07-12 14:58:07.701145 : AGFW:207623936: {0:31:13} ora.db.falsrv.svc 1 1 state changed from: ONLINE to: PLANNED_OFFLINE
==>状态由online变为PLANNED_OFFLINE,而不是offline
3)查看service状态
[oracle@db1 ~]$ srvctl status service -db db -service falsrv
Service falsrv is not running.
==》service未failover
最后参考MOS ID 1324574.1,有以下补充
If using sqlplus to shutdown instance
In both 10g, 11g, the service will failover to available instance
If shutdown instance using srvctl
In pre-11.2, the service will failover to available instance.
In 11.2, the service will not failover but stop
In 11.2, you need to specify -f option if you want service failover (start in another instance))
to available instance (ie, srvctl stop instance -d xxx -i xxx1 -f) when stopping instance using srvctl.
==》10g,11g下shudown abort方式可以触发service的failover。11.2通过srvctl方式触发failover需加-f参数。
总结:
1、通过指定preferred和available参数,service可以failover
2、service的failover需满足state changed from: STARTING to: ONLINE而不是state changed from: ONLINE to: PLANNED_OFFLINE,也就是说PLANNED_OFFLINE状态的service不会进行failover
end!
When you define a service for an administrator-managed database, you define which
instances normally support that service using SRVCTL with the -preferred
parameter. These are known as the preferred instances. You can also define other
instances to support a service if the service's preferred instance fails using SRVCTL
with the -available parameter.
==》大致意思说,administrator-managed的数据库,在创建service时,我们可以指定preferred参数,指定
service首选运行在该实例,该实例失败后可以在available参数所指定的实例上运行。
针对上述我们来做个测试,测试环境:oracle linux7.2 + 12.1.0.2两节点RAC
1)新建service并指定preferred和available参数
[oracle@db1 ~]$ srvctl add servic -db db -service falsrv -pdb pdb1 -preferred db1 -available db2
2)启动service并查看状态
[oracle@db1 ~]$ srvctl start service -db db -service falsrv
[oracle@db1 ~]$ srvctl status service -db db -service falsrv
Service falsrv is running on instance(s) db1
==》运行在实例1
3)kill实例1
[root@db1 ~]# ps -ef | grep ora_smon | grep -v grep
oracle 18839 1 0 14:42 ? 00:00:00 ora_smon_db1
[root@db1 ~]# kill -9 18839
4)查看节点1的crsd_oraagent_oracle.trc
2016-07-12 14:41:56.260439 : AGFW:1510827776: {0:59:6} ora.db.falsrv.svc 1 1 state changed from: ONLINE to: OFFLINE
==》状态online变为offline
5)查看此时service状态
[root@db1 ~]# srvctl status service -db db -service falsrv
Service falsrv is running on instance(s) db2
==》service运行在节2了
6)查看节点2的crsd_oraagent_oracle.trc
2016-07-12 14:41:56.301545 : AGFW:207623936: {0:59:10} : UNKNOWN to: STARTING
2016-07-12 14:41:57.144786 : AGFW:207623936: {0:59:10} ora.db.falsrv.svc 1 1 state changed from: STARTING to: ONLINE
==》service在节点2启动,状态为online
但是通过shutdown abort方式来测试,该版本下会遇到bug,service将不会failover,具体可参考MOS ID 2087538.1
下面来看测试
1)service运行在节点2,shutdown abort节点2
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> shutdown abort
ORACLE instance shut down.
2)查看各节点的crsd_oraagent_oracle.trc
节点1无该service的信息输出
节点2有以下信息输出
2016-07-12 14:58:07.701145 : AGFW:207623936: {0:31:13} ora.db.falsrv.svc 1 1 state changed from: ONLINE to: PLANNED_OFFLINE
==>状态由online变为PLANNED_OFFLINE,而不是offline
3)查看service状态
[oracle@db1 ~]$ srvctl status service -db db -service falsrv
Service falsrv is not running.
==》service未failover
最后参考MOS ID 1324574.1,有以下补充
If using sqlplus to shutdown instance
In both 10g, 11g, the service will failover to available instance
If shutdown instance using srvctl
In pre-11.2, the service will failover to available instance.
In 11.2, the service will not failover but stop
In 11.2, you need to specify -f option if you want service failover (start in another instance))
to available instance (ie, srvctl stop instance -d xxx -i xxx1 -f) when stopping instance using srvctl.
==》10g,11g下shudown abort方式可以触发service的failover。11.2通过srvctl方式触发failover需加-f参数。
总结:
1、通过指定preferred和available参数,service可以failover
2、service的failover需满足state changed from: STARTING to: ONLINE而不是state changed from: ONLINE to: PLANNED_OFFLINE,也就是说PLANNED_OFFLINE状态的service不会进行failover
end!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25923810/viewspace-2121917/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25923810/viewspace-2121917/