Heartbeat version 2.0 CIB STONITH example configuration


Below is a sample script to configure the ssh STONITH agent for the Heartbeat system. STONITH will reboot nodes when things go wrong to restore the integrity of the cluster.

The STONITH test program supports the -n option to list parameters and the -l option to list nodes. The following is an example of using it with the ssh agent:
# stonith -t ssh -n
# stonith -t ssh hostlist="node-0 node-1" -l

The hostlist tuple is the only configuration option for ssh. It is assumed that you have passwordless ssh logins allowed between root on all the nodes in the cluster so the host name list is all that’s needed.

The important thing to note about the constraint is that you are constraining the parent of the clones (which in this example has an ID of “DoFencing“) not a clone instance.

ssh is the simplest and in many ways least useful method of STONITH, but it’s good for an example as everyone knows it. Once you get ssh going it’ll be trivial to get the other methods working.

See below for the script to insert the XML in the CIB.

if [ "$1" = "start" ]; then
  cibadmin --obj_type resources --cib_create -p << END
  <clone id="DoFencing">
        <nvpair name="clone_max" value="2"/>
        <nvpair name="clone_node_max" value="1"/>
    <primitive id="child_DoFencing" class="stonith" type="ssh">
        <op name="monitor" interval="5s" timeout="20s"
        <op name="start" timeout="20s" prereq="nothing"/>
          <nvpair name="hostlist" value="node-0 node-1"/>
  sleep 1
  cibadmin --obj_type constraints --cib_create -p << END
  <rsc_location id="stonith-cons:0" rsc="DoFencing">
      <rule id="stonith-cons-rule-node-0" score="100000">
        <expression id="stonith-cons-rule-expression-node-0"
          attribute="#uname" operation="eq" value="node-0"/>
  cibadmin --obj_type constraints --cib_create -p << END
  <rsc_location id="stonith-cons:1" rsc="DoFencing">
      <rule id="stonith-cons-rule-node-1" score="100000">
        <expression id="stonith-cons-rule-expression-node-1"
          attribute="#uname" operation="eq" value="node-1"/>
  cibadmin -D --obj_type resources -X '<clone id="DoFencing">'
  cibadmin -D --obj_type constraints -X \
          '<rsc_location id="stonith-cons:0">'
  cibadmin -D --obj_type constraints -X \
          '<rsc_location id="stonith-cons:1">'


1 thought on “Heartbeat version 2.0 CIB STONITH example configuration”

Comments are closed.