[Pacemaker] Creating a safe cluster-node shutdown script (for when UPS goes OnBattery+LowBattery)
Giuseppe Ragusa
giuseppe.ragusa at hotmail.com
Fri Jul 4 05:16:31 UTC 2014
Hi all,
I'm trying to create a script as per subject (on CentOS 6.5, CMAN+Pacemaker, only DRBD+KVM active/passive resources; SNMP-UPS monitored by NUT).
Ideally I think that each node should stop (disable) all locally-running VirtualDomain resources (doing so cleanly demotes than downs the DRBD resources underneath), then put itself in standby and finally shutdown.
On further startup, manual intervention would be required to unstandby all nodes and enable resources (nodes already in standby and resources already disabled before blackout should be manually distinguished).
Is this strategy conceptually safe?
Unfortunately, various searches have turned out no "prior art" :)
This is my tentative script (consider it in the public domain):
------------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
# Note: "pcs cluster status" still has a small bug vs. CMAN-controlled Corosync and would always return != 0
pcs status > /dev/null 2>&1
STATUS=$?
# Detect if cluster is running at all on local node
# TODO: detect node already in standby and bypass this
if [ "${STATUS}" = 0 ]; then
local_node="$(cman_tool status | grep -i 'Node[[:space:]]*name:' | sed -e 's/^.*Node\s*name:\s*\([^[:space:]]*\).*$/\1/i')"
for local_resource in $(pcs status 2>/dev/null | grep "ocf::heartbeat:VirtualDomain.*${local_node}\\s*\$" | awk '{print $1}'); do
pcs resource disable "${local_resource}"
done
# TODO: each resource disabling above may return without waiting for complete stop - wait here for "no more resources active"? (but avoid endless loops)
pcs cluster standby "${local_node}"
fi
# Shut down gracefully anyway at the end
/sbin/shutdown -h +0
------------------------------------------------------------------------------------------------------------------------------------
Comments/suggestions/improvements are more than welcome.
Many thanks in advance.
Regards,
Giuseppe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clusterlabs.org/pipermail/pacemaker/attachments/20140704/d49fd05d/attachment-0003.html>
More information about the Pacemaker
mailing list