Chapter 8. Managing Cluster Resources
This chapter describes various commands you can use to manage cluster resources. It provides information on the following procedures.
8.1. Manually Moving Resources Around the Cluster
You can override the cluster and force resources to move from their current location. There are two occasions when you would want to do this:
- When a node is under maintenance, and you need to move all resources running on that node to a different node
- When individually specified resources needs to be moved
To move all resources running on a node to a different node, you put the node in standby mode. For information on putting a cluster node in standby node, see Section 4.4.5, “Standby Mode”.
You can move individually specified resources in either of the following ways.
- You can use the
pcs resource move
command to move a resource off a node on which it is currently running, as described in Section 8.1.1, “Moving a Resource from its Current Node”. - You can use the
pcs resource relocate run
command to move a resource to its preferred node, as determined by current cluster status, constraints, location of resources and other settings. For information on this command, see Section 8.1.2, “Moving a Resource to its Preferred Node”.
8.1.1. Moving a Resource from its Current Node
To move a resource off the node on which it is currently running, use the following command, specifying the resource_id of the resource as defined. Specify the
destination_node
if you want to indicate on which node to run the resource that you are moving.
pcs resource move resource_id [destination_node] [--master] [lifetime=lifetime]
Note
When you execute the
pcs resource move
command, this adds a constraint to the resource to prevent it from running on the node on which it is currently running. You can execute the pcs resource clear
or the pcs constraint delete
command to remove the constraint. This does not necessarily move the resources back to the original node; where the resources can run at that point depends on how you have configured your resources initially.
If you specify the
--master
parameter of the pcs resource move
command, the scope of the constraint is limited to the master role and you must specify master_id rather than resource_id.
You can optionally configure a
lifetime
parameter for the pcs resource move
command to indicate a period of time the constraint should remain. You specify the units of a lifetime
parameter according to the format defined in ISO 8601, which requires that you specify the unit as a capital letter such as Y (for years), M (for months), W (for weeks), D (for days), H (for hours), M (for minutes), and S (for seconds).
To distinguish a unit of minutes(M) from a unit of months(M), you must specify PT before indicating the value in minutes. For example, a
lifetime
parameter of 5M indicates an interval of five months, while a lifetime
parameter of PT5M indicates an interval of five minutes.
The
lifetime
parameter is checked at intervals defined by the cluster-recheck-interval
cluster property. By default this value is 15 minutes. If your configuration requires that you check this parameter more frequently, you can reset this value with the following command.
pcs property set cluster-recheck-interval=value
You can optionally configure a
--wait[=n]
parameter for the pcs resource move
command to indicate the number of seconds to wait for the resource to start on the destination node before returning 0 if the resource is started or 1 if the resource has not yet started. If you do not specify n, the default resource timeout will be used.
The following command moves the resource
resource1
to node example-node2
and prevents it from moving back to the node on which it was originally running for one hour and thirty minutes.
pcs resource move resource1 example-node2 lifetime=PT1H30M
The following command moves the resource
resource1
to node example-node2
and prevents it from moving back to the node on which it was originally running for thirty minutes.
pcs resource move resource1 example-node2 lifetime=PT30M
For information on resource constraints, see Chapter 7, Resource Constraints.
8.1.2. Moving a Resource to its Preferred Node
After a resource has moved, either due to a failover or to an administrator manually moving the node, it will not necessarily move back to its original node even after the circumstances that caused the failover have been corrected. To relocate resources to their preferred node, use the following command. A preferred node is determined by the current cluster status, constraints, resource location, and other settings and may change over time.
pcs resource relocate run [resource1] [resource2] ...
If you do not specify any resources, all resource are relocated to their preferred nodes.
This command calculates the preferred node for each resource while ignoring resource stickiness. After calculating the preferred node, it creates location constraints which will cause the resources to move to their preferred nodes. Once the resources have been moved, the constraints are deleted automatically. To remove all constraints created by the
pcs resource relocate run
command, you can enter the pcs resource relocate clear
command. To display the current status of resources and their optimal node ignoring resource stickiness, enter the pcs resource relocate show
command.