Oracle 叢集(RAC)的啟動與關閉
Oracle RAC啟動與關閉的時候需要注意以下幾點:
一、檢查共用裝置
二、自動啟動RAC並檢查相關進程
三、 手動啟動RAC
四、 在啟動的過程中最好檢測著crs、ASM和資料庫的日誌。
一、檢查共用裝置
一般情況下, 存放OCR 和 Voting Disk 的OCFS2 或者raw 都是自動啟動的。 如果他們沒有啟動,RAC 肯定是啟動不了的。
1.1 如果使用ocfs2的,檢查ocfs2 狀態
/etc/init.d/o2cb status
在掛載之前,/etc/init.d/o2cb status 顯示為Checking O2CB heartbeat: Not active。
在格式化和掛載檔案系統之前,應驗證 O2CB 在兩個節點上均聯機;O2CB 心跳當前沒有
活動,因為檔案系統還沒有掛載 。掛載之後就會變成active。
mount -t ocfs2 -o datavolume /dev/sdb1 /u02/oradata/orcl
1,2. 如果使用raw device.
[root@raw1 ~]# cd /dev/raw/
[root@raw1 raw]# ls
raw1 raw2
或者:
[root@raw1 init.d]# /etc/init.d/rawdevices status
/dev/raw/raw1: bound to major 8, minor 17
/dev/raw/raw2: bound to major 8, minor 18
1.3. 檢查ASM
/etc/init.d/oracleasm listdisks
二、自動啟動RAC並檢查相關進程
RAC 在啟動的時候crs 等進程都是自動啟動的:
[root@rac1 init.d]# ls -l /etc/init.d/init.*
-r-xr-xr-x 1 root root 1951 Feb 26 22:38 /etc/init.d/init.crs
-r-xr-xr-x 1 root root 4714 Feb 26 22:38 /etc/init.d/init.crsd
-r-xr-xr-x 1 root root 35394 Feb 26 22:38 /etc/init.d/init.cssd
-r-xr-xr-x 1 root root 3190 Feb 26 22:38 /etc/init.d/init.evmd
我們要查看一下crs 的狀態:
正常情況下, 進程都是online的:
[root@raw1 bin]# ./crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.raw.db application ONLINE ONLINE raw1
ora.raw.raw.cs application ONLINE ONLINE raw1
ora....aw1.srv application ONLINE ONLINE raw1
ora....aw2.srv application ONLINE ONLINE raw2
ora....w1.inst application ONLINE ONLINE raw1
ora....w2.inst application ONLINE ONLINE raw2
ora....SM1.asm application ONLINE ONLINE raw1
ora....W1.lsnr application ONLINE ONLINE raw1
ora.raw1.gsd application ONLINE ONLINE raw1
ora.raw1.ons application ONLINE ONLINE raw1
ora.raw1.vip application ONLINE ONLINE raw1
ora....SM2.asm application ONLINE ONLINE raw2
ora....W2.lsnr application ONLINE ONLINE raw2
ora.raw2.gsd application ONLINE ONLINE raw2
ora.raw2.ons application ONLINE ONLINE raw2
ora.raw2.vip application ONLINE ONLINE raw2
如果出現以下情況:
[root@rac2 bin]# ./crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.rac.db application ONLINE UNKNOWN rac1
ora....orcl.cs application ONLINE UNKNOWN rac1
ora....ac1.srv application OFFLINE OFFLINE
ora....ac2.srv application OFFLINE OFFLINE
ora....c1.inst application ONLINE UNKNOWN rac1
ora....c2.inst application ONLINE UNKNOWN rac2
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE UNKNOWN rac1
ora.rac1.gsd application ONLINE UNKNOWN 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 UNKNOWN rac2
ora.rac2.gsd application ONLINE UNKNOWN rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
解決方案:
1. 用crs_stat 查看進程全部資訊:
[root@rac2 bin]# ./crs_stat
NAME=ora.rac.db
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac2
NAME=ora.rac1.LISTENER_RAC1.lsnr
TYPE=application
TARGET=ONLINE
STATE=UNKNOWN on rac1
NAME=ora.rac1.gsd
TYPE=application
TARGET=ONLINE
STATE=UNKNOWN on rac1
NAME=ora.rac2.LISTENER_RAC2.lsnr
TYPE=application
TARGET=ONLINE
STATE=UNKNOWN on rac2
... ...
2. 對於offline 的進程,我們可以直接手動的啟動它
[root@rac2 bin]# ./crs_start ora.rac.orcl.rac1.srv
Attempting to start `ora.rac.orcl.rac1.srv` on member `rac1`
Start of `ora.rac.orcl.rac1.srv` on member `rac1` succeeded.、
3. 對於UNKNOWN 的進程,我們可以先stop 它, 在start。
[root@rac2 bin]# ./crs_stop ora.rac2.gsd
Attempting to stop `ora.rac2.gsd` on member `rac2`
Stop of `ora.rac2.gsd` on member `rac2` succeeded.
[root@rac2 bin]# ./crs_start ora.rac2.gsd
Attempting to start `ora.rac2.gsd` on member `rac2`
Start of `ora.rac2.gsd` on member `rac2` succeeded.
4. 如果crs_stop不能結束,crs_start 不能啟動的進程,我們有2中方法來解決:
4.1)是用crs_stop -f 參數把crs中狀態是UNKNOWN的服務關掉,然後再用crs_start -f (加一個-f的參數)啟動所有的服務就可以。要分別在兩個節點上執行;
[oracle@rac2 ~]$ crs_start -f ora.ora9i.ora9i2.inst
Attempting to start `ora.ora9i.ora9i2.inst` on member `rac2`
Start of `ora.ora9i.ora9i2.inst` on member `rac2` succeeded.
[oracle@rac2 ~]$ crs_stop -f ora.ora9i.db
Attempting to stop `ora.ora9i.db` on member `rac2`
Stop of `ora.ora9i.db` on member `rac2` succeeded.
4.2)轉換到root使用者下用/etc/init.d/init.crs stop先禁用crs,然後再用/etc/init.d/init.crs start去啟用crs,啟用crs後會自動啟動crs的一系列服務,注意此種方法需要在兩台節點上都執行;
5. 可以用命令一次啟動和關閉相關進程
[root@rac2 bin]# ./crs_stop -all
[root@rac2 bin]# ./crs_start -all
三、 手動啟動RAC
一般情況下每次節點啟動的時候,所有服務都會自動啟動,如果需要關閉或者啟動某個節點,如下所示
停止RAC:
emctl stop dbconsole
srvctl stop instance -d raw -i raw1
srvctl stop instance -d raw -i raw2
srvctl stop asm -n raw1
srvctl stop asm -n raw2
srvctl stop nodeapps -n raw1
srvctl stop nodeapps -n raw2
啟動RAC:
和上面的步驟正好相反即
srvctl start nodeapps -n raw1
srvctl start nodeapps -n raw2
srvctl start asm -n raw1
srvctl start asm -n raw2
srvctl start instance -d raw -i raw2
srvctl start instance -d orcl -i raw1
emctl start dbconsole
使用 SRVCTL 啟動/停止所有執行個體及其啟用的服務。
srvctl start database -d orcl
srvctl stop database -d orcl
註:CRS Resource 包括GSD(Global Serveice Daemon),ONS(Oracle Notification Service),VIP, Database, Instance 和 Service. 這些資源被分成2類:
GSD,ONS,VIP 和 Listener 屬於Noteapps類
Database,Instance 和Service 屬於 Database-Related Resource 類。
四、在啟動的過程中最好檢測著crs、ASM和資料庫的日誌:
crs日誌:
[oracle@rac1 ~]$ tail -f /u01/app/oracle/product/10.2.0/crs_1/log/rac1/alertrac1.log
[oracle@rac2 ~]$ tail -f /u01/app/oracle/product/10.2.0/crs_1/log/rac2/alertrac2.log
ASM日誌:
[oracle@rac1 ~]$ tail -f /u01/app/oracle/admin/+ASM/bdump/alert_+ASM1.log
[oracle@rac2 ~]$ tail -f /u01/app/oracle/admin/+ASM/bdump/alert_+ASM2.log
資料庫日誌:
[oracle@rac1 ~]$ tail -f /u01/app/oracle/admin/ora9i/bdump/alert_ora9i1.log
[oracle@rac2 ~]$ tail -f /u01/app/oracle/admin/ora9i/bdump/alert_ora9i2.log
註:tail -f命令可用於監視另一個進程正在寫入的檔案的增長。