集羣安裝完畢後,重啓計算機,集羣會跟在系統一起啓動。網上很多文章都說是在/etc/inittab中添加一行
h1:35:respawn:/etc/init.d/init.ohasd run >/dev/null 2>&1
但是在我裝出來的系統中,inittab中並沒有設置任何集羣啓動的信息。那麼集羣究竟是怎麼啓動的呢?
我們查看一下/etc/rc5.d或者/etc/rc3.d這個目錄下的腳本。
[root@11grac1 rc5.d]# ll S96ohasd lrwxrwxrwx 1 root root 17 Aug 13 11:11 S96ohasd -> /etc/init.d/ohasd
就是因爲有了這個,集羣纔會隨機啓動的。
ohasd是整個集羣的一個高可用服務,監控集羣中的各個進程。當集羣進程崩潰後,嘗試重啓這些進程。
系統啓動時,會調用
crsctl start has -nowait
那麼如何禁止集羣自啓動呢?
[root@11grac1 ~]# cd /u01/app/11.2.0/grid/bin/ [root@11grac1 bin]# ./crsctl disable crs CRS-4621: Oracle High Availability Services autostart is disabled.
/etc/oracle/scls_scr/11grac1/root/ohasdstr
這個腳本中的值控制着集羣是否可以自動啓動。
如何手工啓動集羣:
[root@11grac1 root]# /u01/app/11.2.0/grid/bin/crsctl start crs CRS-4123: Oracle High Availability Services has been started.
此命令先啓動ohasd,然後由ohasd啓動crsd、cssd等後臺進程
[root@11grac1 root]# /u01/app/11.2.0/grid/bin/crsctl check crs CRS-4638: Oracle High Availability Services is online CRS-4537: Cluster Ready Services is online CRS-4529: Cluster Synchronization Services is online CRS-4533: Event Manager is online
同時,它也會把數據庫、asm、監聽都一起啓動。
關閉集羣使用命令
[root@11grac1 root]# /u01/app/11.2.0/grid/bin/crsctl stop crs
如果想把這個集羣中的全部或大部分關閉,可以使用如下命令
[root@11grac1 root]# /u01/app/11.2.0/grid/bin/crsctl start cluster -all 或者 [root@11grac1 root]# /u01/app/11.2.0/grid/bin/crsctl start cluster -n 11grac1 11grac2
但是使用start cluster命令的前提是ohasd已經啓動。