Just imagine, your cluster is telling you if some resources getting stuck or manual interventions are required.
It could be a e-mail, push over notification or just a classic XMPP message.
This describes the basics of creating of own resources for your cluster.
Default installation provide a dummy template for your own resources, just make a copy for your purpose:
cp /usr/lib/ocf/resource.d/heartbeat/Dummy /usr/lib/ocf/resource.d/heartbeat/failover |
Replace all instances of Dummy and dummy with your resource name failover:
1 2 | sed -i 's/Dummy/Failover/g' /usr/lib/ocf/resource.d/heartbeat/failover sed -i 's/dummy/failover/g' /usr/lib/ocf/resource.d/heartbeat/failover |
Edit that resource and fill start stop and monitor functions with your logic out:
1 2 3 4 5 6 7 8 9 10 | failover_start() { failover_monitor # Your own trigger # echo "Send a mail on failover" | mail echo "failover occurred" > /var/log/cluster/failover.log if [ $? = $OCF_SUCCESS ]; then return $OCF_SUCCESS fi touch ${OCF_RESKEY_state} } |
Test the new created resource using the ocf-tester to see if your syntax is correct:
ocf-tester -n resourcename /usr/lib/ocf/resource.d/heartbeat/failover |
As an extra test, to see if the script you’ve created is correctly executed, you can do a manual test start of the resource:
1 2 | export OCF_ROOT=/usr/lib/ocf bash -x /usr/lib/ocf/resource.d/heartbeat/failover start |
Add resource to your cluster:
crm configure primitive failover ocf:heartbeat:failover |
Testcase: put a node into standby mode and see if you get an email.
Leave a Reply