Contents
Resource groups are essentially a shortcut for creating a set of resources that need to:
They effectively correspond to one line from a version 1 haresources file.
In the example below we have defined an IP address, a database and an Apache instance. All three resources will be placed on the same machine, and will be started in the order listed, ie.
WebServerIP
WebServerDatabase
WebServerApache
and stopped in the reverse order.
<group id="MyCorpWWW">
<primitive id="WebServerIP" class="ocf" type="IPaddr" provider="heartbeat">
<instance_attributes>
<attributes>
<nvpair name="ip" value="127.0.0.26"/>
</attributes>
</instance_attributes>
</primitive>
<primitive id="WebServerDatabase" class="lsb" type="oracle" provider="heartbeat">
<instance_attributes>
<attributes>
<nvpair name="SID" value="webserver_db"/>
</attributes>
</instance_attributes>
</primitive>
<primitive id="WebServerApache" class="ocf" type="Apache" provider="heartbeat">
<instance_attributes>
<attributes>
<nvpair name="apache_config" value="/home/www.mycorp.com/conf/apache.conf"/>
</attributes>
</instance_attributes>
</primitive>
</group>
The group will implicitly define rules equivalent to:
<constraints>
<rsc_colocation id="ip_and_database"
from="WebServerDatabase" to="WebServerIP" score="INFINITY"/>
<rsc_order id="ip_before_database"
from="WebServerIP" action="start" type="before" to="WebServerDatabase" symmetrical="TRUE"/>
<rsc_colocation id="database_and_apache"
from="WebServerApache" to="WebServerDatabase" score="INFINITY"/>
<rsc_order id="database_before_apache"
from="WebServerDatabase" action="start" type="before" to="WebServerApache" symmetrical="TRUE"/>
</constraints>
Using constraints for the resource group as a whole is no different to a native resource... you just use the id of the group.
<rsc_location id="run_MyCorpWWW" rsc="MyCorpWWW">
<rule id="pref_run_WebServerIP" score="100">
<expression attribute="#uname" operation="eq" value="c001n01"/>
</rule>
</rsc_location>
Easy!
If we defined two more resources and had one start before MyCorpWWW and one after, the results are pretty much what you would expect.
<primitive id="Named" class="lsb" type="named"/> <primitive id="WwwStats" class="lsb" type="apache_stats"/> <rsc_order id="order_named_www" from="MyCorpWWW" action="start" type="after" to="Named"/> <rsc_order id="order_www_stats" from="MyCorpWWW" action="start" type="before" to="WwwStats"/>
Since the ordering constraints are symmetrical by default, this is the equivalent of
<primitive id="Named" class="lsb" type="named"/> <primitive id="WwwStats" class="lsb" type="apache_stats"/> <rsc_order id="start_order_named_www" from="MyCorpWWW" action="start" type="after" to="Named" symmetrical="false" /> <rsc_order id="start_order_www_stats" from="MyCorpWWW" action="start" type="before" to="WwwStats" symmetrical="false" /> <rsc_order id="stop_order_named_www" from="MyCorpWWW" action="stop" type="before" to="Named" symmetrical="false" /> <rsc_order id="stop_order_www_stats" from="MyCorpWWW" action="stop" type="after" to="WwwStats" symmetrical="false" />
If nothing was yet started, the order would be like this:
Start Named
Start WebServerIP
Start WebServerDatabase
Start WebServerApache
Start WwwStats
and likewise, the shutdown order would be:
Stop WwwStats
Stop WebServerApache
Stop WebServerDatabase
Stop WebServerIP
Stop Named
Ensuring that the WwwStats resource runs on the same machine as Apache is no different than before... we just use the id of the group.
<rsc_colocation id="same_stats" from="MyCorpWWW" to="WwwStats" score="INFINITY"/>