zeldor.biz

Linux, programming and more

Copyright © 2023
Log in

Pacemaker create ocf resource

December 13, 2018 by Igor Drobot Leave a Comment

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

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

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}
}

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

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

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

crm configure primitive failover ocf:heartbeat:failover

Testcase: put a node into standby mode and see if you get an email.

Filed Under: Linux Tagged With: Cluster, Corosync, OCF

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *