Chapter 10. Configuring cluster resources
The format for the command to create a cluster resource is as follows:
pcs resource create resource_id [standard:[provider:]]type [resource_options] [op operation_action operation_options [operation_action operation options]...] [meta meta_options...] [clone [clone_options] | master [master_options] | --group group_name [--before resource_id | --after resource_id] | [bundle bundle_id] [--disabled] [--wait[=n]]
Key cluster resource creation options include the following:
When you specify the
--groupoption, the resource is added to the resource group named. If the group does not exist, this creates the group and adds this resource to the group.
--afteroptions specify the position of the added resource relative to a resource that already exists in a resource group.
--disabledoption indicates that the resource is not started automatically.
You can determine the behavior of a resource in a cluster by configuring constraints for that resource.
Resource creation examples
The following command creates a resource with the name
VirtualIP of standard
heartbeat, and type
IPaddr2. The floating address of this resource is 192.168.0.120, and the system will check whether the resource is running every 30 seconds.
pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.120 cidr_netmask=24 op monitor interval=30s
Alternately, you can omit the standard and provider fields and use the following command. This will default to a standard of
ocf and a provider of
pcs resource create VirtualIP IPaddr2 ip=192.168.0.120 cidr_netmask=24 op monitor interval=30s
Deleting a configured resource
Use the following command to delete a configured resource.
pcs resource delete resource_id
For example, the following command deletes an existing resource with a resource ID of
pcs resource delete VirtualIP
10.1. Resource agent identifiers
The identifiers that you define for a resource tell the cluster which agent to use for the resource, where to find that agent and what standards it conforms to. Table 10.1, “Resource Agent Identifiers”, describes these properties.
Table 10.1. Resource Agent Identifiers
The standard the agent conforms to. Allowed values and their meaning:
The name of the resource agent you wish to use, for example
The OCF spec allows multiple vendors to supply the same resource agent. Most of the agents shipped by Red Hat use
Table 10.2, “Commands to Display Resource Properties” summarizes the commands that display the available resource properties.
Table 10.2. Commands to Display Resource Properties
|pcs Display Command||Output|
| || |
Displays a list of all available resources.
| || |
Displays a list of available resource agent standards.
| || |
Displays a list of available resource agent providers.
| || |
Displays a list of available resources filtered by the specified string. You can use this command to display resources filtered by the name of a standard, a provider, or a type.
10.2. Displaying resource-specific parameters
For any individual resource, you can use the following command to display a description of the resource, the parameters you can set for that resource, and the default values that are set for the resource.
pcs resource describe [standard:[provider:]]type
For example, the following command displays information for a resource of type
pcs resource describe ocf:heartbeat:apacheThis is the resource agent for the Apache Web server. This resource agent operates both version 1.x and version 2.x Apache servers. ...
10.3. Configuring resource meta options
In addition to the resource-specific parameters, you can configure additional resource options for any resource. These options are used by the cluster to decide how your resource should behave.
Table 10.3, “Resource Meta Options” describes the resource meta options.
Table 10.3. Resource Meta Options
| || || |
If not all resources can be active, the cluster will stop lower priority resources in order to keep higher priority ones active.
| || || |
What state should the cluster attempt to keep this resource in? Allowed values:
* Stopped - Force the resource to be stopped
* Started - Allow the resource to be started (and in the case of promotable clones, promoted to master role if appropriate)
* Master - Allow the resource to be started and, if appropriate, promoted
* Slave - Allow the resource to be started, but only in Slave mode if the resource is promotable
| || || |
Is the cluster allowed to start and stop the resource? Allowed values:
| || |
Value to indicate how much the resource prefers to stay where it is.
| || |
Indicates under what conditions the resource can be started.
| || || |
How many failures may occur for this resource on a node, before this node is marked ineligible to host this resource. A value of 0 indicates that this feature is disabled (the node will never be marked ineligible); by contrast, the cluster treats
| || || |
Used in conjunction with the
| || || |
What should the cluster do if it ever finds the resource active on more than one node. Allowed values:
10.3.1. Changing the default value of a resource option
To change the default value of a resource option, use the following command.
pcs resource defaults options
For example, the following command resets the default value of
resource-stickiness to 100.
pcs resource defaults resource-stickiness=100
10.3.2. Displaying currently configured resource defaults
Omitting the options parameter from the
pcs resource defaults displays a list of currently configured default values for resource options. The following example shows the output of this command after you have reset the default value of
resource-stickiness to 100.
pcs resource defaultsresource-stickiness: 100
10.3.3. Setting meta options on resource creation
Whether you have reset the default value of a resource meta option or not, you can set a resource option for a particular resource to a value other than the default when you create the resource. The following shows the format of the
pcs resource create command you use when specifying a value for a resource meta option.
pcs resource create resource_id [standard:[provider:]]type [resource options] [meta meta_options...]
For example, the following command creates a resource with a
resource-stickiness value of 50.
pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.120 meta resource-stickiness=50
You can also set the value of a resource meta option for an existing resource, group, cloned resource, or master resource with the following command.
pcs resource meta resource_id | group_id | clone_id meta_options
In the following example, there is an existing resource named
dummy_resource. This command sets the
failure-timeout meta option to 20 seconds, so that the resource can attempt to restart on the same node in 20 seconds.
pcs resource meta dummy_resource failure-timeout=20s
After executing this command, you can display the values for the resource to verify that
failure-timeout=20s is set.
pcs resource config dummy_resourceResource: dummy_resource (class=ocf provider=heartbeat type=Dummy) Meta Attrs: failure-timeout=20s ...
10.4. Configuring resource groups
One of the most common elements of a cluster is a set of resources that need to be located together, start sequentially, and stop in the reverse order. To simplify this configuration, Pacemaker supports the concept of resource groups.
10.4.1. Creating a resource group
You create a resource group with the following command, specifying the resources to include in the group. If the group does not exist, this command creates the group. If the group exists, this command adds additional resources to the group. The resources will start in the order you specify them with this command, and will stop in the reverse order of their starting order.
pcs resource group add group_name resource_id [resource_id] ... [resource_id] [--before resource_id | --after resource_id]
You can use the
--after options of this command to specify the position of the added resources relative to a resource that already exists in the group.
You can also add a new resource to an existing group when you create the resource, using the following command. The resource you create is added to the group named group_name. If the group group_name does not exist, it will be created.
pcs resource create resource_id [standard:[provider:]]type [resource_options] [op operation_action operation_options] --group group_name
There is no limit to the number of resources a group can contain. The fundamental properties of a group are as follows.
- Resources are colocated within a group.
- Resources are started in the order in which you specify them. If a resource in the group cannot run anywhere, then no resource specified after that resource is allowed to run.
- Resources are stopped in the reverse order in which you specify them.
The following example creates a resource group named
shortcut that contains the existing resources
pcs resource group add shortcut IPaddr Email
In this example:
IPaddris started first, then
IPaddrcannot run anywhere, neither can
IPaddrin any way.
10.4.2. Removing a resource group
You remove a resource from a group with the following command. If there are no remaining resources in the group, this command removes the group itself.
pcs resource group remove group_name resource_id...
10.4.3. Displaying resource groups
The following command lists all currently configured resource groups.
pcs resource group list
10.4.4. Group options
You can set the following options for a resource group, and they maintain the same meaning as when they are set for a single resource:
is-managed. For information on resource meta options, see Configuring resource meta options.
10.4.5. Group stickiness
Stickiness, the measure of how much a resource wants to stay where it is, is additive in groups. Every active resource of the group will contribute its stickiness value to the group’s total. So if the default
resource-stickiness is 100, and a group has seven members, five of which are active, then the group as a whole will prefer its current location with a score of 500.
10.5. Determining resource behavior
You can determine the behavior of a resource in a cluster by configuring constraints for that resource. You can configure the following categories of constraints:
locationconstraints — A location constraint determines which nodes a resource can run on. For information on configuring location constraints, see Determining which nodes a resource can run on.
orderconstraints — An ordering constraint determines the order in which the resources run. For information on configuring ordering constraints, see Determining the order in which cluster resources are run.
colocationconstraints — A colocation constraint determines where resources will be placed relative to other resources. For information on colocation constraints, see Colocating cluster resources.
As a shorthand for configuring a set of constraints that will locate a set of resources together and ensure that the resources start sequentially and stop in reverse order, Pacemaker supports the concept of resource groups. After you have created a resource group, you can configure constraints on the group itself just as you configure constraints for individual resources. For information on resource groups, see Configuring resource groups.