31.3. Disabling, enabling, and banning cluster resources
In addition to the pcs resource move and pcs resource relocate commands, there are a variety of other commands you can use to control the behavior of cluster resources.
31.3.1. Disabling a cluster resource 复制链接链接已复制到粘贴板!
You can manually stop a running resource and prevent the cluster from starting it again with the following command. Depending on the rest of the configuration, such as constraints, options, and failures, the resource may remain started. If you specify the --wait option, pcs waits up to 'n' seconds for the resource to stop and then returns 0 if the resource is stopped or 1 if the resource has not stopped. If you do not specify n, it defaults to 60 minutes.
Simulating disabling a resource
Ensuring that disabling a resource would not have an effect on other resources can be impossible to do by hand when complex resource relations are set up. To determine what effect disabling a resource will have on other resources, use the pcs resource disable --simulate command to show the effects of disabling a resource while not changing the cluster configuration.
Safely disabling resources
You can specify that a resource be disabled only if disabling the resource would not have an effect on other resources.
-
The
pcs resource disable --safecommand disables a resource only if no other resources would be affected in any way, such as being migrated from one node to another. Thepcs resource safe-disablecommand is an alias for thepcs resource disable --safecommand. -
The
pcs resource disable --safe --no-strictcommand disables a resource only if no other resources would be stopped or demoted.
Determining the resource IDs of affected resources
The error report that the pcs resource disable --safe command generates if the safe disable operation fails contains the affected resource IDs. If you need to know only the resource IDs of resources that would be affected by disabling a resource, use the --brief option for the pcs resource disable --safe command, which does not provide the full simulation result and prints errors only.
Procedure
Stop a running resource and prevent the cluster from starting it again:
# pcs resource disable resource_id [--wait[=n]]
31.3.2. Enabling a cluster resource 复制链接链接已复制到粘贴板!
The following command allows the cluster to start a resource. Depending on the rest of the configuration, the resource may remain stopped. If you specify the --wait option, pcs will wait up to 'n' seconds for the resource to start and then return 0 if the resource is started or 1 if the resource has not started. If 'n' is not specified it defaults to 60 minutes.
Procedure
Use the following command to allow the cluster to start a resource:
pcs resource enable resource_id [--wait[=n]]
You can prevent a resource from running on a specified node, or on the current node if no node is specified.
Procedure
Prevent a resource from running on a specified node, or on the current node if no node is specified:
# pcs resource ban resource_id [node] [--promoted] [lifetime=lifetime] [--wait[=n]]注意When you execute the
pcs resource bancommand, this adds a -INFINITY location constraint to the resource to prevent it from running on the indicated node. You can execute thepcs resource clearor thepcs constraint deletecommand to remove the constraint. This does not necessarily move the resources back to the indicated node; where the resources can run at that point depends on how you have configured your resources initially. For information about resource constraints, see Determining which nodes a resource can run on.-
If you specify the
--promotedparameter of thepcs resource bancommand, the scope of the constraint is limited to the promoted role and you must specify promotable_id rather than resource_id. -
You can optionally configure a
lifetimeparameter for thepcs resource bancommand to indicate a period of time the constraint should remain. -
You can optionally configure a
--wait[=n]parameter for thepcs resource bancommand 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 is used.
31.3.4. Forcing a resource to start on the current node 复制链接链接已复制到粘贴板!
Use the debug-start parameter of the pcs resource command to force a specified resource to start on the current node, ignoring the cluster recommendations and printing the output from starting the resource. This is mainly used for debugging resources; starting resources on a cluster is (almost) always done by Pacemaker and not directly with a pcs command. If your resource is not starting, it is usually due to either a misconfiguration of the resource (which you debug in the system log), constraints that prevent the resource from starting, or the resource being disabled. You can use this command to test resource configuration, but it should not normally be used to start resources in a cluster.
Procedure
Use the
debug-startcommand to force a specified resource to start on the current node:# pcs resource debug-start resource_id