アプローチしては、似通ってくるけど3つぐらい
- 別ユーザのcronで自分のノードの状態を監視し、状態に応じてcrontab -u <ファイル>を実行する方法
- ha.cfの外部スクリプトでノードの状態を監視し、状態に応じてcrontab -u <ファイル>を実行する方法
- /etc/init.dにcrontab -u <ファイル>を実行するスクリプトを書いて、haresourceから起動させる方法
3がキレイだと思ったので、これを採用。
/etc/init.d/hacrontabとして
#!/bin/bash # get functions . /etc/init.d/functions # See how we were called. case "$1" in start) logger -s -t "$0" "setting up root crontab: /data/crontab/hacrontab" /usr/bin/crontab -u root /data/crontab/hacrontab echo ;; stop) logger -s -t "$0" "removing root crontab" /usr/bin/crontab -u root -r echo ;; status) echo "$0 status: " echo "crontab -u root -l:" crontab -u root -l ;; *) echo "Usage $0 (start|stop|status)" ;; esac exit 0
適当だけど…。
これを両方のノードに置き、/etc/haresourcesの最後にhacrontabを追加してheartbeatを再起動。
これでOKでした!
0 件のコメント:
コメントを投稿