Chapter 3. Setting Up a Simple Resource

Contents

3.1. Configuring a Resource with the Heartbeat GUI
3.2. Manual Configuration of a Resource

Once your cluster is installed and set up as described in Chapter 2, Installation and Setup, you can start adding resources to your configuration. Configure resources either with the Heartbeat GUI or manually by using the command line tools.

In the following, find an example of how to configure an IP address as a resource either manually or with the Heartbeat GUI.

3.1. Configuring a Resource with the Heartbeat GUI

Creating a sample cluster resource and migrating it to another server can help you test to ensure your Heartbeat cluster is functioning properly. A simple resource to configure and migrate is an IP address.

Procedure 3.1. Creating an IP Address Cluster Resource

  1. Start the HA Management Client and log in to the cluster as described in Section 4.1, “Graphical HA Management Client”.

  2. Click Resources, then click Add New Item, or click the + button.

  3. Choose Native as the resource item type, then click OK.

  4. Enter a Resource ID (name) for the IP address resource. For example, ipaddress1.

  5. In the Type section of the page, scroll down the list and select IPaddr (OCF Resource Agent) as the resource type.

  6. In the Parameters section of the page, find the line that was added for the IP address resource, click the line once, then click the line again under the Value heading to open a text field.

  7. Add the IP address for the IP address cluster resource.

  8. Click the Add Parameter button and from the drop-down list, specify nic as Name and eth0 as Value, then click OK.

    The name and value are dependent on your hardware configuration and what you chose for the media configuration during the Heartbeat installation.

  9. Click the Add button at the bottom of the page to add the resource to the cluster.

  10. Select the resource in the left pane of the main window, then click Resources+Start to start the new resource on the cluster.

Procedure 3.2. Migrating Resources to Another Node

To migrate the newly created resource to another node in the cluster, you can use either the HA Management Client or the command line.

  1. It the command line, use the following command:

    crm_resource -M -r resource_name -H hostname 

    For example, to migrate a resource named ipaddress1 to a cluster node named node2, you would need to enter:

    crm_resource -M -r ipaddress1 -H node2
  2. To use the HA Management Client for migration, select the resource you want to migrate in the left pane of the main window and select Resources+Migrate Resource.

  3. In the new window, select ipaddress1 as Resource to migrate and select node1 from the To Node drop-down list.

3.2. Manual Configuration of a Resource

Resources are any type of service that a computer provides. Resources are known to Heartbeat when they may be controlled by RAs (Resource Agents), which are LSB scripts, OCF scripts, or legacy Heartbeat 1 resources. All resources are configured in the CIB (Cluster Information Base) in the resources section. For an overview of available resources, look at Appendix A, HB OCF Agents.

To add a resource to the current configuration, first write an XML file with the specific date for this resource. For example, to add the IP address 10.10.0.1 to your cluster, use the following example:

<primitive id="ip_1"1
    class="ocf" 2
    type="IPaddr" 2
    provider="heartbeat" 2 >
  <instance_attributes>
    <attributes>3
      <nvpair name="ip" value="10.10.0.1"4/>
    </attributes>
  </instance_attributes>
</primitive>

1

The value of the id attribute of the primitive tag may be chosen freely. Like all IDs in XML, it must be unique and should follow a system. For example, ip_1 may be read as the first ip primitive.

2

The three attributes class, type, and provider determine the exact script that is used for this primitive. In this example, the script is at /usr/lib/ocf/resource.d/heartbeat/IPaddr.

3

All the attributes for a resource agent are entered in a list of nvpair tags. This should not be confused with the XML attributes that are added, for example, to the primitive tag.

4

In this example, the RA attribute ip is set to 10.10.0.1. For the IPaddr RA, this RA attribute is mandatory, as can be seen in Appendix A, HB OCF Agents.

[Note]

When configuring a resource with Heartbeat, the same resource should not be initialized by init. Heartbeat should be responsible for all service start or stop actions.

To add this IPaddr configuration to the cluster, first save the configuration to a file named ip_1.xml. Add this file to the cluster configuration with the command:

cibadmin -o resources -C -x ip_1.xml 

If the configuration was successful, a new resource appears in crm_mon that is started on a random node of your cluster.


Heartbeat Guide