在RAC数据库管理中,srvctl命令可以在任意一个节点上启停数据库,并且可以通过- o选项指定nomount, mount, open 或者 transaction, nomal, immediate, abort关键字。那么该命令是否也可以像单实例数据库那样关闭之后,可以从shutdown状态启动到nomount状态,再启动到mount状态,最后open数据库呢?
来做个小实验看看效果
1,查看数据库当前状态
[grid@node1 ~]$ srvctl status database -d PROD
Instance PROD1 is running on node node1
Instance PROD2 is running on node node2
2,使用-o immediate参数关闭数据库
[grid@node1 ~]$ srvctl stop database -d PROD -o immediate
3,此时的数据库状态
[grid@node1 ~]$ srvctl status database -d PROD
Instance PROD1 is not running on node node1
Instance PROD2 is not running on node node2
4,用oracle用户从节点1登录数据库,查看状态
[grid@node1 ~]$ su - oracle
[oracle@node1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 17 00:46:46 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
5,srvctl启动数据库到nomount状态
[grid@node1 ~]$ srvctl start database -d PROD -o nomount
6,srvctl查看数据库状态,running
[grid@node1 ~]$ srvctl status database -d PROD
Instance PROD1 is running on node node1
Instance PROD2 is running on node node2
7,用oracle用户从节点1登录数据库,状态显示database not mounted
[oracle@node1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 11 21:17:54 2014
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
SYS@PROD2> select open_mode from v$database;
select open_mode from v$database
*
ERROR at line 1:
ORA-01507: database not mounted
8,本实验关键的一步,看是否能启动到mount状态?
启动数据库到mount状态使用-o mount参数,结果是不可以,srvctl认为node1已经在running了。看来只有将数据库shutdown,才能启动到mount状态,而不能像但实例数据库那样使用alter database mount
[grid@node1 ~]$ srvctl start database -d PROD -o mount
PRCR-1004 : Resource ora.prod.db is already running
PRCR-1079 : Failed to start resource ora.prod.db
CRS-5702: Resource 'ora.prod.db' is already running on ‘node1'
9,再次使用-o immediate参数关闭数据库
srvctl stop database -d PROD -o immediate
10,srvctl启动数据库到mount状态
[grid@node1 ~]$ srvctl start database -d PROD -o mount
11,用oracle用户从节点1登录数据库,登录成功并且查询结果为mounted
[oracle@node1 ~]$ s
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 17 01:07:03 2014
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
SYS@PROD1> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
12,此时如果用srvctl 启动数据库参数为-o open可以么?是否还会出现is already running on ‘node1’?
答案是肯定的。
[grid@node1 ~]$ srvctl start database -d PROD -o open
PRCR-1004 : Resource ora.prod.db is already running
PRCR-1079 : Failed to start resource ora.prod.db
CRS-5702: Resource 'ora.prod.db' is already running on 'node1'
13,最后用oracle用户登录数据,采用单实例模式下的alter database open启动数据库完成本次试验吧
登录节点1
SYS@PROD1> alter database open;
Database altered.
SYS@PROD1> select open_mode,INST_ID from gv$database;
OPEN_MODE INST_ID
-------------------- ----------
READ WRITE 1
MOUNTED 2
登录节点2
SYS@PROD2> alter database open;
Database altered.
SYS@PROD2> select open_mode,inst_id from gv$database;
OPEN_MODE INST_ID
-------------------- ----------
READ WRITE 1
READ WRITE 2