1. 程式人生 > >linux 7安裝rac 11gR2時執行root.sh報錯找不到ohas服務(ohasd failed to start)

linux 7安裝rac 11gR2時執行root.sh報錯找不到ohas服務(ohasd failed to start)

執行root.sh指令碼的時候報錯

Adding Clusterware entries to inittab

ohasd failed to start
Failed to start the Clusterware. Last 20 lines of the alert log follow: 

含義:把叢集新增到inittab服務,啟動ohasd失敗

      inittab為linux初始化檔案系統時init初始化程式用到的配置檔案。這個檔案負責設定init初始化程式初始化指令碼在哪裡;每個執行級初始化時執行的命令; 開機、關機、重啟對應的命令;各執行級登陸時所執行的命令。

但是linux 7使用systemd替代了原來的initd來執行程序,重啟程序。

執行root.sh的時候,採用以前的initd來啟動ohasd服務,找不到目錄,所以啟動失敗

CentOS 7 使用systemd替換了SysV。Systemd目的是要取代Unix時代以來一直在使用的init系統,相容SysV和LSB的啟動指令碼,而且夠在程序啟動過程中更有效地引導載入服務。

systemd的特性有:

  • 支援並行化任務
  • 同時採用socket式與D-Bus匯流排式啟用服務
  • 按需啟動守護程序(daemon)
  • 利用 Linux 的 cgroups 監視程序
  • 支援快照和系統恢復
  • 維護掛載點和自動掛載點
  • 各服務間基於依賴關係進行精密控制

解決方法:

單獨在linux 7中為ohasd設定一個服務。

步驟如下
1. 建立服務ohas.service的服務檔案並賦予許可權

touch /usr/lib/systemd/system/ohas.service

chmod 777 /usr/lib/systemd/system/ohas.service



2. 往ohas.service服務檔案新增啟動ohasd的相關資訊

 vi /usr/lib/systemd/system/ohas.service

[Unit]
Description=Oracle High Availability Services
After=syslog.target


[Service]
ExecStart=/etc/init.d/init.ohasd run >/dev/null 2>&1 Type=simple
Restart=always


[Install]
WantedBy=multi-user.target


note:把紅色部分的內容新增到檔案裡面

3. 載入,啟動服務

重新載入守護程序

systemctl daemon-reload

設定守護程序自動啟動

systemctl enable ohas.service

手工啟動ohas服務

systemctl start ohas.service

4. 重新執行root.sh指令碼

sh root.sh

報錯消失

5:檢視ohas服務狀態

systemctl status ohas.service

可以看到ohasd已經處於running的狀態