1

I am testing using the OCF:Heartbeat:Dummy script and I want to make a very basic setup just to know it works and build on that.

The only information I can find was this web blog here. https://raymii.org/s/tutorials/Corosync_Pacemaker_-_Execute_a_script_on_failover.html

It has some typos but basically worked for me.

The script currently just contains the following :

sudo nano /usr/local/bin/failover.sh && sudo chmod +x /usr/local/bin/failover.sh

#!/bin/sh

touch /tmp/testfailover.sh

Here is my setup :

cp /usr/lib/ocf/resource.d/heartbeat/Dummy /usr/lib/ocf/resource.d/heartbeat/FailOverScript

sudo nano /usr/lib/ocf/resource.d/heartbeat/FailOverScript

dummy_start() {
    dummy_monitor
    /usr/local/bin/failover.sh
    if [ $? =  $OCF_SUCCESS ]; then
    return $OCF_SUCCESS
    fi
    touch ${OCF_RESKEY_state}
}

sed -i 's/Dummy/FailOverScript/g' /usr/lib/ocf/resource.d/heartbeat/FailOverScript



sed -i 's/dummy/FailOverScript/g' /usr/lib/ocf/resource.d/heartbeat/FailOverScript

pcs resource create FailOverScript ocf:heartbeat:FailOverScript op monitor interval="30"

The only testing I can really do :

[root@node2 ~]# /usr/lib/ocf/resource.d/heartbeat/FailOverScript start ; echo $?
DEBUG: default start : 0
0

ocf-tester doesn't seem to exist in the latest HA Software Suite, not really sure how to manually install it, but the script "half works".

The script doesn't need monitoring, its supposed to be very basic, but it seems to be flapping and giving me the following error code. Any idea's what to do?

FailOverScript (ocf::heartbeat:FailOverScript):        Started
node2

Failed Actions:
* FailOverScript_monitor_30000 on node2 'not running' (7): call=
24423, status=complete, exitreason='none',
    last-rc-change='Tue Aug 16 15:53:50 2016', queued=0ms, exec=
9ms

Example of what I want to do:

Cluster start

Script runs "start.sh"

Cluster fails over to node2.

On node1 script runs "fail.sh"

On node2 script runs "start.sh"

and vis versa if it fails the other direction.

Note: The script does work, I get /tmp/testfailover.sh. I even tried putting another script under dummy_stop to remove the file and that worked, but it just keeps flapping along removing/adding/removing/adding file and starting/failing/stoping/starting etc etc.

Thanks for reading!

  • I started just using ClusterMon and modifying the already existing/working scripts... – FreeSoftwareServers Sep 19 '16 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.