This site best when viewed with a modern standards-compliant browser. We recommend Firefox Get Firefox!.

Linux-HA project logo
Providing Open Source High-Availability Software for Linux and other OSes since 1999.

USA Flag UK Flag

Japanese Flag

Homepage

About Us

Contact Us

Legal Info

How To Contribute

Security Issues

21 December 2007 Heartbeat release 2.1.3 is now out Download it and install it!

11 October 2007 NEW educational HA/DR Blog hosted by Alan Robertson

9 April 2007 Check out the Cool Heartbeat Screencasts: Installation, Intro to the GUI Part of the Heartbeat Education project

Last site update:
2008-05-17 03:53:40

Contents

  1. Introduction
  2. Example
  3. Location Constraints for Resource Groups
  4. Ordering Constraints and Resource Groups
  5. Co-locational Constraints and Resource Groups

Introduction

Resource groups are essentially a shortcut for creating a set of resources that need to:

  • be started on the same node, and
  • started and stopped sequentially

They effectively correspond to one line from a version 1 haresources file.

Example

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.

  1. WebServerIP

  2. WebServerDatabase

  3. 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>
     

Location Constraints for Resource Groups

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! :)

Ordering Constraints and Resource Groups

If we defined two more resources and had one start before MyCorpWWW and one after, the results are pretty much what you would expect.

  • Example:
    <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:

  1. Start Named

  2. Start WebServerIP

  3. Start WebServerDatabase

  4. Start WebServerApache

  5. Start WwwStats

and likewise, the shutdown order would be:

  1. Stop WwwStats

  2. Stop WebServerApache

  3. Stop WebServerDatabase

  4. Stop WebServerIP

  5. Stop Named

Co-locational Constraints and Resource Groups

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"/>