Archives

Categories

Another Heartbeat 2.0 STONITH example configuration

In a Heartbeat cluster installation it may not be possible to have one STONITH device be used to reboot all nodes. To support this it is possible to have multiple STONITH devices configured that will each be used to reboot different nodes in the cluster. In the following code section there is an example of how to configure STONITH for two separate ssh instances. Of course this is not useful apart from as an example of how to configure STONITH. It would be quite easy to change one of those ssh configuration entries to use IPMI or some more effective method of managing machines. My previous post on this topic has an example of a simpler ssh STONITH configuration.

It is convenient that the ssh method for rebooting nodes is available both as a shared object (which is used by the following example XML) and as a shell script (type external/ssh). The shell script can be used to give the same functionality as the shared object (with reduced performance) but the benefit is as an example of how to write external plugins. For a client I have just written an IPMI module that works with machines that have two Ethernet ports. When a server has two Ethernet ports you want to send an IPMI reset command to both of them in case the failure which requires a STONITH was triggered by a broken Ethernet cable. Unfortunately I can’t release the IPMI code at this time


#!/bin/bash
if [ "$1" = "start" ]; then
  cibadmin --obj_type resources --cib_create -p << END
  <clone id="Fence-node-0">
    <instance_attributes>
      <attributes>
        <nvpair name="clone_max" value="2"/>
        <nvpair name="clone_node_max" value="1"/>
      </attributes>
    </instance_attributes>
    <primitive id="child_Fence-node-0" class="stonith" type="ssh">
      <operations>
        <op name="monitor" interval="5s" timeout="20s" prereq="nothing"/>
        <op name="start" timeout="20s" prereq="nothing"/>
      </operations>
      <instance_attributes>
        <attributes>
          <nvpair name="hostlist" value="node-0"/>
        </attributes>
      </instance_attributes>
    </primitive>
  </clone>
END
  cibadmin --obj_type resources --cib_create -p << END
  <clone id="Fence-node-1">
    <instance_attributes>
      <attributes>
        <nvpair name="clone_max" value="2"/>
        <nvpair name="clone_node_max" value="1"/>
      </attributes>
    </instance_attributes>
    <primitive id="child_Fence-node-1" class="stonith" type="ssh">
      <operations>
        <op name="monitor" interval="5s" timeout="20s" prereq="nothing"/>
        <op name="start" timeout="20s" prereq="nothing"/>
      </operations>
      <instance_attributes>
        <attributes>
          <nvpair name="hostlist" value="node-1"/>
        </attributes>
      </instance_attributes>
    </primitive>
  </clone>
END
  sleep 1
  cibadmin --obj_type constraints --cib_create -p << END
  <rsc_location id="stonith-constraint-node-0:0" rsc="Fence-node-0">
      <rule id="stonith-constraint-rule-node-0:0" score="1000">
        <expression id="stonith-constraint-rule-expression-node-0:0"
          attribute="#uname" operation="eq" value="node-0"/>
      </rule>
  </rsc_location>
END
  cibadmin --obj_type constraints --cib_create -p << END
  <rsc_location id="stonith-constraint-node-0:1" rsc="Fence-node-0">
      <rule id="stonith-constraint-rule-node-0:1" score="1000">
        <expression id="stonith-constraint-rule-expression-node-0:1"
          attribute="#uname" operation="eq" value="node-1"/>
      </rule>
  </rsc_location>
END
  cibadmin --obj_type constraints --cib_create -p << END
  <rsc_location id="stonith-constraint-node-1:0" rsc="Fence-node-1">
      <rule id="stonith-constraint-rule-node-1:0" score="1000">
        <expression id="stonith-constraint-rule-expression-node-1:0"
          attribute="#uname" operation="eq" value="node-0"/>
      </rule>
  </rsc_location>
END
  cibadmin --obj_type constraints --cib_create -p << END
  <rsc_location id="stonith-constraint-node-1:1" rsc="Fence-node-1">
      <rule id="stonith-constraint-rule-node-1:1" score="1000">
        <expression id="stonith-constraint-rule-expression-node-1:1"
          attribute="#uname" operation="eq" value="node-1"/>
      </rule>
  </rsc_location>
END
else
  cibadmin -D --obj_type  constraints  -X \
  '<rsc_location id="stonith-constraint-node-0:0">'
  cibadmin -D --obj_type  constraints  -X \
  '<rsc_location id="stonith-constraint-node-0:1">'
  cibadmin -D --obj_type  constraints  -X \
  '<rsc_location id="stonith-constraint-node-1:0">'
  cibadmin -D --obj_type  constraints  -X \
  '<rsc_location id="stonith-constraint-node-1:1">'
  cibadmin -D --obj_type resources -X '<clone id="Fence-node-0">'
  cibadmin -D --obj_type resources -X '<clone id="Fence-node-1">'
fi

1 comment to Another Heartbeat 2.0 STONITH example configuration