
我建立了一個高可用性系統心跳,我希望當主叢集出現故障並且輔助叢集被啟動時,Heartbeat 在其中啟動並執行 shell 腳本。
內容
/etc/ha.d/haresources
master IPaddr::10.0.0.1/24 test.sh
內容
/etc/ha.d/ha.cf
autojoin none debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local0 ucast ens32 10.0.0.3 ucast ens32 10.0.0.2 udpport 694 use_logd yes keepalive 1 deadtime 10 warntime 5 initdead 20 node master node slave auto_failback on
我給了腳本執行權限並將其放在路徑中/etc/init.d/
,但我仍然無法透過Heartbeat執行它,這種類型的過程可能嗎?
答案1
您可以透過多種不同的方式來實現這一目標。
您可以放入腳本,/etc/init.d/
但需要確保它符合 LSB:http://www.linux-ha.org/wiki/LSB_Resource_Agents
您可以為 Pacemaker 編寫 OCF 資源代理程式:http://www.linux-ha.org/doc/dev-guides/ra-dev-guide.html
或者您可以嘗試使用 ocf:heartbeat:anything 資源代理。它可以運行任意命令,但涉及它的設定/要求。在其中一個節點上執行以下命令以了解更多資訊:# crm ra info ocf:heartbeat:anything