Pingd with resources on different networks

= HowTo use pingd with resources in different networks =

The first version of this HowTo was posted [here], but as it needs several adjustments for pacemaker, you will find the appropriate HowTo for pacemaker >=1.0 here.

I assume you know how to use pingd and set up a location constraint referring to the pingd attribute and that you are familiar with pacemaker in general.

What is this about?
Say we have a setup of 2 cluster nodes (node1, node2), which have two network interfaces each and are connected to two different networks (net1, net2). The cluster is running resources, which are only accessed on one network each (res1 on net1, res2 on net2).

Say both resources are running on node1 and the NIC for net1 on node1 dies (or whatever - say you cannot reach net1 from node1 anymore). Then you surely want res1 to move to node2, but you do not necessarily want to move res2, too as what would unnecessarily interrupt client connections to that resource.

The basic idea
So what you need is two attributes, one for each network, that reflect the node's connectivity to the networks.

Of course you could make pingd ping nodes on different networks, but that would not reflect the connectivity to one specific network.

What you can do with pingd is to start multiple instances, let each ping a different set of nodes (the set should reasonably be on the particular network) and have the instances set different attributes each. This way you can constraint your resource with the connectivity to a specific network.

Configuration
primitive pingdnet1 ocf:pacemaker:pingd params host_list=192.168.23.1 name=pingdnet1 clone cl-pingdnet1 pingdnet1 primitive pingdnet2 ocf:pacemaker:pingd params host_list=10.2.50.11 name=pingdnet2 clone cl-pingdnet2 pingdnet2
 * crm configure:

This will set the attributes "pingdnet1" and "pingdnet2" according to the number of hosts reachable.

And here is an example of how to use the new attributes in resource location constraints:

location res1-on-pingdnet1 res1 rule -inf: not_defined pingdnet1 or pingdnet1 lte 0 location res2-on-pingdnet2 res2 rule -inf: not_defined pingdnet2 or pingdnet2 lte 0
 * crm configure:

This will force res1 off of any node with a pingdnet1 attribute value of less or equal 0 or without a pingdnet1 attribute at all (and s/1/2/g)

Note: This will prevent res1 all its colocated resources from running at all if all your nodes lose network connection to the ping nodes in net1 (and of course s/1/2/g).