天天看點

RAC使用頻率較高的CRS維護指令

1.啟動crs

如果crs沒有啟動在使用crs_stat指令檢視叢集狀态的時候将會收到如下的報錯資訊。

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_stat -t

crs-0184: cannot communicate with the crs daemon.

在rac環境下啟動所有節點上的crs。

[root@rac1 ~]# /oracle/app/crs/bin/crsctl start crs

attempting to start crs stack

the crs stack will be started shortly

[root@rac2 ~]# /oracle/app/crs/bin/crsctl start crs

叢集從啟動到全部啟動完畢的總時間與系統想能和配置有關,一般需要3~10分鐘的時間,請耐心等待。

注意:為保證叢集環境可以正常無誤的啟動,一定要確定叢集環境中各個節點的時鐘保持一緻。

與之對應的停止crs指令為:“crsctl stop crs”。

2.檢視crs資源狀态

叢集資源啟動完畢後,以在第一節點檢視叢集狀态為例。

name           type           target    state     host

------------------------------------------------------------

ora....b1.inst application    online    online    rac1

ora....b2.inst application    online    online    rac2

ora.racdb.db   application    online    online    rac2

ora....db1.srv application    online    online    rac1

ora....db2.srv application    online    online    rac2

ora.....taf.cs application    online    online    rac1

ora....sm1.asm application    online    online    rac1

ora....c1.lsnr application    online    online    rac1

ora.rac1.gsd   application    online    online    rac1

ora.rac1.ons   application    online    online    rac1

ora.rac1.vip   application    online    online    rac1

ora....sm2.asm application    online    online    rac2

ora....c2.lsnr application    online    online    rac2

ora.rac2.gsd   application    online    online    rac2

ora.rac2.ons   application    online    online    rac2

ora.rac2.vip   application    online    online    rac2

3.關閉特定叢集資源

1)擷取叢集資源名的方法

crs_stat指令會給出叢集資源名的基本資訊,結合适當的shell技巧便可以得到目前環境下叢集資源名資訊。

racdb1@rac1 /home/oracle$ crs_stat | grep -i name= | cut -d '=' -f2

ora.racdb.racdb1.inst

ora.racdb.racdb2.inst

ora.racdb.db

ora.racdb.taf.racdb1.srv

ora.racdb.taf.racdb2.srv

ora.racdb.taf.cs

ora.rac1.asm1.asm

ora.rac1.listener_rac1.lsnr

ora.rac1.gsd

ora.rac1.ons

ora.rac1.vip

ora.rac2.asm2.asm

ora.rac2.listener_rac2.lsnr

ora.rac2.gsd

ora.rac2.ons

ora.rac2.vip

2)以關閉ora.racdb.racdb1.inst資源為例

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_stop ora.racdb.racdb1.inst

attempting to stop `ora.racdb.racdb1.inst` on member `rac1`

stop of `ora.racdb.racdb1.inst` on member `rac1` succeeded.

提示已成功關閉racdb1資料庫執行個體。

确認關閉後叢集資源狀态:

ora....b1.inst application    offline   offline

ora....db1.srv application    online    offline

4.啟動特定叢集資源

啟動ora.racdb.racdb1.inst資源

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_start ora.racdb.racdb1.inst

attempting to start `ora.racdb.racdb1.inst` on member `rac1`

start of `ora.racdb.racdb1.inst` on member `rac1` succeeded.

确認啟動後狀态:

5.同時停掉所有叢集資源

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_stop -all

attempting to stop `ora.racdb.taf.racdb1.srv` on member `rac1`

attempting to stop `ora.rac1.gsd` on member `rac1`

attempting to stop `ora.racdb.taf.cs` on member `rac1`

attempting to stop `ora.rac1.ons` on member `rac1`

attempting to stop `ora.racdb.taf.racdb2.srv` on member `rac2`

attempting to stop `ora.rac2.gsd` on member `rac2`

attempting to stop `ora.rac2.ons` on member `rac2`

stop of `ora.racdb.taf.racdb2.srv` on member `rac2` succeeded.

stop of `ora.racdb.taf.racdb1.srv` on member `rac1` succeeded.

attempting to stop `ora.racdb.db` on member `rac2`

stop of `ora.rac2.gsd` on member `rac2` succeeded.

stop of `ora.rac1.gsd` on member `rac1` succeeded.

stop of `ora.rac1.ons` on member `rac1` succeeded.

stop of `ora.rac2.ons` on member `rac2` succeeded.

stop of `ora.racdb.taf.cs` on member `rac1` succeeded.

stop of `ora.racdb.db` on member `rac2` succeeded.

`ora.racdb.racdb1.inst` is already offline.

`ora.racdb.racdb2.inst` is already offline.

attempting to stop `ora.rac1.listener_rac1.lsnr` on member `rac1`

attempting to stop `ora.rac1.asm1.asm` on member `rac1`

attempting to stop `ora.rac2.asm2.asm` on member `rac2`

attempting to stop `ora.rac2.listener_rac2.lsnr` on member `rac2`

stop of `ora.rac1.listener_rac1.lsnr` on member `rac1` succeeded.

attempting to stop `ora.rac1.vip` on member `rac1`

stop of `ora.rac2.listener_rac2.lsnr` on member `rac2` succeeded.

attempting to stop `ora.rac2.vip` on member `rac2`

stop of `ora.rac1.vip` on member `rac1` succeeded.

stop of `ora.rac2.vip` on member `rac2` succeeded.

stop of `ora.rac2.asm2.asm` on member `rac2` succeeded.

stop of `ora.rac1.asm1.asm` on member `rac1` succeeded.

crs-0216: could not stop resource 'ora.racdb.racdb1.inst'.

crs-0216: could not stop resource 'ora.racdb.racdb2.inst'.

确認叢集資源停止後狀态

ora....b2.inst application    offline   offline

ora.racdb.db   application    offline   offline

ora....db1.srv application    offline   offline

ora....db2.srv application    offline   offline

ora.....taf.cs application    offline   offline

ora....sm1.asm application    offline   offline

ora....c1.lsnr application    offline   offline

ora.rac1.gsd   application    offline   offline

ora.rac1.ons   application    offline   offline

ora.rac1.vip   application    offline   offline

ora....sm2.asm application    offline   offline

ora....c2.lsnr application    offline   offline

ora.rac2.gsd   application    offline   offline

ora.rac2.ons   application    offline   offline

ora.rac2.vip   application    offline   offline

6.同時啟動所有叢集資源

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crs_start -all

attempting to start `ora.rac1.vip` on member `rac1`

attempting to start `ora.rac1.asm1.asm` on member `rac1`

attempting to start `ora.rac2.vip` on member `rac2`

attempting to start `ora.rac2.asm2.asm` on member `rac2`

start of `ora.rac1.vip` on member `rac1` succeeded.

attempting to start `ora.rac1.listener_rac1.lsnr` on member `rac1`

start of `ora.rac2.vip` on member `rac2` succeeded.

attempting to start `ora.rac2.listener_rac2.lsnr` on member `rac2`

start of `ora.rac1.listener_rac1.lsnr` on member `rac1` succeeded.

start of `ora.rac2.listener_rac2.lsnr` on member `rac2` succeeded.

start of `ora.rac1.asm1.asm` on member `rac1` succeeded.

start of `ora.rac2.asm2.asm` on member `rac2` succeeded.

attempting to start `ora.racdb.racdb2.inst` on member `rac2`

start of `ora.racdb.racdb2.inst` on member `rac2` succeeded.

crs-1002: resource 'ora.rac1.ons' is already running on member 'rac1'

crs-1002: resource 'ora.rac2.ons' is already running on member 'rac2'

crs-1002: resource 'ora.racdb.db' is already running on member 'rac1'

attempting to start `ora.racdb.taf.racdb2.srv` on member `rac2`

attempting to start `ora.racdb.taf.cs` on member `rac1`

attempting to start `ora.racdb.taf.racdb1.srv` on member `rac1`

attempting to start `ora.rac1.gsd` on member `rac1`

attempting to start `ora.rac2.gsd` on member `rac2`

start of `ora.racdb.taf.cs` on member `rac1` succeeded.

start of `ora.racdb.taf.racdb2.srv` on member `rac2` succeeded.

start of `ora.rac2.gsd` on member `rac2` succeeded.

start of `ora.racdb.taf.racdb1.srv` on member `rac1` succeeded.

start of `ora.rac1.gsd` on member `rac1` succeeded.

crs-0223: resource 'ora.racdb.db' has placement error.

crs-0223: resource 'ora.rac1.ons' has placement error.

crs-0223: resource 'ora.rac2.ons' has placement error.

确認叢集資源啟動後狀态

ora.racdb.db   application    online    online    rac1

note:如果叢集資源狀态是unknown,使用crs_start –all指令将無法完成正常啟動。

7.使用srvctl停止和啟動節點應用

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/srvctl stop nodeapps -n rac1

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/srvctl start nodeapps -n rac1

有關更多的srvctl指令的參考可以通過下面的方法獲得:

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/srvctl

usage: srvctl <command> <object> [<options>]

    command: enable|disable|start|stop|relocate|status|add|remove|modify|getenv|setenv|unsetenv|config

    objects: database|instance|service|nodeapps|asm|listener

for detailed help on each command and object and its options use:

    srvctl <command> <object> -h

使用“-h”選項可以獲得更加詳細的用法。

8.停止目前節點所有crs資源

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl stop resources

stopping resources. this could take several minutes.

successfully stopped crs resources.

ora....b1.inst application    online    offline

ora.racdb.db   application    online    offline

ora.....taf.cs application    online    offline

ora....sm1.asm application    online    offline

9.啟動目前節點所有crs資源

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl start resources

starting resources.

successfully started crs resources

racdb1@rac1 /home/oracle$ crs_stat -t

10.對crs背景程序做健康檢查

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl check crs

css appears healthy

crs appears healthy

evm appears healthy

11.檢查ocr

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/ocrcheck

status of oracle cluster registry is as follows :

         version                  :          2

         total space (kbytes)     :     104216

         used space (kbytes)      :       4604

         available space (kbytes) :      99612

         id                       :  529429773

         device/file name         : /dev/raw/raw1

                                    device/file integrity check succeeded

                                    device/file not configured

         cluster registry integrity check succeeded

12.檢查表決磁盤

racdb1@rac1 /home/oracle$ /oracle/app/crs/bin/crsctl query css votedisk

 0.     0    /dev/raw/raw2

located 1 votedisk(s).

13.小結

以上示範了在rac環境與crs有關的維護指令,這些指令的使用頻率較高,需要熟練掌握。管理crs的指令較多,建議對每一個指令的具體選項做實際的測試,以便降低誤操作的風險。