srvctl 是否能夠將RAC資料庫像單例項資料庫的方式一步一步啟動

snowdba發表於2014-06-23
在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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29047826/viewspace-1191526/,如需轉載,請註明出處,否則將追究法律責任。

相關文章