
Contents
Related Pages: v2/Concepts[1] v2/Concepts/Clones[2] outdated documentation[3]
Superset of a cloned resource.
Currently supports two states
master_max (default: 1)
master_node_max (default: 1)
In the example below we have specified that the WebServerIP resource should be a ClusteredIP. It will be started on at most 3 nodes and at most there can be 2 clone active on any given node. Instance 1 will serve the first "bucket", instance 2 the second and so on.
<master_slave id="MyCorpWWW" ordered="false" interleave="false" notify="false">
<instance_attributes>
<attributes>
<nvpair name="clone_max" value="3"/>
<nvpair name="clone_node_max" value="2"/>
<nvpair name="master_max" value="2"/>
<nvpair name="master_node_max" value="1"/>
</attributes>
</instance_attributes>
<primitive id="WebServerIP" class="ocf" type="IPaddr" provider="heartbeat">
<instance_attributes>
<attributes>
<nvpair name="ip" value="127.0.0.26"/>
</attributes>
</instance_attributes>
</primitive>
</master_slave>
If there are >=1 nodes available:
It is the responsibility of the OCFResourceAgent[4] to know what state the clone instance is in. The CRM knows what state it thinks the resource should be in, but in all cases it is the script which must understand the resource and determine it's true state.
You must define a monitor action for every role (e.g. Master, Slave, Started, Stopped) you wish to monitor. Please refer to the examples given in ClusterInformationBase/Actions[5].
During the start operation, Resource Agent scripts should call the crm_master command-line tool. This tool automatically detects both the resource and host and should be used to set a preference for being promoted. Based on this, master_max, and master_node_max, the instance(s) with the highest preference will be promoted. Instances with a negative or zero preference will never be promoted; a positive preference must be set for all eligible instances.
BeekhofG5::beekhof pengine # crm_master
usage: crm_master [-?VQ] -(D|G|v) [-l]
Options
--help (-?) : this help message
--verbose (-V) : turn on debug info. additional instances increase verbosity
--quiet (-Q) : Print only the value on stdout (use with -G)
--get-value (-G) : Retrieve rather than set the attribute
--delete-attr (-D) : Delete rather than set the attribute
--attr-value (-v) <string> : Value to use (ignored with -G)
--lifetime (-l) <string> : How long the preference lasts (reboot|forever)
This items listed here are in addition to the requirements for Clones[2].
ResourceAgents[6] are required to accurately report how many instances are active, inactive, masters and slaves. In monitor operations:
All OCF variables can normally be found in /usr/lib/ocf/resource.d/heartbeat/ocf-shellfuncs which should be the first thing included by a resource agent.
A Master/Slave Resource Agent must implement the promote and demote operations. The implementation is up to the user.
In addition to the environment variables added for clones[7], these variables are available to notify actions.
OCF_RESKEY_notify_operation (start|stop|promote|demote)
OCF_RESKEY_notify_{x}_resource
OCF_RESKEY_notify_ {x}_uname
Starting with 2.0.4, they will also be available to start, stop, promote and demote actions if notify="true" is set.
minus $OCF_RESKEY_notify_demote_resource
minus $OCF_RESKEY_notify_stop_resource
minus $OCF_RESKEY_notify_demote_resource
minus $OCF_RESKEY_notify_stop_resource
plus $OCF_RESKEY_notify_stop_resource
minus $OCF_RESKEY_notify_stop_resource
plus $OCF_RESKEY_notify_start_resource
minus $OCF_RESKEY_notify_demote_resource
minus $OCF_RESKEY_notify_stop_resource
plus $OCF_RESKEY_notify_start_resource
plus $OCF_RESKEY_notify_stop_resource
minus $OCF_RESKEY_notify_start_resource
minus $OCF_RESKEY_notify_stop_resource
plus $OCF_RESKEY_notify_start_resource
minus $OCF_RESKEY_notify_demote_resource
plus $OCF_RESKEY_notify_promote_resource
minus $OCF_RESKEY_notify_stop_resource
plus $OCF_RESKEY_notify_start_resource
minus $OCF_RESKEY_notify_promote_resource
plus $OCF_RESKEY_notify_stop_resource
minus $OCF_RESKEY_notify_start_resource
It is sometimes desirable to preferentially constrain the master instance of a master/slave resource to run on a particular node or set of nodes in the cluster.
The CIB snippet below will add prefer the node ace to be master of the resource ms-drbd1 by 100 points.
<rsc_location id="loc:ms-drbd1_likes_ace" rsc="ms-drbd1">
<rule id="rule:ms-drbd1_likes_ace" role="master" score="100">
<expression attribute="#uname" operation="eq" value="ace"/>
</rule>
</rsc_location>
It is sometimes desirable to preferentially constrain the slave instance of a master/slave resource to run on a particular node or set of nodes in the cluster.
However, since all resources go through slave status before becoming promoted, what we have to do is constrain it to avoid becoming master.
The CIB snippet below will prefer to promote any node but fred to be master of the resource drbd1 by 100 points. This is effectively the same as saying "we want fred to avoid becoming master if possible".
<rsc_location id="loc:drbd1_likes_fred" rsc="drbd1">
<rule id="rule:drbd1_likes_fred" role="master" score="100">
<expression attribute="#uname" operation="ne" value="fred">
</rule>
</rsc_location>
It is very common to want to have a certain resource run only on a node which is master for a given resource.
You can either make sure the resource is run on the master, which is the propably more common approach:
<rsc_order id="ms-drbd0_before_fs0" from="fs0" action="start" to="ms-drbd0" to_action="promote"/> <rsc_colocation id="fs0_on_ms-drbd0" to="ms-drbd0" to_role="master" from="fs0" score="infinity"/>
Translation:
Or you can make sure the resource is not run on the slave:
<rsc_order id="ms-drbd0_before_fs0" from="fs0" action="start" to="ms-drbd0" to_action="promote"/> <rsc_colocation id="fs0_not_on_stopped_ms-drbd0" to="ms-drbd0" to_role="stopped" from="fs0" score="-infinity"/> <rsc_colocation id="fs0_not_on_slave_ms-drbd0" to="ms-drbd0" to_role="slave" from="fs0" score="-infinity"/>
Translation:
Never run fs0 on a node where ms-drbd0 is stopped.
Never run fs0 on a node where ms-drbd0 is running as slave.
Only start fs0 after promoting ms-drbd0 to master.
Since the the total set of states for a master/slave resource is {stopped, slave, master}, this only allows it to run on a node which is running as master.
The idiom to use if you have a resource which you want to run on the slave node is similar to the colocation with master[8] case:
<rsc_colocation id="fs_on_drbd0" to="drbd0-partition" to_role="stopped" from="mount-drbd0" score="-infinity"/> <rsc_colocation id="fs_on_drbd0" to="drbd0-partition" to_role="master" from="mount-drbd0" score="-infinity"/>
Translation:
Never run fs_on_drbd0 on a node where drbd0-partition is stopped.
Never run fs_on_drbd0 on a node where drbd0-partition is running as master.
Since the the total set of states for a master/slave resource is {stopped, slave, master}, this only allows the resource to run on a node which is running as slave.
Question:
I don't know how to write the corresponding ordering rule for this case - to ensure that it only runs after being started OR after being demoted from master. Is it necessary? If it isn't necessary, then probably the ordering rule for the master case isn't needed either.
| [1] | http://www.linux-ha.org/v2/Concepts |
| [2] | http://www.linux-ha.org/v2/Concepts/Clones |
| [3] | http://www.linux-ha.org/ClusterResourceManager/MultiStateResources |
| [4] | http://www.linux-ha.org/OCFResourceAgent |
| [5] | http://www.linux-ha.org/ClusterInformationBase/Actions |
| [6] | http://www.linux-ha.org/ResourceAgents |
| [7] | http://www.linux-ha.org/v2/Concepts/MultiState |
| [8] | http://www.linux-ha.org/CIB/Idioms/ColoWithMaster |
This information provided courtesy of the Linux-HA project at http://linux-ha.org/