Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F1841444
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
182 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/doc/sphinx/Pacemaker_Explained/nodes.rst b/doc/sphinx/Pacemaker_Explained/nodes.rst
index 994f54d4ea..f19d7319f7 100644
--- a/doc/sphinx/Pacemaker_Explained/nodes.rst
+++ b/doc/sphinx/Pacemaker_Explained/nodes.rst
@@ -1,208 +1,216 @@
Cluster Nodes
-------------
.. Convert_to_RST:
== Defining a Cluster Node ==
Each node in the cluster will have an entry in the nodes section
containing its UUID, uname, and type.
.Example Corosync cluster node entry
======
[source,XML]
<node id="101" uname="pcmk-1"/>
======
In normal circumstances, the admin should let the cluster populate
this information automatically from the communications and membership
data.
- [[s-node-name]]
- == Where Pacemaker Gets the Node Name ==
+.. _node_name:
+
+Where Pacemaker Gets the Node Name
+##################################
+
+.. Convert_to_RST_2:
Traditionally, Pacemaker required nodes to be referred to by the value
returned by `uname -n`. This can be problematic for services that
require the `uname -n` to be a specific value (e.g. for a licence
file).
This requirement has been relaxed for clusters using Corosync 2.0 or later.
The name Pacemaker uses is:
. The value stored in +corosync.conf+ under *ring0_addr* in the *nodelist*, if it does not contain an IP address; otherwise
. The value stored in +corosync.conf+ under *name* in the *nodelist*; otherwise
. The value of `uname -n`
Pacemaker provides the `crm_node -n` command which displays the name
used by a running cluster.
If a Corosync *nodelist* is used, `crm_node --name-for-id` pass:[<replaceable>number</replaceable>] is also
available to display the name used by the node with the corosync
*nodeid* of pass:[<replaceable>number</replaceable>], for example: `crm_node --name-for-id 2`.
- [[s-node-attributes]]
- == Node Attributes ==
+.. _node_attributes:
+
+Node Attributes
+###############
+.. Convert_to_RST_3:
+
indexterm:[Node,attribute]
Pacemaker allows node-specific values to be specified using 'node attributes'.
A node attribute has a name, and may have a distinct value for each node.
While certain node attributes have specific meanings to the cluster, they are
mainly intended to allow administrators and resource agents to track any
information desired.
For example, an administrator might choose to define node attributes for how
much RAM and disk space each node has, which OS each uses, or which server room
rack each node is in.
Users can configure <<ch-rules,rules>> that use node attributes to affect
where resources are placed.
=== Setting and querying node attributes ===
Node attributes can be set and queried using the `crm_attribute` and
`attrd_updater` commands, so that the user does not have to deal with XML
configuration directly.
Here is an example of what XML configuration would be generated if an
administrator ran this command:
.Result of using crm_attribute to specify which kernel pcmk-1 is running
======
-------
# crm_attribute --type nodes --node pcmk-1 --name kernel --update $(uname -r)
-------
[source,XML]
-------
<node id="1" uname="pcmk-1">
<instance_attributes id="nodes-1-attributes">
<nvpair id="nodes-1-kernel" name="kernel" value="3.10.0-862.14.4.el7.x86_64"/>
</instance_attributes>
</node>
-------
======
To read back the value that was just set:
----
# crm_attribute --type nodes --node pcmk-1 --name kernel --query
scope=nodes name=kernel value=3.10.0-862.14.4.el7.x86_64
----
By specifying `--type nodes` the admin tells the cluster that this
attribute is persistent across reboots. There are also transient attributes
which are kept in the status section and are "forgotten" whenever the node
leaves the cluster. Administrators can use this section by specifying
`--type status`.
=== Special node attributes ===
Certain node attributes have special meaning to the cluster.
Node attribute names beginning with # are considered reserved for these
special attributes. Some special attributes do not start with #, for
historical reasons.
Certain special attributes are set automatically by the cluster, should never
be modified directly, and can be used only within <<ch-rules,rules>>;
these are listed under <<node-attribute-expressions>>.
For true/false values, the cluster considers a value of "1", "y", "yes", "on",
or "true" (case-insensitively) to be true, "0", "n", "no", "off", "false", or
unset to be false, and anything else to be an error.
.Node attributes with special significance
[width="95%",cols="2m,<5",options="header",align="center"]
|====
|Name |Description
| fail-count-*
| Attributes whose names start with +fail-count-+ are managed by the cluster
to track how many times particular resource operations have failed on this
node. These should be queried and cleared via the `crm_failcount` or
`crm_resource --cleanup` commands rather than directly.
indexterm:[Node,attribute,fail-count-]
indexterm:[fail-count-,Node attribute]
| last-failure-*
| Attributes whose names start with +last-failure-+ are managed by the cluster
to track when particular resource operations have most recently failed on
this node. These should be cleared via the `crm_failcount` or
`crm_resource --cleanup` commands rather than directly.
indexterm:[Node,attribute,last-failure-]
indexterm:[last-failure-,Node attribute]
| maintenance
| Similar to the +maintenance-mode+ <<s-cluster-options,cluster option>>, but for
a single node. If true, resources will not be started or stopped on the node,
resources and individual clone instances running on the node will become
unmanaged, and any recurring operations for those will be cancelled.
indexterm:[Node,attribute,maintenance]
indexterm:[maintenance,Node attribute]
| probe_complete
| This is managed by the cluster to detect when nodes need to be reprobed, and
should never be used directly.
indexterm:[Node,attribute,probe_complete]
indexterm:[probe_complete,Node attribute]
| resource-discovery-enabled
| If the node is a remote node, fencing is enabled, and this attribute is
explicitly set to false (unset means true in this case), resource discovery
(probes) will not be done on this node. This is highly discouraged; the
+resource-discovery+ location constraint property is preferred for this
purpose.
indexterm:[Node,attribute,resource-discovery-enabled]
indexterm:[resource-discovery-enabled,Node attribute]
| shutdown
| This is managed by the cluster to orchestrate the shutdown of a node,
and should never be used directly.
indexterm:[Node,attribute,shutdown]
indexterm:[shutdown,Node attribute]
| site-name
| If set, this will be used as the value of the +#site-name+ node attribute
used in rules. (If not set, the value of the +cluster-name+ cluster option
will be used as +#site-name+ instead.)
indexterm:[Node,attribute,site-name]
indexterm:[site-name,Node attribute]
| standby
| If true, the node is in standby mode. This is typically set and queried via
the `crm_standby` command rather than directly.
indexterm:[Node,attribute,standby]
indexterm:[standby,Node attribute]
| terminate
| If the value is true or begins with any nonzero number, the node will be
fenced. This is typically set by tools rather than directly.
indexterm:[Node,attribute,terminate]
indexterm:[terminate,Node attribute]
| #digests-*
| Attributes whose names start with +#digests-+ are managed by the cluster to
detect when <<s-unfencing,unfencing>> needs to be redone, and should never be
used directly.
indexterm:[Node,attribute,#digests-]
indexterm:[#digests-,Node attribute]
| #node-unfenced
| When the node was last unfenced (as seconds since the epoch). This is managed
by the cluster and should never be used directly.
indexterm:[Node,attribute,#node-unfenced]
indexterm:[#node-unfenced,Node attribute]
|====
[WARNING]
====
Restarting pacemaker on a node that is in single-node maintenance mode will
likely lead to undesirable effects. If +maintenance+ is set as a transient
attribute, it will be erased when pacemaker is stopped, which will immediately
take the node out of maintenance mode and likely get it fenced. Even if
permanent, if pacemaker is restarted, any resources active on the node will
have their local history erased when the node rejoins, so the cluster will no
longer consider them running on the node and thus will consider them managed
again, leading them to be started elsewhere. This behavior might be improved
in a future release.
====
diff --git a/doc/sphinx/Pacemaker_Explained/options.rst b/doc/sphinx/Pacemaker_Explained/options.rst
index 04eb4f437d..2261024423 100644
--- a/doc/sphinx/Pacemaker_Explained/options.rst
+++ b/doc/sphinx/Pacemaker_Explained/options.rst
@@ -1,500 +1,504 @@
Cluster-Wide Configuration
--------------------------
.. Convert_to_RST:
== Configuration Layout ==
The cluster is defined by the Cluster Information Base (CIB),
which uses XML notation. The simplest CIB, an empty one, looks like this:
.An empty configuration
======
[source,XML]
-------
<cib crm_feature_set="3.0.7" validate-with="pacemaker-1.2" admin_epoch="1" epoch="0" num_updates="0">
<configuration>
<crm_config/>
<nodes/>
<resources/>
<constraints/>
</configuration>
<status/>
</cib>
-------
======
The empty configuration above contains the major sections that make up a CIB:
* +cib+: The entire CIB is enclosed with a +cib+ tag. Certain fundamental settings
are defined as attributes of this tag.
** +configuration+: This section -- the primary focus of this document --
contains traditional configuration information such as what resources the
cluster serves and the relationships among them.
*** +crm_config+: cluster-wide configuration options
*** +nodes+: the machines that host the cluster
*** +resources+: the services run by the cluster
*** +constraints+: indications of how resources should be placed
** +status+: This section contains the history of each resource on each node.
Based on this data, the cluster can construct the complete current
state of the cluster. The authoritative source for this section
is the local executor (pacemaker-execd process) on each cluster node, and
the cluster will occasionally repopulate the entire section. For this
reason, it is never written to disk, and administrators are advised
against modifying it in any way.
In this document, configuration settings will be described as 'properties' or 'options'
based on how they are defined in the CIB:
* Properties are XML attributes of an XML element.
* Options are name-value pairs expressed as +nvpair+ child elements of an XML element.
Normally, you will use command-line tools that abstract the XML, so the
distinction will be unimportant; both properties and options are
cluster settings you can tweak.
== CIB Properties ==
Certain settings are defined by CIB properties (that is, attributes of the
+cib+ tag) rather than with the rest of the cluster configuration in the
+configuration+ section.
The reason is simply a matter of parsing. These options are used by the
configuration database which is, by design, mostly ignorant of the content it
holds. So the decision was made to place them in an easy-to-find location.
.CIB Properties
[width="95%",cols="2m,<5",options="header",align="center"]
|=========================================================
|Field |Description
| admin_epoch |
indexterm:[Configuration Version,Cluster]
indexterm:[Cluster,Option,Configuration Version]
indexterm:[admin_epoch,Cluster Option]
indexterm:[Cluster,Option,admin_epoch]
When a node joins the cluster, the cluster performs a check to see
which node has the best configuration. It asks the node with the highest
(+admin_epoch+, +epoch+, +num_updates+) tuple to replace the configuration on
all the nodes -- which makes setting them, and setting them correctly, very
important. +admin_epoch+ is never modified by the cluster; you can use this
to make the configurations on any inactive nodes obsolete. _Never set this
value to zero_. In such cases, the cluster cannot tell the difference between
your configuration and the "empty" one used when nothing is found on disk.
| epoch |
indexterm:[epoch,Cluster Option]
indexterm:[Cluster,Option,epoch]
The cluster increments this every time the configuration is updated (usually by
the administrator).
| num_updates |
indexterm:[num_updates,Cluster Option]
indexterm:[Cluster,Option,num_updates]
The cluster increments this every time the configuration or status is updated
(usually by the cluster) and resets it to 0 when epoch changes.
| validate-with |
indexterm:[validate-with,Cluster Option]
indexterm:[Cluster,Option,validate-with]
Determines the type of XML validation that will be done on the configuration.
If set to +none+, the cluster will not verify that updates conform to the
DTD (nor reject ones that don't). This option can be useful when
operating a mixed-version cluster during an upgrade.
|cib-last-written |
indexterm:[cib-last-written,Cluster Property]
indexterm:[Cluster,Property,cib-last-written]
Indicates when the configuration was last written to disk. Maintained by the
cluster; for informational purposes only.
|have-quorum |
indexterm:[have-quorum,Cluster Property]
indexterm:[Cluster,Property,have-quorum]
Indicates if the cluster has quorum. If false, this may mean that the
cluster cannot start resources or fence other nodes (see
+no-quorum-policy+ below). Maintained by the cluster.
|dc-uuid |
indexterm:[dc-uuid,Cluster Property]
indexterm:[Cluster,Property,dc-uuid]
Indicates which cluster node is the current leader. Used by the
cluster when placing resources and determining the order of some
events. Maintained by the cluster.
|=========================================================
+
+.. _cluster_options:
+
+Cluster Options
+###############
- [[s-cluster-options]]
- == Cluster Options ==
-
+.. Convert_to_RST_2:
+
Cluster options, as you might expect, control how the cluster behaves
when confronted with certain situations.
They are grouped into sets within the +crm_config+ section, and, in advanced
configurations, there may be more than one set. (This will be described later
in the section on <<ch-rules>> where we will show how to have the cluster use
different sets of options during working hours than during weekends.) For now,
we will describe the simple case where each option is present at most once.
You can obtain an up-to-date list of cluster options, including
their default values, by running the `man pacemaker-schedulerd` and
`man pacemaker-controld` commands.
.Cluster Options
[width="95%",cols="5m,2,<11",options="header",align="center"]
|=========================================================
|Option |Default |Description
| cluster-name | |
indexterm:[cluster-name,Cluster Property]
indexterm:[Cluster,Property,cluster-name]
An (optional) name for the cluster as a whole. This is mostly for users'
convenience for use as desired in administration, but this can be used
in the Pacemaker configuration in <<ch-rules,rules>> (as the
+#cluster-name+ <<node-attribute-expressions-special,node attribute>>). It may
also be used by higher-level tools when displaying cluster information, and by
certain resource agents (for example, the +ocf:heartbeat:GFS2+ agent stores the
cluster name in filesystem meta-data).
| dc-version | |
indexterm:[dc-version,Cluster Property]
indexterm:[Cluster,Property,dc-version]
Version of Pacemaker on the cluster's DC.
Determined automatically by the cluster.
Often includes the hash which identifies the exact Git changeset it was built
from. Used for diagnostic purposes.
| cluster-infrastructure | |
indexterm:[cluster-infrastructure,Cluster Property]
indexterm:[Cluster,Property,cluster-infrastructure]
The messaging stack on which Pacemaker is currently running.
Determined automatically by the cluster.
Used for informational and diagnostic purposes.
| no-quorum-policy | stop
a|
indexterm:[no-quorum-policy,Cluster Option]
indexterm:[Cluster,Option,no-quorum-policy]
What to do when the cluster does not have quorum. Allowed values:
* +ignore:+ continue all resource management
* +freeze:+ continue resource management, but don't recover resources from nodes not in the affected partition
* +stop:+ stop all resources in the affected cluster partition
* +demote:+ demote promotable resources and stop all other resources in the
affected cluster partition
* +suicide:+ fence all nodes in the affected cluster partition
| batch-limit | 0 |
indexterm:[batch-limit,Cluster Option]
indexterm:[Cluster,Option,batch-limit]
The maximum number of actions that the cluster may execute in parallel across
all nodes. The "correct" value will depend on the speed and load of your
network and cluster nodes. If zero, the cluster will impose a dynamically
calculated limit only when any node has high load.
| migration-limit | -1 |
indexterm:[migration-limit,Cluster Option]
indexterm:[Cluster,Option,migration-limit]
The number of <<s-migrating-resources,live migration>> actions that the cluster
is allowed to execute in parallel on a node. A value of -1 means unlimited.
| symmetric-cluster | TRUE |
indexterm:[symmetric-cluster,Cluster Option]
indexterm:[Cluster,Option,symmetric-cluster]
Can all resources run on any node by default?
| stop-all-resources | FALSE |
indexterm:[stop-all-resources,Cluster Option]
indexterm:[Cluster,Option,stop-all-resources]
Should the cluster stop all resources?
| stop-orphan-resources | TRUE |
indexterm:[stop-orphan-resources,Cluster Option]
indexterm:[Cluster,Option,stop-orphan-resources]
Should deleted resources be stopped? This value takes precedence over
+is-managed+ (i.e. even unmanaged resources will be stopped if deleted from
the configuration when this value is TRUE).
| stop-orphan-actions | TRUE |
indexterm:[stop-orphan-actions,Cluster Option]
indexterm:[Cluster,Option,stop-orphan-actions]
Should deleted actions be cancelled?
| start-failure-is-fatal | TRUE |
indexterm:[start-failure-is-fatal,Cluster Option]
indexterm:[Cluster,Option,start-failure-is-fatal]
Should a failure to start a resource on a particular node prevent further start
attempts on that node? If FALSE, the cluster will decide whether the same
node is still eligible based on the resource's current failure count
and +migration-threshold+ (see <<s-failure-handling>>).
| enable-startup-probes | TRUE |
indexterm:[enable-startup-probes,Cluster Option]
indexterm:[Cluster,Option,enable-startup-probes]
Should the cluster check for active resources during startup?
| maintenance-mode | FALSE |
indexterm:[maintenance-mode,Cluster Option]
indexterm:[Cluster,Option,maintenance-mode]
Should the cluster refrain from monitoring, starting and stopping resources?
| stonith-enabled | TRUE |
indexterm:[stonith-enabled,Cluster Option]
indexterm:[Cluster,Option,stonith-enabled]
Should failed nodes and nodes with resources that can't be stopped be
shot? If you value your data, set up a STONITH device and enable this.
If true, or unset, the cluster will refuse to start resources unless
one or more STONITH resources have been configured.
If false, unresponsive nodes are immediately assumed to be running no
resources, and resource takeover to online nodes starts without any
further protection (which means _data loss_ if the unresponsive node
still accesses shared storage, for example). See also the +requires+
meta-attribute in <<s-resource-options>>.
| stonith-action | reboot |
indexterm:[stonith-action,Cluster Option]
indexterm:[Cluster,Option,stonith-action]
Action to send to STONITH device. Allowed values are +reboot+ and +off+.
The value +poweroff+ is also allowed, but is only used for
legacy devices.
| stonith-timeout | 60s |
indexterm:[stonith-timeout,Cluster Option]
indexterm:[Cluster,Option,stonith-timeout]
How long to wait for STONITH actions (reboot, on, off) to complete
| stonith-max-attempts | 10 |
indexterm:[stonith-max-attempts,Cluster Option]
indexterm:[Cluster,Option,stonith-max-attempts]
How many times fencing can fail for a target before the cluster will no longer
immediately re-attempt it.
| stonith-watchdog-timeout | 0 |
indexterm:[stonith-watchdog-timeout,Cluster Option]
indexterm:[Cluster,Option,stonith-watchdog-timeout]
If nonzero, along with `have-watchdog=true` automatically set by the
cluster, when fencing is required, watchdog-based self-fencing
will be performed via SBD without requiring a fencing resource
explicitly configured.
If `stonith-watchdog-timeout` is set to a positive value, unseen
nodes are assumed to self-fence within this much time. +WARNING:+
It must be ensured that this value is larger than the
`SBD_WATCHDOG_TIMEOUT` environment variable on all nodes.
Pacemaker verifies the settings individually on all nodes and
prevents startup or shuts down if configured wrongly on the fly.
It's strongly recommended that `SBD_WATCHDOG_TIMEOUT` is set to
the same value on all nodes.
If `stonith-watchdog-timeout` is set to a negative value, and
`SBD_WATCHDOG_TIMEOUT` is set, twice that value will be used.
+WARNING:+ In this case, it's essential (currently not verified by
pacemaker) that `SBD_WATCHDOG_TIMEOUT` is set to the same value on
all nodes.
| concurrent-fencing | FALSE |
indexterm:[concurrent-fencing,Cluster Option]
indexterm:[Cluster,Option,concurrent-fencing]
Is the cluster allowed to initiate multiple fence actions concurrently?
| fence-reaction | stop |
indexterm:[fence-reaction,Cluster Option]
indexterm:[Cluster,Option,fence-reaction]
How should a cluster node react if notified of its own fencing? A cluster node
may receive notification of its own fencing if fencing is misconfigured, or if
fabric fencing is in use that doesn't cut cluster communication. Allowed values
are +stop+ to attempt to immediately stop pacemaker and stay stopped, or
+panic+ to attempt to immediately reboot the local node, falling back to stop
on failure. The default is likely to be changed to +panic+ in a future release.
'(since 2.0.3)'
| priority-fencing-delay | 0 |
indexterm:[priority-fencing-delay,Cluster Option]
indexterm:[Cluster,Option,priority-fencing-delay]
Apply specified delay for the fencings that are targeting the lost
nodes with the highest total resource priority in case we don't
have the majority of the nodes in our cluster partition, so that
the more significant nodes potentially win any fencing match,
which is especially meaningful under split-brain of 2-node
cluster. A promoted resource instance takes the base priority + 1
on calculation if the base priority is not 0. Any static/random
delays that are introduced by `pcmk_delay_base/max` configured
for the corresponding fencing resources will be added to this
delay. This delay should be significantly greater than, safely
twice, the maximum `pcmk_delay_base/max`. By default, priority
fencing delay is disabled. '(since 2.0.4)'
| cluster-delay | 60s |
indexterm:[cluster-delay,Cluster Option]
indexterm:[Cluster,Option,cluster-delay]
Estimated maximum round-trip delay over the network (excluding action
execution). If the DC requires an action to be executed on another
node, it will consider the action failed if it does not get a response
from the other node in this time (after considering the action's
own timeout). The "correct" value will depend on the speed and load of your
network and cluster nodes.
| dc-deadtime | 20s |
indexterm:[dc-deadtime,Cluster Option]
indexterm:[Cluster,Option,dc-deadtime]
How long to wait for a response from other nodes during startup.
The "correct" value will depend on the speed/load of your network and the type of switches used.
| cluster-ipc-limit | 500 |
indexterm:[cluster-ipc-limit,Cluster Option]
indexterm:[Cluster,Option,cluster-ipc-limit]
The maximum IPC message backlog before one cluster daemon will disconnect
another. This is of use in large clusters, for which a good value is the number
of resources in the cluster multiplied by the number of nodes. The default of
500 is also the minimum. Raise this if you see "Evicting client" messages for
cluster daemon PIDs in the logs.
| pe-error-series-max | -1 |
indexterm:[pe-error-series-max,Cluster Option]
indexterm:[Cluster,Option,pe-error-series-max]
The number of PE inputs resulting in ERRORs to save. Used when reporting problems.
A value of -1 means unlimited (report all).
| pe-warn-series-max | -1 |
indexterm:[pe-warn-series-max,Cluster Option]
indexterm:[Cluster,Option,pe-warn-series-max]
The number of PE inputs resulting in WARNINGs to save. Used when reporting problems.
A value of -1 means unlimited (report all).
| pe-input-series-max | -1 |
indexterm:[pe-input-series-max,Cluster Option]
indexterm:[Cluster,Option,pe-input-series-max]
The number of "normal" PE inputs to save. Used when reporting problems.
A value of -1 means unlimited (report all).
| placement-strategy | default |
indexterm:[placement-strategy,Cluster Option]
indexterm:[Cluster,Option,placement-strategy]
How the cluster should allocate resources to nodes (see <<s-utilization>>).
Allowed values are +default+, +utilization+, +balanced+, and +minimal+.
| node-health-strategy | none |
indexterm:[node-health-strategy,Cluster Option]
indexterm:[Cluster,Option,node-health-strategy]
How the cluster should react to node health attributes (see <<s-node-health>>).
Allowed values are +none+, +migrate-on-red+, +only-green+, +progressive+, and
+custom+.
| enable-acl | FALSE |
indexterm:[enable-acl,Cluster Option]
indexterm:[Cluster,Option,enable-acl]
Whether access control lists (ACLs) (see <<ch-acls>>) can be used to authorize
modifications to the CIB.
| node-health-base | 0 |
indexterm:[node-health-base,Cluster Option]
indexterm:[Cluster,Option,node-health-base]
The base health score assigned to a node. Only used when
+node-health-strategy+ is +progressive+.
| node-health-green | 0 |
indexterm:[node-health-green,Cluster Option]
indexterm:[Cluster,Option,node-health-green]
The score to use for a node health attribute whose value is +green+.
Only used when +node-health-strategy+ is +progressive+ or +custom+.
| node-health-yellow | 0 |
indexterm:[node-health-yellow,Cluster Option]
indexterm:[Cluster,Option,node-health-yellow]
The score to use for a node health attribute whose value is +yellow+.
Only used when +node-health-strategy+ is +progressive+ or +custom+.
| node-health-red | 0 |
indexterm:[node-health-red,Cluster Option]
indexterm:[Cluster,Option,node-health-red]
The score to use for a node health attribute whose value is +red+.
Only used when +node-health-strategy+ is +progressive+ or +custom+.
| cluster-recheck-interval | 15min |
indexterm:[cluster-recheck-interval,Cluster Option]
indexterm:[Cluster,Option,cluster-recheck-interval]
Pacemaker is primarily event-driven, and looks ahead to know when to recheck
the cluster for failure timeouts and most time-based rules. However, it will
also recheck the cluster after this amount of inactivity. This has two goals:
rules with +date_spec+ are only guaranteed to be checked this often, and it
also serves as a fail-safe for certain classes of scheduler bugs. A value of 0
disables this polling; positive values are a time interval.
| shutdown-lock | false |
The default of false allows active resources to be recovered elsewhere when
their node is cleanly shut down, which is what the vast majority of users will
want. However, some users prefer to make resources highly available only for
failures, with no recovery for clean shutdowns. If this option is true,
resources active on a node when it is cleanly shut down are kept "locked" to
that node (not allowed to run elsewhere) until they start again on that node
after it rejoins (or for at most shutdown-lock-limit, if set). Stonith
resources and Pacemaker Remote connections are never locked. Clone and bundle
instances and the master role of promotable clones are currently never locked,
though support could be added in a future release. Locks may be manually
cleared using the `--refresh` option of `crm_resource` (both the resource and
node must be specified; this works with remote nodes if their connection
resource's target-role is set to Stopped, but not if Pacemaker Remote is
stopped on the remote node without disabling the connection resource).
'(since 2.0.4)'
indexterm:[shutdown-lock,Cluster Option]
indexterm:[Cluster,Option,shutdown-lock]
| shutdown-lock-limit | 0 |
If shutdown-lock is true, and this is set to a nonzero time duration, locked
resources will be allowed to start after this much time has passed since the
node shutdown was initiated, even if the node has not rejoined. (This works
with remote nodes only if their connection resource's target-role is set to
Stopped.) '(since 2.0.4)'
indexterm:[shutdown-lock-limit,Cluster Option]
indexterm:[Cluster,Option,shutdown-lock-limit]
| remove-after-stop | FALSE |
indexterm:[remove-after-stop,Cluster Option]
indexterm:[Cluster,Option,remove-after-stop]
_Advanced Use Only:_ Should the cluster remove resources from the LRM after
they are stopped? Values other than the default are, at best, poorly tested and
potentially dangerous.
| startup-fencing | TRUE |
indexterm:[startup-fencing,Cluster Option]
indexterm:[Cluster,Option,startup-fencing]
_Advanced Use Only:_ Should the cluster shoot unseen nodes?
Not using the default is very unsafe!
| election-timeout | 2min |
indexterm:[election-timeout,Cluster Option]
indexterm:[Cluster,Option,election-timeout]
_Advanced Use Only:_ If you need to adjust this value, it probably indicates
the presence of a bug.
| shutdown-escalation | 20min |
indexterm:[shutdown-escalation,Cluster Option]
indexterm:[Cluster,Option,shutdown-escalation]
_Advanced Use Only:_ If you need to adjust this value, it probably indicates
the presence of a bug.
| join-integration-timeout | 3min |
indexterm:[join-integration-timeout,Cluster Option]
indexterm:[Cluster,Option,join-integration-timeout]
_Advanced Use Only:_ If you need to adjust this value, it probably indicates
the presence of a bug.
| join-finalization-timeout | 30min |
indexterm:[join-finalization-timeout,Cluster Option]
indexterm:[Cluster,Option,join-finalization-timeout]
_Advanced Use Only:_ If you need to adjust this value, it probably indicates
the presence of a bug.
| transition-delay | 0s |
indexterm:[transition-delay,Cluster Option]
indexterm:[Cluster,Option,transition-delay]
_Advanced Use Only:_ Delay cluster recovery for the configured interval to
allow for additional/related events to occur. Useful if your configuration is
sensitive to the order in which ping updates arrive.
Enabling this option will slow down cluster recovery under
all conditions.
|=========================================================
diff --git a/doc/sphinx/Pacemaker_Explained/resources.rst b/doc/sphinx/Pacemaker_Explained/resources.rst
index 9d6055e398..6e24844550 100644
--- a/doc/sphinx/Pacemaker_Explained/resources.rst
+++ b/doc/sphinx/Pacemaker_Explained/resources.rst
@@ -1,950 +1,964 @@
Cluster Resources
-----------------
.. Convert_to_RST:
[[s-resource-primitive]]
== What is a Cluster Resource? ==
indexterm:[Resource]
A resource is a service made highly available by a cluster.
The simplest type of resource, a 'primitive' resource, is described
in this chapter. More complex forms, such as groups and clones,
are described in later chapters.
Every primitive resource has a 'resource agent'. A resource agent is an
external program that abstracts the service it provides and present a
consistent view to the cluster.
This allows the cluster to be agnostic about the resources it manages.
The cluster doesn't need to understand how the resource works because
it relies on the resource agent to do the right thing when given a
`start`, `stop` or `monitor` command. For this reason, it is crucial that
resource agents are well-tested.
Typically, resource agents come in the form of shell scripts. However,
they can be written using any technology (such as C, Python or Perl)
that the author is comfortable with.
[[s-resource-supported]]
== Resource Classes ==
indexterm:[Resource,class]
Pacemaker supports several classes of agents:
* OCF
* LSB
* Upstart
* Systemd
* Service
* Fencing
* Nagios Plugins
=== Open Cluster Framework ===
indexterm:[Resource,OCF]
indexterm:[OCF,Resources]
indexterm:[Open Cluster Framework,Resources]
The OCF standard
footnote:[See https://github.com/ClusterLabs/OCF-spec/tree/master/ra . The
Pacemaker implementation has been somewhat extended from the OCF specs.]
is basically an extension of the Linux Standard Base conventions for
init scripts to:
* support parameters,
* make them self-describing, and
* make them extensible
OCF specs have strict definitions of the exit codes that actions must return.
footnote:[
The resource-agents source code includes the `ocf-tester` script, which
can be useful in this regard.
]
The cluster follows these specifications exactly, and giving the wrong
exit code will cause the cluster to behave in ways you will likely
find puzzling and annoying. In particular, the cluster needs to
distinguish a completely stopped resource from one which is in some
erroneous and indeterminate state.
Parameters are passed to the resource agent as environment variables, with the
special prefix +OCF_RESKEY_+. So, a parameter which the user thinks
of as +ip+ will be passed to the resource agent as +OCF_RESKEY_ip+. The
number and purpose of the parameters is left to the resource agent; however,
the resource agent should use the `meta-data` command to advertise any that it
supports.
The OCF class is the most preferred as it is an industry standard,
highly flexible (allowing parameters to be passed to agents in a
non-positional manner) and self-describing.
For more information, see the
http://www.linux-ha.org/wiki/OCF_Resource_Agents[reference] and
the 'Resource Agents' chapter of 'Pacemaker Administration'.
=== Linux Standard Base ===
indexterm:[Resource,LSB]
indexterm:[LSB,Resources]
indexterm:[Linux Standard Base,Resources]
'LSB' resource agents are more commonly known as 'init scripts'. If a full path
is not given, they are assumed to be located in +/etc/init.d+.
Commonly, they are provided by the OS distribution. In order to be used
with a Pacemaker cluster, they must conform to the LSB specification.
footnote:[
See
http://refspecs.linux-foundation.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
for the LSB Spec as it relates to init scripts.
]
[WARNING]
====
Many distributions or particular software packages claim LSB compliance
but ship with broken init scripts. For details on how to check whether
your init script is LSB-compatible, see the 'Resource Agents' chapter of
'Pacemaker Administration'. Common problematic violations of the LSB
standard include:
* Not implementing the +status+ operation at all
* Not observing the correct exit status codes for
+start+/+stop+/+status+ actions
* Starting a started resource returns an error
* Stopping a stopped resource returns an error
====
[IMPORTANT]
====
Remember to make sure the computer is _not_ configured to start any
services at boot time -- that should be controlled by the cluster.
====
[[s-resource-supported-systemd]]
=== Systemd ===
indexterm:[Resource,Systemd]
indexterm:[Systemd,Resources]
Some newer distributions have replaced the old
http://en.wikipedia.org/wiki/Init#SysV-style["SysV"] style of
initialization daemons and scripts with an alternative called
http://www.freedesktop.org/wiki/Software/systemd[Systemd].
Pacemaker is able to manage these services _if they are present_.
Instead of init scripts, systemd has 'unit files'. Generally, the
services (unit files) are provided by the OS distribution, but there
are online guides for converting from init scripts.
footnote:[For example,
http://0pointer.de/blog/projects/systemd-for-admins-3.html]
[IMPORTANT]
====
Remember to make sure the computer is _not_ configured to start any
services at boot time -- that should be controlled by the cluster.
====
=== Upstart ===
indexterm:[Resource,Upstart]
indexterm:[Upstart,Resources]
Some newer distributions have replaced the old
http://en.wikipedia.org/wiki/Init#SysV-style["SysV"] style of
initialization daemons (and scripts) with an alternative called
http://upstart.ubuntu.com/[Upstart].
Pacemaker is able to manage these services _if they are present_.
Instead of init scripts, upstart has 'jobs'. Generally, the
services (jobs) are provided by the OS distribution.
[IMPORTANT]
====
Remember to make sure the computer is _not_ configured to start any
services at boot time -- that should be controlled by the cluster.
====
=== System Services ===
indexterm:[Resource,System Services]
indexterm:[System Service,Resources]
Since there are various types of system services (+systemd+,
+upstart+, and +lsb+), Pacemaker supports a special +service+ alias which
intelligently figures out which one applies to a given cluster node.
This is particularly useful when the cluster contains a mix of
+systemd+, +upstart+, and +lsb+.
In order, Pacemaker will try to find the named service as:
. an LSB init script
. a Systemd unit file
. an Upstart job
=== STONITH ===
indexterm:[Resource,STONITH]
indexterm:[STONITH,Resources]
The STONITH class is used exclusively for fencing-related resources. This is
discussed later in <<ch-fencing>>.
=== Nagios Plugins ===
indexterm:[Resource,Nagios Plugins]
indexterm:[Nagios Plugins,Resources]
Nagios Plugins
footnote:[The project has two independent forks, hosted at
https://www.nagios-plugins.org/ and https://www.monitoring-plugins.org/. Output
from both projects' plugins is similar, so plugins from either project can be
used with pacemaker.]
allow us to monitor services on remote hosts.
Pacemaker is able to do remote monitoring with the plugins _if they are
present_.
A common use case is to configure them as resources belonging to a resource
container (usually a virtual machine), and the container will be restarted
if any of them has failed. Another use is to configure them as ordinary
resources to be used for monitoring hosts or services via the network.
The supported parameters are same as the long options of the plugin.
[[primitive-resource]]
== Resource Properties ==
These values tell the cluster which resource agent to use for the resource,
where to find that resource agent and what standards it conforms to.
.Properties of a Primitive Resource
[width="95%",cols="1m,<6",options="header",align="center"]
|=========================================================
|Field
|Description
|id
|Your name for the resource
indexterm:[id,Resource]
indexterm:[Resource,Property,id]
|class
|The standard the resource agent conforms to. Allowed values:
+lsb+, +nagios+, +ocf+, +service+, +stonith+, +systemd+, +upstart+
indexterm:[class,Resource]
indexterm:[Resource,Property,class]
|type
|The name of the Resource Agent you wish to use. E.g. +IPaddr+ or +Filesystem+
indexterm:[type,Resource]
indexterm:[Resource,Property,type]
|provider
|The OCF spec allows multiple vendors to supply the same
resource agent. To use the OCF resource agents supplied by
the Heartbeat project, you would specify +heartbeat+ here.
indexterm:[provider,Resource]
indexterm:[Resource,Property,provider]
|=========================================================
The XML definition of a resource can be queried with the `crm_resource` tool.
For example:
----
# crm_resource --resource Email --query-xml
----
might produce:
.A system resource definition
=====
[source,XML]
<primitive id="Email" class="service" type="exim"/>
=====
[NOTE]
=====
One of the main drawbacks to system services (LSB, systemd or
Upstart) resources is that they do not allow any parameters!
=====
////
See https://tools.ietf.org/html/rfc5737 for choice of example IP address
////
.An OCF resource definition
=====
[source,XML]
-------
<primitive id="Public-IP" class="ocf" type="IPaddr" provider="heartbeat">
<instance_attributes id="Public-IP-params">
<nvpair id="Public-IP-ip" name="ip" value="192.0.2.2"/>
</instance_attributes>
</primitive>
-------
=====
+
+.. _resource_options:
+
+Resource Options
+################
- [[s-resource-options]]
- == Resource Options ==
-
+.. Convert_to_RST_2:
+
Resources have two types of options: 'meta-attributes' and 'instance attributes'.
Meta-attributes apply to any type of resource, while instance attributes
are specific to each resource agent.
=== Resource Meta-Attributes ===
Meta-attributes are used by the cluster to decide how a resource should
behave and can be easily set using the `--meta` option of the
`crm_resource` command.
.Meta-attributes of a Primitive Resource
[width="95%",cols="2m,2,<5",options="header",align="center"]
|=========================================================
|Field
|Default
|Description
|priority
|0
|If not all resources can be active, the cluster will stop lower
priority resources in order to keep higher priority ones active.
indexterm:[priority,Resource Option]
indexterm:[Resource,Option,priority]
|target-role
|Started
a|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
<<s-resource-promotable,promotable clone resources>>, promoted to master if
appropriate)
* +Slave:+ Allow the resource to be started, but only in Slave mode if
the resource is <<s-resource-promotable,promotable>>
* +Master:+ Equivalent to +Started+
indexterm:[target-role,Resource Option]
indexterm:[Resource,Option,target-role]
|is-managed
|TRUE
|Is the cluster allowed to start and stop the resource? Allowed
values: +true+, +false+
indexterm:[is-managed,Resource Option]
indexterm:[Resource,Option,is-managed]
|maintenance
|FALSE
|Similar to the +maintenance-mode+ <<s-cluster-options,cluster option>>, but for
a single resource. If true, the resource will not be started, stopped, or
monitored on any node. This differs from +is-managed+ in that monitors will
not be run. Allowed values: +true+, +false+
indexterm:[maintenance,Resource Option]
indexterm:[Resource,Option,maintenance]
-
+
+.. _resource-stickiness:
+
+ placeholder
+
+.. Convert_to_RST_3:
+
|resource-stickiness
|1 for individual clone instances, 0 for all other resources
|A score that will be added to the current node when a resource is already
active. This allows running resources to stay where they are, even if
they would be placed elsewhere if they were being started from a stopped
state.
indexterm:[resource-stickiness,Resource Option]
indexterm:[Resource,Option,resource-stickiness]
|requires
|+quorum+ for resources with a +class+ of +stonith+,
otherwise +unfencing+ if unfencing is active in the cluster,
otherwise +fencing+ if +stonith-enabled+ is true, otherwise +quorum+
a|Conditions under which the resource can be started
Allowed values:
* +nothing:+ can always be started
* +quorum:+ The cluster can only start this resource if a majority of
the configured nodes are active
* +fencing:+ The cluster can only start this resource if a majority
of the configured nodes are active _and_ any failed or unknown nodes
have been <<ch-fencing,fenced>>
* +unfencing:+
The cluster can only start this resource if a majority
of the configured nodes are active _and_ any failed or unknown nodes
have been fenced _and_ only on nodes that have been
<<s-unfencing,unfenced>>
indexterm:[requires,Resource Option]
indexterm:[Resource,Option,requires]
|migration-threshold
|INFINITY
|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
constrast, the cluster treats INFINITY (the default) as a very large but
finite number. This option has an effect only if the failed operation
specifies +on-fail+ as +restart+ (the default), and additionally for
failed +start+ operations, if the cluster property +start-failure-is-fatal+
is +false+.
indexterm:[migration-threshold,Resource Option]
indexterm:[Resource,Option,migration-threshold]
|failure-timeout
|0
|How many seconds to wait before acting as if the failure had not
occurred, and potentially allowing the resource back to the node on
which it failed. A value of 0 indicates that this feature is disabled.
indexterm:[failure-timeout,Resource Option]
indexterm:[Resource,Option,failure-timeout]
|multiple-active
|stop_start
a|What should the cluster do if it ever finds the resource active on
more than one node? Allowed values:
* +block:+ mark the resource as unmanaged
* +stop_only:+ stop all active instances and leave them that way
* +stop_start:+ stop all active instances and start the resource in
one location only
indexterm:[multiple-active,Resource Option]
indexterm:[Resource,Option,multiple-active]
|allow-migrate
|TRUE for ocf:pacemaker:remote resources, FALSE otherwise
|Whether the cluster should try to "live migrate" this resource when it needs
to be moved (see <<s-migrating-resources>>)
|container-attribute-target
|
|Specific to bundle resources; see <<s-bundle-attributes>>
|remote-node
|
|The name of the Pacemaker Remote guest node this resource is associated with,
if any. If specified, this both enables the resource as a guest node and
defines the unique name used to identify the guest node. The guest must be
configured to run the Pacemaker Remote daemon when it is started. +WARNING:+
This value cannot overlap with any resource or node IDs.
|remote-port
|3121
|If +remote-node+ is specified, the port on the guest used for its
Pacemaker Remote connection. The Pacemaker Remote daemon on the guest must be
configured to listen on this port.
|remote-addr
|value of +remote-node+
|If +remote-node+ is specified, the IP address or hostname used to connect to
the guest via Pacemaker Remote. The Pacemaker Remote daemon on the guest
must be configured to accept connections on this address.
|remote-connect-timeout
|60s
|If +remote-node+ is specified, how long before a pending guest connection will
time out.
|=========================================================
As an example of setting resource options, if you performed the following
commands on an LSB Email resource:
-------
# crm_resource --meta --resource Email --set-parameter priority --parameter-value 100
# crm_resource -m -r Email -p multiple-active -v block
-------
the resulting resource definition might be:
.An LSB resource with cluster options
=====
[source,XML]
-------
<primitive id="Email" class="lsb" type="exim">
<meta_attributes id="Email-meta_attributes">
<nvpair id="Email-meta_attributes-priority" name="priority" value="100"/>
<nvpair id="Email-meta_attributes-multiple-active" name="multiple-active" value="block"/>
</meta_attributes>
</primitive>
-------
=====
In addition to the cluster-defined meta-attributes described above, you may
also configure arbitrary meta-attributes of your own choosing. Most commonly,
this would be done for use in <<ch-rules,rules>>. For example, an IT department
might define a custom meta-attribute to indicate which company department each
resource is intended for. To reduce the chance of name collisions with
cluster-defined meta-attributes added in the future, it is recommended to use
a unique, organization-specific prefix for such attributes.
[[s-resource-defaults]]
=== Setting Global Defaults for Resource Meta-Attributes ===
To set a default value for a resource option, add it to the
+rsc_defaults+ section with `crm_attribute`. For example,
----
# crm_attribute --type rsc_defaults --name is-managed --update false
----
would prevent the cluster from starting or stopping any of the
resources in the configuration (unless of course the individual
resources were specifically enabled by having their +is-managed+ set to
+true+).
=== Resource Instance Attributes ===
The resource agents of some resource classes (lsb, systemd and upstart 'not' among them)
can be given parameters which determine how they behave and which instance
of a service they control.
If your resource agent supports parameters, you can add them with the
`crm_resource` command. For example,
----
# crm_resource --resource Public-IP --set-parameter ip --parameter-value 192.0.2.2
----
would create an entry in the resource like this:
.An example OCF resource with instance attributes
=====
[source,XML]
-------
<primitive id="Public-IP" class="ocf" type="IPaddr" provider="heartbeat">
<instance_attributes id="params-public-ip">
<nvpair id="public-ip-addr" name="ip" value="192.0.2.2"/>
</instance_attributes>
</primitive>
-------
=====
For an OCF resource, the result would be an environment variable
called +OCF_RESKEY_ip+ with a value of +192.0.2.2+.
The list of instance attributes supported by an OCF resource agent can be
found by calling the resource agent with the `meta-data` command.
The output contains an XML description of all the supported
attributes, their purpose and default values.
.Displaying the metadata for the Dummy resource agent template
=====
----
# export OCF_ROOT=/usr/lib/ocf
# $OCF_ROOT/resource.d/pacemaker/Dummy meta-data
----
[source,XML]
-------
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="Dummy" version="1.0">
<version>1.0</version>
<longdesc lang="en">
This is a Dummy Resource Agent. It does absolutely nothing except
keep track of whether its running or not.
Its purpose in life is for testing and to serve as a template for RA writers.
NB: Please pay attention to the timeouts specified in the actions
section below. They should be meaningful for the kind of resource
the agent manages. They should be the minimum advised timeouts,
but they shouldn't/cannot cover _all_ possible resource
instances. So, try to be neither overly generous nor too stingy,
but moderate. The minimum timeouts should never be below 10 seconds.
</longdesc>
<shortdesc lang="en">Example stateless resource agent</shortdesc>
<parameters>
<parameter name="state" unique="1">
<longdesc lang="en">
Location to store the resource state in.
</longdesc>
<shortdesc lang="en">State file</shortdesc>
<content type="string" default="/var/run/Dummy-default.state" />
</parameter>
<parameter name="fake" unique="0">
<longdesc lang="en">
Fake attribute that can be changed to cause a reload
</longdesc>
<shortdesc lang="en">Fake attribute that can be changed to cause a reload</shortdesc>
<content type="string" default="dummy" />
</parameter>
<parameter name="op_sleep" unique="1">
<longdesc lang="en">
Number of seconds to sleep during operations. This can be used to test how
the cluster reacts to operation timeouts.
</longdesc>
<shortdesc lang="en">Operation sleep duration in seconds.</shortdesc>
<content type="string" default="0" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="monitor" timeout="20" interval="10" depth="0"/>
<action name="reload" timeout="20" />
<action name="migrate_to" timeout="20" />
<action name="migrate_from" timeout="20" />
<action name="validate-all" timeout="20" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
-------
=====
== Resource Operations ==
indexterm:[Resource,Action]
'Operations' are actions the cluster can perform on a resource by calling the
resource agent. Resource agents must support certain common operations such as
start, stop, and monitor, and may implement any others.
Operations may be explicitly configured for two purposes: to override defaults
for options (such as timeout) that the cluster will use whenever it initiates
the operation, and to run an operation on a recurring basis (for example, to
monitor the resource for failure).
.An OCF resource with a non-default start timeout
=====
[source,XML]
-------
<primitive id="Public-IP" class="ocf" type="IPaddr" provider="heartbeat">
<operations>
<op id="Public-IP-start" name="start" timeout="60s"/>
</operations>
<instance_attributes id="params-public-ip">
<nvpair id="public-ip-addr" name="ip" value="192.0.2.2"/>
</instance_attributes>
</primitive>
-------
=====
Pacemaker identifies operations by a combination of name and interval, so this
combination must be unique for each resource. That is, you should not configure
two operations for the same resource with the same name and interval.
-
- [[s-operation-properties]]
- === Operation Properties ===
-
+
+.. _operation_properties:
+
+Operation Properties
+____________________
+
+.. Convert_to_RST_4:
+
Operation properties may be specified directly in the +op+ element as
XML attributes, or in a separate +meta_attributes+ block as +nvpair+ elements.
XML attributes take precedence over +nvpair+ elements if both are specified.
.Properties of an Operation
[width="95%",cols="2m,3,<6",options="header",align="center"]
|=========================================================
|Field
|Default
|Description
|id
|
|A unique name for the operation.
indexterm:[id,Action Property]
indexterm:[Action,Property,id]
|name
|
|The action to perform. This can be any action supported by the agent; common
values include +monitor+, +start+, and +stop+.
indexterm:[name,Action Property]
indexterm:[Action,Property,name]
|interval
|0
|How frequently (in seconds) to perform the operation. A value of 0 means "when
needed". A positive value defines a 'recurring action', which is typically
used with <<s-resource-monitoring,monitor>>.
indexterm:[interval,Action Property]
indexterm:[Action,Property,interval]
|timeout
|
|How long to wait before declaring the action has failed
indexterm:[timeout,Action Property]
indexterm:[Action,Property,timeout]
|on-fail
a|Varies by action:
* +stop+: +fence+ if +stonith-enabled+ is true or +block+ otherwise
* +demote+: +on-fail+ of the +monitor+ action with +role+ set to +Master+, if
present, enabled, and configured to a value other than +demote+, or +restart+
otherwise
* all other actions: +restart+
a|The action to take if this action ever fails. Allowed values:
* +ignore:+ Pretend the resource did not fail.
* +block:+ Don't perform any further operations on the resource.
* +stop:+ Stop the resource and do not start it elsewhere.
* +demote:+ Demote the resource, without a full restart. This is valid only for
+promote+ actions, and for +monitor+ actions with both a nonzero +interval+
and +role+ set to +Master+; for any other action, a configuration error will
be logged, and the default behavior will be used.
* +restart:+ Stop the resource and start it again (possibly on a different node).
* +fence:+ STONITH the node on which the resource failed.
* +standby:+ Move _all_ resources away from the node on which the resource failed.
indexterm:[on-fail,Action Property]
indexterm:[Action,Property,on-fail]
|enabled
|TRUE
|If +false+, ignore this operation definition. This is typically used to pause
a particular recurring +monitor+ operation; for instance, it can complement
the respective resource being unmanaged (+is-managed=false+), as this alone
will <<s-monitoring-unmanaged,not block any configured monitoring>>.
Disabling the operation does not suppress all actions of the given type.
Allowed values: +true+, +false+.
indexterm:[enabled,Action Property]
indexterm:[Action,Property,enabled]
|record-pending
|TRUE
|If +true+, the intention to perform the operation is recorded so that
GUIs and CLI tools can indicate that an operation is in progress.
This is best set as an _operation default_ (see <<s-operation-defaults>>).
Allowed values: +true+, +false+.
indexterm:[enabled,Action Property]
indexterm:[Action,Property,enabled]
|role
|
|Run the operation only on node(s) that the cluster thinks should be in
the specified role. This only makes sense for recurring +monitor+ operations.
Allowed (case-sensitive) values: +Stopped+, +Started+, and in the
case of <<s-resource-promotable,promotable clone resources>>, +Slave+ and +Master+.
indexterm:[role,Action Property]
indexterm:[Action,Property,role]
|=========================================================
[NOTE]
====
When +on-fail+ is set to +demote+, recovery from failure by a successful demote
causes the cluster to recalculate whether and where a new instance should be
promoted. The node with the failure is eligible, so if master scores have not
changed, it will be promoted again.
There is no direct equivalent of +migration-threshold+ for the master role, but
the same effect can be achieved with a location constraint using a
<<ch-rules,rule>> with a node attribute expression for the resource's fail
count.
For example, to immediately ban the master role from a node with any failed
promote or master monitor:
[source,XML]
----
<rsc_location id="loc1" rsc="my_primitive">
<rule id="rule1" score="-INFINITY" role="Master" boolean-op="or">
<expression id="expr1" attribute="fail-count-my_primitive#promote_0"
operation="gte" value="1"/>
<expression id="expr2" attribute="fail-count-my_primitive#monitor_10000"
operation="gte" value="1"/>
</rule>
</rsc_location>
----
This example assumes that there is a promotable clone of the +my_primitive+
resource (note that the primitive name, not the clone name, is used in the
rule), and that there is a recurring 10-second-interval monitor configured for
the master role (fail count attributes specify the interval in milliseconds).
====
[[s-resource-monitoring]]
=== Monitoring Resources for Failure ===
When Pacemaker first starts a resource, it runs one-time +monitor+ operations
(referred to as 'probes') to ensure the resource is running where it's
supposed to be, and not running where it's not supposed to be. (This behavior
can be affected by the +resource-discovery+ location constraint property.)
Other than those initial probes, Pacemaker will 'not' (by default) check that
the resource continues to stay healthy.
footnote:[Currently, anyway. Automatic monitoring operations may be
added in a future version of Pacemaker.]
You must configure +monitor+ operations explicitly to perform these checks.
.An OCF resource with a recurring health check
=====
[source,XML]
-------
<primitive id="Public-IP" class="ocf" type="IPaddr" provider="heartbeat">
<operations>
<op id="Public-IP-start" name="start" timeout="60s"/>
<op id="Public-IP-monitor" name="monitor" interval="60s"/>
</operations>
<instance_attributes id="params-public-ip">
<nvpair id="public-ip-addr" name="ip" value="192.0.2.2"/>
</instance_attributes>
</primitive>
-------
=====
By default, a +monitor+ operation will ensure that the resource is running
where it is supposed to. The +target-role+ property can be used for further
checking.
For example, if a resource has one +monitor+ operation with
+interval=10 role=Started+ and a second +monitor+ operation with
+interval=11 role=Stopped+, the cluster will run the first monitor on any nodes
it thinks 'should' be running the resource, and the second monitor on any nodes
that it thinks 'should not' be running the resource (for the truly paranoid,
who want to know when an administrator manually starts a service by mistake).
[NOTE]
====
Currently, monitors with +role=Stopped+ are not implemented for
<<s-resource-clone,clone>> resources.
====
[[s-monitoring-unmanaged]]
=== Monitoring Resources When Administration is Disabled ===
Recurring +monitor+ operations behave differently under various administrative
settings:
* When a resource is unmanaged (by setting +is-managed=false+): No monitors
will be stopped.
+
If the unmanaged resource is stopped on a node where the cluster thinks it
should be running, the cluster will detect and report that it is not, but it
will not consider the monitor failed, and will not try to start the resource
until it is managed again.
+
Starting the unmanaged resource on a different node is strongly discouraged
and will at least cause the cluster to consider the resource failed, and
may require the resource's +target-role+ to be set to +Stopped+ then +Started+
to be recovered.
* When a node is put into standby: All resources will be moved away from the
node, and all +monitor+ operations will be stopped on the node, except those
specifying +role+ as +Stopped+ (which will be newly initiated if
appropriate).
* When the cluster is put into maintenance mode: All resources will be marked
as unmanaged. All monitor operations will be stopped, except those
specifying +role+ as +Stopped+ (which will be newly initiated if
appropriate). As with single unmanaged resources, starting
a resource on a node other than where the cluster expects it to be will
cause problems.
[[s-operation-defaults]]
=== Setting Global Defaults for Operations ===
You can change the global default values for operation properties
in a given cluster. These are defined in an +op_defaults+ section
of the CIB's +configuration+ section, and can be set with `crm_attribute`.
For example,
----
# crm_attribute --type op_defaults --name timeout --update 20s
----
would default each operation's +timeout+ to 20 seconds. If an
operation's definition also includes a value for +timeout+, then that
value would be used for that operation instead.
=== When Implicit Operations Take a Long Time ===
The cluster will always perform a number of implicit operations: +start+,
+stop+ and a non-recurring +monitor+ operation used at startup to check
whether the resource is already active. If one of these is taking too long,
then you can create an entry for them and specify a longer timeout.
.An OCF resource with custom timeouts for its implicit actions
=====
[source,XML]
-------
<primitive id="Public-IP" class="ocf" type="IPaddr" provider="heartbeat">
<operations>
<op id="public-ip-startup" name="monitor" interval="0" timeout="90s"/>
<op id="public-ip-start" name="start" interval="0" timeout="180s"/>
<op id="public-ip-stop" name="stop" interval="0" timeout="15min"/>
</operations>
<instance_attributes id="params-public-ip">
<nvpair id="public-ip-addr" name="ip" value="192.0.2.2"/>
</instance_attributes>
</primitive>
-------
=====
=== Multiple Monitor Operations ===
Provided no two operations (for a single resource) have the same name
and interval, you can have as many +monitor+ operations as you like.
In this way, you can do a superficial health check every minute and
progressively more intense ones at higher intervals.
To tell the resource agent what kind of check to perform, you need to
provide each monitor with a different value for a common parameter.
The OCF standard creates a special parameter called +OCF_CHECK_LEVEL+
for this purpose and dictates that it is "made available to the
resource agent without the normal +OCF_RESKEY+ prefix".
Whatever name you choose, you can specify it by adding an
+instance_attributes+ block to the +op+ tag. It is up to each
resource agent to look for the parameter and decide how to use it.
.An OCF resource with two recurring health checks, performing different levels of checks specified via +OCF_CHECK_LEVEL+.
=====
[source,XML]
-------
<primitive id="Public-IP" class="ocf" type="IPaddr" provider="heartbeat">
<operations>
<op id="public-ip-health-60" name="monitor" interval="60">
<instance_attributes id="params-public-ip-depth-60">
<nvpair id="public-ip-depth-60" name="OCF_CHECK_LEVEL" value="10"/>
</instance_attributes>
</op>
<op id="public-ip-health-300" name="monitor" interval="300">
<instance_attributes id="params-public-ip-depth-300">
<nvpair id="public-ip-depth-300" name="OCF_CHECK_LEVEL" value="20"/>
</instance_attributes>
</op>
</operations>
<instance_attributes id="params-public-ip">
<nvpair id="public-ip-level" name="ip" value="192.0.2.2"/>
</instance_attributes>
</primitive>
-------
=====
=== Disabling a Monitor Operation ===
The easiest way to stop a recurring monitor is to just delete it.
However, there can be times when you only want to disable it
temporarily. In such cases, simply add +enabled=false+ to the
operation's definition.
.Example of an OCF resource with a disabled health check
=====
[source,XML]
-------
<primitive id="Public-IP" class="ocf" type="IPaddr" provider="heartbeat">
<operations>
<op id="public-ip-check" name="monitor" interval="60s" enabled="false"/>
</operations>
<instance_attributes id="params-public-ip">
<nvpair id="public-ip-addr" name="ip" value="192.0.2.2"/>
</instance_attributes>
</primitive>
-------
=====
This can be achieved from the command line by executing:
----
# cibadmin --modify --xml-text '<op id="public-ip-check" enabled="false"/>'
----
Once you've done whatever you needed to do, you can then re-enable it with
----
# cibadmin --modify --xml-text '<op id="public-ip-check" enabled="true"/>'
----
diff --git a/doc/sphinx/Pacemaker_Explained/rules.rst b/doc/sphinx/Pacemaker_Explained/rules.rst
index 365e04c073..b897fffa1a 100644
--- a/doc/sphinx/Pacemaker_Explained/rules.rst
+++ b/doc/sphinx/Pacemaker_Explained/rules.rst
@@ -1,932 +1,948 @@
+.. index::
+ single: rule
+
+.. _rules:
+
Rules
-----
-.. Convert_to_RST:
-
- anchor:ch-rules[Chapter 8, Rules]
- indexterm:[Constraint,Rule]
-
- Rules can be used to make your configuration more dynamic, allowing values to
- change depending on the time or the value of a node attribute. Examples of
- things rules are useful for:
-
- * Set a higher value for <<s-resource-options,+resource-stickiness+>> during
- working hours, to minimize downtime, and a lower value on weekends, to allow
- resources to move to their most preferred locations when people aren't around
- to notice.
-
- * Automatically place the cluster into maintenance mode during a scheduled
- maintenance window.
-
- * Assign certain nodes and resources to a particular department via custom
- node attributes and meta-attributes, and add a single location constraint
- that restricts the department's resources to run only on those nodes.
-
- Each constraint type or property set that supports rules may contain one or more
- +rule+ elements specifying conditions under which the constraint or properties
- take effect. Examples later in this chapter will make this clearer.
-
- == Rule Properties ==
-
- indexterm:[XML element,rule element]
-
- .Attributes of a rule Element
- [width="95%",cols="2m,1,<5",options="header",align="center"]
- |=========================================================
-
- |Attribute
- |Default
- |Description
-
- |id
- |
- |A unique name for the rule (required)
- indexterm:[XML attribute,id attribute,rule element]
- indexterm:[XML element,rule element,id attribute]
-
- |role
- |+Started+
- |The rule is in effect only when the resource is in the specified
- role. Allowed values are +Started+, +Slave+, and +Master+. A rule
- with +role="Master"+ cannot determine the initial location of a
- clone instance and will only affect which of the active instances
- will be promoted.
- indexterm:[XML attribute,role attribute,rule element]
- indexterm:[XML element,rule element,role attribute]
-
- |score
- |
- |If this rule is used in a location constraint and evaluates to true, apply
- this score to the constraint. Only one of +score+ and +score-attribute+ may be
- used.
- indexterm:[XML attribute,score attribute,rule element]
- indexterm:[XML element,rule element,score attribute]
-
- |score-attribute
- |
- |If this rule is used in a location constraint and evaluates to true, use the
- value of this node attribute as the score to apply to the constraint. Only one
- of +score+ and +score-attribute+ may be used.
- indexterm:[XML attribute,score-attribute attribute,rule element]
- indexterm:[XML element,rule element,score-attribute attribute]
-
- |boolean-op
- |+and+
- |If this rule contains more than one condition, a value of +and+ specifies that
- the rule evaluates to true only if all conditions are true, and a value of
- +or+ specifies that the rule evaluates to true if any condition is true.
- indexterm:[XML attribute,boolean-op attribute,rule element]
- indexterm:[XML element,rule element,boolean-op attribute]
-
- |=========================================================
-
- A +rule+ element must contain one or more conditions. A condition may be an
- +expression+ element, a +date_expression+ element, or another +rule+ element.
-
- == Node Attribute Expressions ==
-
- [[node-attribute-expressions]]
- indexterm:[Rule,Node Attribute Expression]
- indexterm:[XML element,expression element]
-
- Expressions are rule conditions based on the values of node attributes.
-
- .Attributes of an expression Element
- [width="95%",cols="2m,1,<5",options="header",align="center"]
- |=========================================================
-
- |Field
- |Default
- |Description
-
- |id
- |
- |A unique name for the expression (required)
- indexterm:[XML attribute,id attribute,expression element]
- indexterm:[XML element,expression element,id attribute]
-
- |attribute
- |
- |The node attribute to test (required)
- indexterm:[XML attribute,attribute attribute,expression element]
- indexterm:[XML element,expression element,attribute attribute]
-
- |type
- |The default type for +lt+, +gt+, +lte+, and +gte+ operations is
- +number+ if either value contains a decimal point character, or
- +integer+ otherwise. The default type for all other operations is
- +string+. If a numeric parse fails for either value, then the values
- are compared as type +string+.
- |How the node attributes should be compared. Allowed values are
- +string+, +integer+, +number+, and +version+. +integer+ truncates
- floating-point values if necessary before performing an integer
- comparison. +number+ performs a floating-point comparison.
-
- indexterm:[XML attribute,type attribute,expression element]
- indexterm:[XML element,expression element,type attribute]
-
- |operation
- |
- a|The comparison to perform (required). Allowed values:
-
- * +lt:+ True if the node attribute value is less than the comparison value
- * +gt:+ True if the node attribute value is greater than the comparison value
- * +lte:+ True if the node attribute value is less than or equal to the comparison value
- * +gte:+ True if the node attribute value is greater than or equal to the comparison value
- * +eq:+ True if the node attribute value is equal to the comparison value
- * +ne:+ True if the node attribute value is not equal to the comparison value
- * +defined:+ True if the node has the named attribute
- * +not_defined:+ True if the node does not have the named attribute
- indexterm:[XML attribute,operation attribute,expression element]
- indexterm:[XML element,expression element,operation attribute]
-
- |value
- |
- |User-supplied value for comparison (required for operations other than
- +defined+ and +not_defined+)
- indexterm:[XML attribute,value attribute,expression element]
- indexterm:[XML element,expression element,value attribute]
-
- |value-source
- |+literal+
- a|How the +value+ is derived. Allowed values:
-
- * +literal+: +value+ is a literal string to compare against
- * +param+: +value+ is the name of a resource parameter to compare against (only
- valid in location constraints)
- * +meta+: +value+ is the name of a resource meta-attribute to compare against
- (only valid in location constraints)
- indexterm:[XML attribute,value-source attribute,expression element]
- indexterm:[XML element,expression element,value-source attribute]
-
- |=========================================================
-
- [[node-attribute-expressions-special]]
- In addition to custom node attributes defined by the administrator, the cluster
- defines special, built-in node attributes for each node that can also be used
- in rule expressions.
-
- .Built-in Node Attributes
- [width="95%",cols="1m,<5",options="header",align="center"]
- |=========================================================
-
- |Name
- |Value
-
- |#uname
- |Node <<s-node-name,name>>
-
- |#id
- |Node ID
-
- |#kind
- |Node type. Possible values are +cluster+, +remote+, and +container+. Kind is
- +remote+ for Pacemaker Remote nodes created with the +ocf:pacemaker:remote+
- resource, and +container+ for Pacemaker Remote guest nodes and bundle nodes
-
- |#is_dc
- |"true" if this node is a Designated Controller (DC), "false" otherwise
-
- |#cluster-name
- |The value of the +cluster-name+ cluster property, if set
-
- |#site-name
- |The value of the +site-name+ node attribute, if set, otherwise identical to
- +#cluster-name+
-
- |#role
- a|The role the relevant promotable clone resource has on this node. Valid only within
- a rule for a location constraint for a promotable clone resource.
-
- ////
- // if uncommenting, put a pipe in front of first two lines
- #ra-version
- The installed version of the resource agent on the node, as defined
- by the +version+ attribute of the +resource-agent+ tag in the agent's
- metadata. Valid only within rules controlling resource options. This can be
- useful during rolling upgrades of a backward-incompatible resource agent.
- '(coming in x.x.x)'
- ////
-
- |=========================================================
-
- == Date/Time Expressions ==
-
- indexterm:[Rule,Date/Time Expression]
- indexterm:[XML element,date_expression element]
-
- Date/time expressions are rule conditions based (as the name suggests) on the
- current date and time.
-
- A +date_expression+ element may optionally contain a +date_spec+ or +duration+
- element depending on the context.
-
- .Attributes of a date_expression Element
- [width="95%",cols="2m,<5",options="header",align="center"]
- |=========================================================
- |Field
- |Description
-
- |id
- |A unique name for the expression (required)
- indexterm:[XML attribute,id attribute,date_expression element]
- indexterm:[XML element,date_expression element,id attribute]
-
- |start
- |A date/time conforming to the http://en.wikipedia.org/wiki/ISO_8601[ISO8601]
- specification. May be used when +operation+ is +in_range+ (in which case at
- least one of +start+ or +end+ must be specified) or +gt+ (in which case
- +start+ is required).
- indexterm:[XML attribute,start attribute,date_expression element]
- indexterm:[XML element,date_expression element,start attribute]
-
- |end
- |A date/time conforming to the http://en.wikipedia.org/wiki/ISO_8601[ISO8601]
- specification. May be used when +operation+ is +in_range+ (in which case at
- least one of +start+ or +end+ must be specified) or +lt+ (in which case
- +end+ is required).
- indexterm:[XML attribute,end attribute,date_expression element]
- indexterm:[XML element,date_expression element,end attribute]
-
- |operation
- a|Compares the current date/time with the start and/or end date,
- depending on the context. Allowed values:
-
- * +gt:+ True if the current date/time is after +start+
- * +lt:+ True if the current date/time is before +end+
- * +in_range:+ True if the current date/time is after +start+ (if specified)
- and before either +end+ (if specified) or +start+ plus the value of the
- +duration+ element (if one is contained in the +date_expression+)
- * +date_spec:+ True if the current date/time matches the specification
- given in the contained +date_spec+ element (described below)
- indexterm:[XML attribute,operation attribute,date_expression element]
- indexterm:[XML element,date_expression element,operation attribute]
-
- |=========================================================
-
- [NOTE]
- ======
- There is no +eq+, +neq+, +gte+, or +lte+ operation, since they would be valid
- only for a single second.
- ======
-
- === Date Specifications ===
- indexterm:[Rule,Date/Time Expression,Date Specification]
- indexterm:[XML element,date_spec element]
-
- A +date_spec+ element is used to create a cron-like expression relating
- to time. Each field can contain a single number or range. Any field not
- supplied is ignored.
-
- .Attributes of a date_spec Element
- [width="95%",cols="2m,<5",options="header",align="center"]
- |=========================================================
-
- |Field
- |Description
-
- |id
- |A unique name for the object (required)
- indexterm:[XML attribute,id attribute,date_spec element]
- indexterm:[XML element,date_spec element,id attribute]
-
- |hours
- |Allowed values: 0-23 (where 0 is midnight and 23 is 11 p.m.)
- indexterm:[XML attribute,hours attribute,date_spec element]
- indexterm:[XML element,date_spec element,hours attribute]
-
- |monthdays
- |Allowed values: 1-31 (depending on month and year)
- indexterm:[XML attribute,monthdays attribute,date_spec element]
- indexterm:[XML element,date_spec element,monthdays attribute]
-
- |weekdays
- |Allowed values: 1-7 (where 1 is Monday and 7 is Sunday)
- indexterm:[XML attribute,weekdays attribute,date_spec element]
- indexterm:[XML element,date_spec element,weekdays attribute]
-
- |yeardays
- |Allowed values: 1-366 (depending on the year)
- indexterm:[XML attribute,yeardays attribute,date_spec element]
- indexterm:[XML element,date_spec element,yeardays attribute]
-
- |months
- |Allowed values: 1-12
- indexterm:[XML attribute,months attribute,date_spec element]
- indexterm:[XML element,date_spec element,months attribute]
-
- |weeks
- |Allowed values: 1-53 (depending on weekyear)
- indexterm:[XML attribute,weeks attribute,date_spec element]
- indexterm:[XML element,date_spec element,weeks attribute]
-
- |years
- |Year according to the Gregorian calendar
- indexterm:[XML attribute,years attribute,date_spec element]
- indexterm:[XML element,date_spec element,years attribute]
-
- |weekyears
- |Year in which the week started; for example, 1 January 2005 can be specified
- in ISO 8601 as '2005-001 Ordinal', '2005-01-01 Gregorian' or
- '2004-W53-6 Weekly' and thus would match +years="2005"+ or +weekyears="2004"+
- indexterm:[XML attribute,weekyears attribute,date_spec element]
- indexterm:[XML element,date_spec element,weekyears attribute]
-
- |moon
- |Allowed values are 0-7 (where 0 is the new moon and 4 is full moon).
- Seriously, you can use this. This was implemented to demonstrate the ease with
- which new comparisons could be added.
- indexterm:[XML attribute,moon attribute,date_spec element]
- indexterm:[XML element,date_spec element,moon attribute]
-
- |=========================================================
-
- For example, +monthdays="1"+ matches the first day of every month, and
- +hours="09-17"+ matches the hours between 9 a.m. and 5 p.m. (inclusive).
-
- At this time, multiple ranges (e.g. +weekdays="1,2"+ or +weekdays="1-2,5-6"+)
- are not supported.
-
- [NOTE]
- ====
- Pacemaker can calculate when evaluation of a +date_expression+ with an
- +operation+ of +gt+, +lt+, or +in_range+ will next change, and schedule a
- cluster re-check for that time. However, it does not do this for +date_spec+.
- Instead, it evaluates the +date_spec+ whenever a cluster re-check naturally
- happens via a cluster event or the +cluster-recheck-interval+ cluster option.
- For example, if you have a +date_spec+ enabling a resource from 9 a.m. to 5 p.m.,
- and +cluster-recheck-interval+ has been set to 5 minutes, then sometime between
- 9 a.m. and 9:05 a.m. the cluster would notice that it needs to start the
- resource, and sometime between 5 p.m. and 5:05 p.m. it would realize that it
- needs to stop the resource. The timing of the actual start and stop actions
- will further depend on factors such as any other actions the cluster may need
- to perform first, and the load of the machine.
- ====
-
- === Durations ===
- indexterm:[Rule,Date/Time Expression,Duration]
- indexterm:[XML element,duration element]
-
- A +duration+ is used to calculate a value for +end+ when one is not supplied to
- +in_range+ operations. It contains one or more attributes each containing a
- single number. Any attribute not supplied is ignored.
-
- .Attributes of a duration Element
- [width="95%",cols="2m,<5",options="header",align="center"]
- |=========================================================
-
- |Field
- |Description
-
- |id
- |A unique name for this duration element (required)
- indexterm:[XML attribute,id attribute,duration element]
- indexterm:[XML element,duration element,id attribute]
-
- |seconds
- |This many seconds will be added to the total duration
- indexterm:[XML attribute,seconds attribute,duration element]
- indexterm:[XML element,duration element,seconds attribute]
-
- |minutes
- |This many minutes will be added to the total duration
- indexterm:[XML attribute,minutes attribute,duration element]
- indexterm:[XML element,duration element,minutes attribute]
-
- |hours
- |This many hours will be added to the total duration
- indexterm:[XML attribute,hours attribute,duration element]
- indexterm:[XML element,duration element,hours attribute]
-
- |weeks
- |This many weeks will be added to the total duration
- indexterm:[XML attribute,weeks attribute,duration element]
- indexterm:[XML element,duration element,weeks attribute]
-
- |months
- |This many months will be added to the total duration
- indexterm:[XML attribute,months attribute,duration element]
- indexterm:[XML element,duration element,months attribute]
-
- |years
- |This many years will be added to the total duration
- indexterm:[XML attribute,years attribute,duration element]
- indexterm:[XML element,duration element,years attribute]
-
- |=========================================================
-
- === Example Time-Based Expressions ===
-
- A small sample of how time-based expressions can be used:
-
- .True if now is any time in the year 2005
- ====
- [source,XML]
- ----
- <rule id="rule1" score="INFINITY">
- <date_expression id="date_expr1" start="2005-001" operation="in_range">
- <duration id="duration1" years="1"/>
- </date_expression>
- </rule>
- ----
- ====
-
- .Equivalent expression
- ====
- [source,XML]
- ----
- <rule id="rule2" score="INFINITY">
- <date_expression id="date_expr2" operation="date_spec">
- <date_spec id="date_spec2" years="2005"/>
- </date_expression>
- </rule>
- ----
- ====
-
- .9am-5pm Monday-Friday
- ====
- [source,XML]
- -------
- <rule id="rule3" score="INFINITY">
- <date_expression id="date_expr3" operation="date_spec">
- <date_spec id="date_spec3" hours="9-16" weekdays="1-5"/>
- </date_expression>
- </rule>
- -------
- ====
-
- Please note that the +16+ matches up to +16:59:59+, as the numeric
- value (hour) still matches!
-
- .9am-6pm Monday through Friday or anytime Saturday
- ====
- [source,XML]
- -------
- <rule id="rule4" score="INFINITY" boolean-op="or">
- <date_expression id="date_expr4-1" operation="date_spec">
- <date_spec id="date_spec4-1" hours="9-16" weekdays="1-5"/>
- </date_expression>
- <date_expression id="date_expr4-2" operation="date_spec">
- <date_spec id="date_spec4-2" weekdays="6"/>
- </date_expression>
- </rule>
- -------
- ====
-
- .9am-5pm or 9pm-12am Monday through Friday
- ====
- [source,XML]
- -------
- <rule id="rule5" score="INFINITY" boolean-op="and">
- <rule id="rule5-nested1" score="INFINITY" boolean-op="or">
- <date_expression id="date_expr5-1" operation="date_spec">
- <date_spec id="date_spec5-1" hours="9-16"/>
- </date_expression>
- <date_expression id="date_expr5-2" operation="date_spec">
- <date_spec id="date_spec5-2" hours="21-23"/>
- </date_expression>
+Rules can be used to make your configuration more dynamic, allowing values to
+change depending on the time or the value of a node attribute. Examples of
+things rules are useful for:
+
+* Set a higher value for :ref:`resource-stickiness <resource-stickiness>`
+ during working hours, to minimize downtime, and a lower value on weekends, to
+ allow resources to move to their most preferred locations when people aren't
+ around to notice.
+
+* Automatically place the cluster into maintenance mode during a scheduled
+ maintenance window.
+
+* Assign certain nodes and resources to a particular department via custom
+ node attributes and meta-attributes, and add a single location constraint
+ that restricts the department's resources to run only on those nodes.
+
+Each constraint type or property set that supports rules may contain one or more
+``rule`` elements specifying conditions under which the constraint or properties
+take effect. Examples later in this chapter will make this clearer.
+
+.. index::
+ pair: XML element; rule
+
+Rule Properties
+###############
+
+.. table:: **Attributes of a rule Element**
+
+ +-----------------+-------------+-------------------------------------------+
+ | Attribute | Default | Description |
+ +=================+=============+===========================================+
+ | id | | .. index:: |
+ | | | pair: rule; id |
+ | | | |
+ | | | A unique name for this element (required) |
+ +-----------------+-------------+-------------------------------------------+
+ | role | ``Started`` | .. index:: |
+ | | | pair: rule; role |
+ | | | |
+ | | | The rule is in effect only when the |
+ | | | resource is in the specified role. |
+ | | | Allowed values are ``Started``, ``Slave``,|
+ | | | and ``Master``. A rule with a ``role`` of |
+ | | | ``Master`` cannot determine the initial |
+ | | | location of a clone instance and will |
+ | | | only affect which of the active instances |
+ | | | will be promoted. |
+ +-----------------+-------------+-------------------------------------------+
+ | score | | .. index:: |
+ | | | pair: rule; score |
+ | | | |
+ | | | If this rule is used in a location |
+ | | | constraint and evaluates to true, apply |
+ | | | this score to the constraint. Only one of |
+ | | | ``score`` and ``score-attribute`` may be |
+ | | | used. |
+ +-----------------+-------------+-------------------------------------------+
+ | score-attribute | | .. index:: |
+ | | | pair: rule; score-attribute |
+ | | | |
+ | | | If this rule is used in a location |
+ | | | constraint and evaluates to true, use the |
+ | | | value of this node attribute as the score |
+ | | | to apply to the constraint. Only one of |
+ | | | ``score`` and ``score-attribute`` may be |
+ | | | used. |
+ +-----------------+-------------+-------------------------------------------+
+ | boolean-op | ``and`` | .. index:: |
+ | | | pair: rule; boolean-op |
+ | | | |
+ | | | If this rule contains more than one |
+ | | | condition, a value of ``and`` specifies |
+ | | | that the rule evaluates to true only if |
+ | | | all conditions are true, and a value of |
+ | | | ``or`` specifies that the rule evaluates |
+ | | | to true if any condition is true. |
+ +-----------------+-------------+-------------------------------------------+
+
+A ``rule`` element must contain one or more conditions. A condition may be an
+``expression`` element, a ``date_expression`` element, or another ``rule`` element.
+
+
+.. index::
+ single: rule; node attribute expression
+ single: node attribute; rule expression
+ pair: XML element; expression
+
+.. _node_attribute_expressions:
+
+Node Attribute Expressions
+##########################
+
+Expressions are rule conditions based on the values of node attributes.
+
+.. table:: **Attributes of an expression Element**
+
+ +--------------+---------------------------------+-------------------------------------------+
+ | Attribute | Default | Description |
+ +==============+=================================+===========================================+
+ | id | | .. index:: |
+ | | | pair: expression; id |
+ | | | |
+ | | | A unique name for this element (required) |
+ +--------------+---------------------------------+-------------------------------------------+
+ | attribute | | .. index:: |
+ | | | pair: expression; attribute |
+ | | | |
+ | | | The node attribute to test (required) |
+ +--------------+---------------------------------+-------------------------------------------+
+ | type | The default type for | .. index:: |
+ | | ``lt``, ``gt``, ``lte``, and | pair: expression; type |
+ | | ``gte`` operations is ``number``| |
+ | | if either value contains a | How the node attributes should be |
+ | | decimal point character, or | compared. Allowed values are ``string``, |
+ | | ``integer`` otherwise. The | ``integer``, ``number``, and ``version``. |
+ | | default type for all other | ``integer`` truncates floating-point |
+ | | operations is ``string``. If a | values if necessary before performing an |
+ | | numeric parse fails for either | integer comparison. ``number`` performs a |
+ | | value, then the values are | floating-point comparison. |
+ | | compared as type ``string``. | |
+ +--------------+---------------------------------+-------------------------------------------+
+ | operation | | .. index:: |
+ | | | pair: expression; operation |
+ | | | |
+ | | | The comparison to perform (required). |
+ | | | Allowed values: |
+ | | | |
+ | | | * ``lt:`` True if the node attribute value|
+ | | | is less than the comparison value |
+ | | | * ``gt:`` True if the node attribute value|
+ | | | is greater than the comparison value |
+ | | | * ``lte:`` True if the node attribute |
+ | | | value is less than or equal to the |
+ | | | comparison value |
+ | | | * ``gte:`` True if the node attribute |
+ | | | value is greater than or equal to the |
+ | | | comparison value |
+ | | | * ``eq:`` True if the node attribute value|
+ | | | is equal to the comparison value |
+ | | | * ``ne:`` True if the node attribute value|
+ | | | is not equal to the comparison value |
+ | | | * ``defined:`` True if the node has the |
+ | | | named attribute |
+ | | | * ``not_defined:`` True if the node does |
+ | | | not have the named attribute |
+ +--------------+---------------------------------+-------------------------------------------+
+ | value | | .. index:: |
+ | | | pair: expression; value |
+ | | | |
+ | | | User-supplied value for comparison |
+ | | | (required for operations other than |
+ | | | ``defined`` and ``not_defined``) |
+ +--------------+---------------------------------+-------------------------------------------+
+ | value-source | ``literal`` | .. index:: |
+ | | | pair: expression; value-source |
+ | | | |
+ | | | How the ``value`` is derived. Allowed |
+ | | | values: |
+ | | | |
+ | | | * ``literal``: ``value`` is a literal |
+ | | | string to compare against |
+ | | | * ``param``: ``value`` is the name of a |
+ | | | resource parameter to compare against |
+ | | | (only valid in location constraints) |
+ | | | * ``meta``: ``value`` is the name of a |
+ | | | resource meta-attribute to compare |
+ | | | against (only valid in location |
+ | | | constraints) |
+ +--------------+---------------------------------+-------------------------------------------+
+
+.. _node-attribute-expressions-special:
+
+In addition to custom node attributes defined by the administrator, the cluster
+defines special, built-in node attributes for each node that can also be used
+in rule expressions.
+
+.. table:: **Built-in Node Attributes**
+
+ +---------------+-----------------------------------------------------------+
+ | Name | Value |
+ +===============+===========================================================+
+ | #uname | :ref:`Node name <node_name>` |
+ +---------------+-----------------------------------------------------------+
+ | #id | Node ID |
+ +---------------+-----------------------------------------------------------+
+ | #kind | Node type. Possible values are ``cluster``, ``remote``, |
+ | | and ``container``. Kind is ``remote`` for Pacemaker Remote|
+ | | nodes created with the ``ocf:pacemaker:remote`` resource, |
+ | | and ``container`` for Pacemaker Remote guest nodes and |
+ | | bundle nodes |
+ +---------------+-----------------------------------------------------------+
+ | #is_dc | ``true`` if this node is the cluster's Designated |
+ | | Controller (DC), ``false`` otherwise |
+ +---------------+-----------------------------------------------------------+
+ | #cluster-name | The value of the ``cluster-name`` cluster property, if set|
+ +---------------+-----------------------------------------------------------+
+ | #site-name | The value of the ``site-name`` node attribute, if set, |
+ | | otherwise identical to ``#cluster-name`` |
+ +---------------+-----------------------------------------------------------+
+ | #role | The role the relevant promotable clone resource has on |
+ | | this node. Valid only within a rule for a location |
+ | | constraint for a promotable clone resource. |
+ +---------------+-----------------------------------------------------------+
+
+.. Add_to_above_table_if_released:
+
+ +---------------+-----------------------------------------------------------+
+ | #ra-version | The installed version of the resource agent on the node, |
+ | | as defined by the ``version`` attribute of the |
+ | | ``resource-agent`` tag in the agent's metadata. Valid only|
+ | | within rules controlling resource options. This can be |
+ | | useful during rolling upgrades of a backward-incompatible |
+ | | resource agent. '(since x.x.x)' |
+
+
+.. index::
+ single: rule; date/time expression
+ pair: XML element; date_expression
+
+Date/Time Expressions
+#####################
+
+Date/time expressions are rule conditions based (as the name suggests) on the
+current date and time.
+
+A ``date_expression`` element may optionally contain a ``date_spec`` or
+``duration`` element depending on the context.
+
+.. table:: **Attributes of a date_expression Element**
+
+ +---------------+-----------------------------------------------------------+
+ | Attribute | Description |
+ +===============+===========================================================+
+ | id | .. index:: |
+ | | pair: id; date_expression |
+ | | |
+ | | A unique name for this element (required) |
+ +---------------+-----------------------------------------------------------+
+ | start | .. index:: |
+ | | pair: start; date_expression |
+ | | |
+ | | A date/time conforming to the |
+ | | `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ |
+ | | specification. May be used when ``operation`` is |
+ | | ``in_range`` (in which case at least one of ``start`` or |
+ | | ``end`` must be specified) or ``gt`` (in which case |
+ | | ``start`` is required). |
+ +---------------+-----------------------------------------------------------+
+ | end | .. index:: |
+ | | pair: end; date_expression |
+ | | |
+ | | A date/time conforming to the |
+ | | `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ |
+ | | specification. May be used when ``operation`` is |
+ | | ``in_range`` (in which case at least one of ``start`` or |
+ | | ``end`` must be specified) or ``lt`` (in which case |
+ | | ``end`` is required). |
+ +---------------+-----------------------------------------------------------+
+ | operation | .. index:: |
+ | | pair: operation; date_expression |
+ | | |
+ | | Compares the current date/time with the start and/or end |
+ | | date, depending on the context. Allowed values: |
+ | | |
+ | | * ``gt:`` True if the current date/time is after ``start``|
+ | | * ``lt:`` True if the current date/time is before ``end`` |
+ | | * ``in_range:`` True if the current date/time is after |
+ | | ``start`` (if specified) and before either ``end`` (if |
+ | | specified) or ``start`` plus the value of the |
+ | | ``duration`` element (if one is contained in the |
+ | | ``date_expression``) |
+ | | * ``date_spec:`` True if the current date/time matches |
+ | | the specification given in the contained ``date_spec`` |
+ | | element (described below) |
+ +---------------+-----------------------------------------------------------+
+
+
+.. note:: There is no ``eq``, ``neq``, ``gte``, or ``lte`` operation, since
+ they would be valid only for a single second.
+
+
+.. index::
+ single: date specification
+ pair: XML element; date_spec
+
+Date Specifications
+___________________
+
+A ``date_spec`` element is used to create a cron-like expression relating
+to time. Each field can contain a single number or range. Any field not
+supplied is ignored.
+
+.. table:: **Attributes of a date_spec Element**
+
+ +---------------+-----------------------------------------------------------+
+ | Attribute | Description |
+ +===============+===========================================================+
+ | id | .. index:: |
+ | | pair: id; date_spec |
+ | | |
+ | | A unique name for this element (required) |
+ +---------------+-----------------------------------------------------------+
+ | hours | .. index:: |
+ | | pair: hours; date_spec |
+ | | |
+ | | Allowed values: 0-23 (where 0 is midnight and 23 is |
+ | | 11 p.m.) |
+ +---------------+-----------------------------------------------------------+
+ | monthdays | .. index:: |
+ | | pair: monthdays; date_spec |
+ | | |
+ | | Allowed values: 1-31 (depending on month and year) |
+ +---------------+-----------------------------------------------------------+
+ | weekdays | .. index:: |
+ | | pair: weekdays; date_spec |
+ | | |
+ | | Allowed values: 1-7 (where 1 is Monday and 7 is Sunday) |
+ +---------------+-----------------------------------------------------------+
+ | yeardays | .. index:: |
+ | | pair: yeardays; date_spec |
+ | | |
+ | | Allowed values: 1-366 (depending on the year) |
+ +---------------+-----------------------------------------------------------+
+ | months | .. index:: |
+ | | pair: months; date_spec |
+ | | |
+ | | Allowed values: 1-12 |
+ +---------------+-----------------------------------------------------------+
+ | weeks | .. index:: |
+ | | pair: weeks; date_spec |
+ | | |
+ | | Allowed values: 1-53 (depending on weekyear) |
+ +---------------+-----------------------------------------------------------+
+ | years | .. index:: |
+ | | pair: years; date_spec |
+ | | |
+ | | Year according to the Gregorian calendar |
+ +---------------+-----------------------------------------------------------+
+ | weekyears | .. index:: |
+ | | pair: weekyears; date_spec |
+ | | |
+ | | Year in which the week started; for example, 1 January |
+ | | 2005 can be specified in ISO 8601 as "2005-001 Ordinal", |
+ | | "2005-01-01 Gregorian" or "2004-W53-6 Weekly" and thus |
+ | | would match ``years="2005"`` or ``weekyears="2004"`` |
+ +---------------+-----------------------------------------------------------+
+ | moon | .. index:: |
+ | | pair: moon; date_spec |
+ | | |
+ | | Allowed values are 0-7 (where 0 is the new moon and 4 is |
+ | | full moon). Seriously, you can use this. This was |
+ | | implemented to demonstrate the ease with which new |
+ | | comparisons could be added. |
+ +---------------+-----------------------------------------------------------+
+
+For example, ``monthdays="1"`` matches the first day of every month, and
+``hours="09-17"`` matches the hours between 9 a.m. and 5 p.m. (inclusive).
+
+At this time, multiple ranges (e.g. ``weekdays="1,2"`` or ``weekdays="1-2,5-6"``)
+are not supported.
+
+.. note:: Pacemaker can calculate when evaluation of a ``date_expression`` with
+ an ``operation`` of ``gt``, ``lt``, or ``in_range`` will next change,
+ and schedule a cluster re-check for that time. However, it does not
+ do this for ``date_spec``. Instead, it evaluates the ``date_spec``
+ whenever a cluster re-check naturally happens via a cluster event or
+ the ``cluster-recheck-interval`` cluster option.
+
+ For example, if you have a ``date_spec`` enabling a resource from 9
+ a.m. to 5 p.m., and ``cluster-recheck-interval`` has been set to 5
+ minutes, then sometime between 9 a.m. and 9:05 a.m. the cluster would
+ notice that it needs to start the resource, and sometime between 5
+ p.m. and 5:05 p.m. it would realize that it needs to stop the
+ resource. The timing of the actual start and stop actions will
+ further depend on factors such as any other actions the cluster may
+ need to perform first, and the load of the machine.
+
+
+.. index::
+ single: duration
+ pair: XML element; duration
+
+Durations
+_________
+
+A ``duration`` is used to calculate a value for ``end`` when one is not
+supplied to ``in_range`` operations. It contains one or more attributes each
+containing a single number. Any attribute not supplied is ignored.
+
+.. table:: **Attributes of a duration Element**
+
+ +---------------+-----------------------------------------------------------+
+ | Attribute | Description |
+ +===============+===========================================================+
+ | id | .. index:: |
+ | | pair: id; duration |
+ | | |
+ | | A unique name for this element (required) |
+ +---------------+-----------------------------------------------------------+
+ | seconds | .. index:: |
+ | | pair: seconds; duration |
+ | | |
+ | | This many seconds will be added to the total duration |
+ +---------------+-----------------------------------------------------------+
+ | minutes | .. index:: |
+ | | pair: minutes; duration |
+ | | |
+ | | This many minutes will be added to the total duration |
+ +---------------+-----------------------------------------------------------+
+ | hours | .. index:: |
+ | | pair: hours; duration |
+ | | |
+ | | This many hours will be added to the total duration |
+ +---------------+-----------------------------------------------------------+
+ | weeks | .. index:: |
+ | | pair: weeks; duration |
+ | | |
+ | | This many weeks will be added to the total duration |
+ +---------------+-----------------------------------------------------------+
+ | months | .. index:: |
+ | | pair: months; duration |
+ | | |
+ | | This many months will be added to the total duration |
+ +---------------+-----------------------------------------------------------+
+ | years | .. index:: |
+ | | pair: years; duration |
+ | | |
+ | | This many years will be added to the total duration |
+ +---------------+-----------------------------------------------------------+
+
+
+Example Time-Based Expressions
+______________________________
+
+A small sample of how time-based expressions can be used:
+
+.. topic:: True if now is any time in the year 2005
+
+ .. code-block:: xml
+
+ <rule id="rule1" score="INFINITY">
+ <date_expression id="date_expr1" start="2005-001" operation="in_range">
+ <duration id="duration1" years="1"/>
+ </date_expression>
+ </rule>
+
+ or equivalently:
+
+ .. code-block:: xml
+
+ <rule id="rule2" score="INFINITY">
+ <date_expression id="date_expr2" operation="date_spec">
+ <date_spec id="date_spec2" years="2005"/>
+ </date_expression>
+ </rule>
+
+.. topic:: 9 a.m. to 5 p.m. Monday through Friday
+
+ .. code-block:: xml
+
+ <rule id="rule3" score="INFINITY">
+ <date_expression id="date_expr3" operation="date_spec">
+ <date_spec id="date_spec3" hours="9-16" weekdays="1-5"/>
+ </date_expression>
+ </rule>
+
+ Note that the ``16`` matches all the way through ``16:59:59``, because the
+ numeric value of the hour still matches.
+
+.. topic:: 9 a.m. to 6 p.m. Monday through Friday or anytime Saturday
+
+ .. code-block:: xml
+
+ <rule id="rule4" score="INFINITY" boolean-op="or">
+ <date_expression id="date_expr4-1" operation="date_spec">
+ <date_spec id="date_spec4-1" hours="9-16" weekdays="1-5"/>
+ </date_expression>
+ <date_expression id="date_expr4-2" operation="date_spec">
+ <date_spec id="date_spec4-2" weekdays="6"/>
+ </date_expression>
+ </rule>
+
+.. topic:: 9 a.m. to 5 p.m. or 9 p.m. to 12 a.m. Monday through Friday
+
+ .. code-block:: xml
+
+ <rule id="rule5" score="INFINITY" boolean-op="and">
+ <rule id="rule5-nested1" score="INFINITY" boolean-op="or">
+ <date_expression id="date_expr5-1" operation="date_spec">
+ <date_spec id="date_spec5-1" hours="9-16"/>
+ </date_expression>
+ <date_expression id="date_expr5-2" operation="date_spec">
+ <date_spec id="date_spec5-2" hours="21-23"/>
+ </date_expression>
+ </rule>
+ <date_expression id="date_expr5-3" operation="date_spec">
+ <date_spec id="date_spec5-3" weekdays="1-5"/>
+ </date_expression>
+ </rule>
+
+.. topic:: Mondays in March 2005
+
+ .. code-block:: xml
+
+ <rule id="rule6" score="INFINITY" boolean-op="and">
+ <date_expression id="date_expr6-1" operation="date_spec">
+ <date_spec id="date_spec6" weekdays="1"/>
+ </date_expression>
+ <date_expression id="date_expr6-2" operation="in_range"
+ start="2005-03-01" end="2005-04-01"/>
+ </rule>
+
+ .. note:: Because no time is specified with the above dates, 00:00:00 is
+ implied. This means that the range includes all of 2005-03-01 but
+ none of 2005-04-01. You may wish to write ``end`` as
+ ``"2005-03-31T23:59:59"`` to avoid confusion.
+
+.. topic:: A full moon on Friday the 13th
+
+ .. code-block:: xml
+
+ <rule id="rule7" score="INFINITY" boolean-op="and">
+ <date_expression id="date_expr7" operation="date_spec">
+ <date_spec id="date_spec7" weekdays="5" monthdays="13" moon="4"/>
+ </date_expression>
</rule>
- <date_expression id="date_expr5-3" operation="date_spec">
- <date_spec id="date_spec5-3" weekdays="1-5"/>
- </date_expression>
- </rule>
- -------
- ====
-
- .Mondays in March 2005
- ====
- [source,XML]
- -------
- <rule id="rule6" score="INFINITY" boolean-op="and">
- <date_expression id="date_expr6-1" operation="date_spec">
- <date_spec id="date_spec6" weekdays="1"/>
- </date_expression>
- <date_expression id="date_expr6-2" operation="in_range"
- start="2005-03-01" end="2005-04-01"/>
- </rule>
- -------
- ====
-
- [NOTE]
- ======
- Because no time is specified with the above dates, 00:00:00 is implied. This
- means that the range includes all of 2005-03-01 but none of 2005-04-01.
- You may wish to write +end="2005-03-31T23:59:59"+ to avoid confusion.
- ======
-
- .A full moon on Friday the 13th
- =====
- [source,XML]
- -------
- <rule id="rule7" score="INFINITY" boolean-op="and">
- <date_expression id="date_expr7" operation="date_spec">
- <date_spec id="date_spec7" weekdays="5" monthdays="13" moon="4"/>
- </date_expression>
- </rule>
- -------
- =====
-
- == Resource Expressions ==
-
- An +rsc_expression+ is a rule condition based on a resource agent's properties.
- This rule is only valid within an +rsc_defaults+ or +op_defaults+ context. None
- of the matching attributes of +class+, +provider+, and +type+ are required. If
- one is omitted, all values of that attribute will match. For instance, omitting
- +type+ means every type will match.
-
- .Attributes of an rsc_expression Element
- [width="95%",cols="2m,<5",options="header",align="center"]
- |=========================================================
-
- |Field
- |Description
-
- |id
- |A unique name for the expression (required)
- indexterm:[XML attribute,id attribute,rsc_expression element]
- indexterm:[XML element,rsc_expression element,id attribute]
-
- |class
- |The standard name to be matched against resource agents
- indexterm:[XML attribute,class attribute,rsc_expression element]
- indexterm:[XML element,rsc_expression element,class attribute]
-
- |provider
- |If given, the vendor to be matched against resource agents. This
- only makes sense for agents using the OCF spec.
- indexterm:[XML attribute,provider attribute,rsc_expression element]
- indexterm:[XML element,rsc_expression element,provider attribute]
-
- |type
- |The name of the resource agent to be matched
- indexterm:[XML attribute,type attribute,rsc_expression element]
- indexterm:[XML element,rsc_expression element,type attribute]
-
- |=========================================================
-
- === Example Resource-Based Expressions ===
-
- A small sample of how resource-based expressions can be used:
-
- .True for all ocf:heartbeat:IPaddr2 resources
- ====
- [source,XML]
- ----
- <rule id="rule1" score="INFINITY">
- <rsc_expression id="rule_expr1" class="ocf" provider="heartbeat" type="IPaddr2"/>
- </rule>
- ----
- ====
-
- .Provider doesn't apply to non-OCF resources
- ====
- [source,XML]
- ----
- <rule id="rule2" score="INFINITY">
- <rsc_expression id="rule_expr2" class="stonith" type="fence_xvm"/>
- </rule>
- ----
- ====
-
- == Operation Expressions ==
-
- An +op_expression+ is a rule condition based on an action of some resource
- agent. This rule is only valid within an +op_defaults+ context.
-
- .Attributes of an op_expression Element
- [width="95%",cols="2m,<5",options="header",align="center"]
- |=========================================================
-
- |Field
- |Description
-
- |id
- |A unique name for the expression (required)
- indexterm:[XML attribute,id attribute,op_expression element]
- indexterm:[XML element,op_expression element,id attribute]
-
- |name
- |The action name to match against. This can be any action supported by
- the resource agent; common values include +monitor+, +start+, and +stop+
- (required).
- indexterm:[XML attribute,name attribute,op_expression element]
- indexterm:[XML element,op_expression element,name attribute]
-
- |interval
- |The interval of the action to match against. If not given, only
- the name attribute will be used to match.
- indexterm:[XML attribute,interval attribute,op_expression element]
- indexterm:[XML element,op_expression element,interval attribute]
-
- |=========================================================
-
- === Example Operation-Based Expressions ===
-
- A small sample of how operation-based expressions can be used:
-
- .True for all monitor actions
- ====
- [source,XML]
- ----
- <rule id="rule1" score="INFINITY">
- <op_expression id="rule_expr1" name="monitor"/>
- </rule>
- ----
- ====
-
- .True for all monitor actions with a 10 second interval
- ====
- [source,XML]
- ----
- <rule id="rule2" score="INFINITY">
- <op_expression id="rule_expr2" name="monitor" interval="10s"/>
- </rule>
- ----
- ====
-
- == Using Rules to Determine Resource Location ==
- indexterm:[Rule,Determine Resource Location]
- indexterm:[Resource,Location,Determine by Rules]
-
- A location constraint may contain one or more top-level rules. The cluster
- will act as if there is a separate location constraint for each rule that
- evaluates as true.
-
- Consider the following simple location constraint:
-
- .Prevent resource "webserver" from running on node3
- =====
- [source,XML]
- -------
- <rsc_location id="ban-apache-on-node3" rsc="webserver"
- score="-INFINITY" node="node3"/>
- -------
- =====
-
- The constraint can be more verbosely written using a rule:
-
- .Prevent resource "webserver" from running on node3 using rule
- =====
- [source,XML]
- -------
- <rsc_location id="ban-apache-on-node3" rsc="webserver">
- <rule id="ban-apache-rule" score="-INFINITY">
- <expression id="ban-apache-expr" attribute="#uname"
- operation="eq" value="node3"/>
- </rule>
- </rsc_location>
- -------
- =====
-
- The advantage of using the expanded form is that one could add more expressions
- (for example, limiting the constraint to certain days of the week), or activate
- the constraint by some node attribute other than node name.
-
- === Location Rules Based on Other Node Properties ===
-
- The expanded form allows us to match on node properties other than its name.
- If we rated each machine's CPU power such that the cluster had the
- following nodes section:
-
- .A sample nodes section for use with score-attribute
- =====
- [source,XML]
- -------
- <nodes>
- <node id="uuid1" uname="c001n01" type="normal">
- <instance_attributes id="uuid1-custom_attrs">
- <nvpair id="uuid1-cpu_mips" name="cpu_mips" value="1234"/>
+
+
+.. index::
+ single: rule; resource expression
+ single: resource; rule expression
+ pair: XML element; rsc_expression
+
+Resource Expressions
+####################
+
+An ``rsc_expression`` is a rule condition based on a resource agent's
+properties. This rule is only valid within an ``rsc_defaults`` or
+``op_defaults`` context. None of the matching attributes of ``class``,
+``provider``, and ``type`` are required. If one is omitted, all values of that
+attribute will match. For instance, omitting ``type`` means every type will
+match.
+
+.. table:: **Attributes of a rsc_expression Element**
+
+ +---------------+-----------------------------------------------------------+
+ | Attribute | Description |
+ +===============+===========================================================+
+ | id | .. index:: |
+ | | pair: id; rsc_expression |
+ | | |
+ | | A unique name for this element (required) |
+ +---------------+-----------------------------------------------------------+
+ | class | .. index:: |
+ | | pair: class; rsc_expression |
+ | | |
+ | | The standard name to be matched against resource agents |
+ +---------------+-----------------------------------------------------------+
+ | provider | .. index:: |
+ | | pair: provider; rsc_expression |
+ | | |
+ | | If given, the vendor to be matched against resource |
+ | | agents (only relevant when ``class`` is ``ocf``) |
+ +---------------+-----------------------------------------------------------+
+ | type | .. index:: |
+ | | pair: type; rsc_expression |
+ | | |
+ | | The name of the resource agent to be matched |
+ +---------------+-----------------------------------------------------------+
+
+Example Resource-Based Expressions
+__________________________________
+
+A small sample of how resource-based expressions can be used:
+
+.. topic:: True for all ``ocf:heartbeat:IPaddr2`` resources
+
+ .. code-block:: xml
+
+ <rule id="rule1" score="INFINITY">
+ <rsc_expression id="rule_expr1" class="ocf" provider="heartbeat" type="IPaddr2"/>
+ </rule>
+
+.. topic:: Provider doesn't apply to non-OCF resources
+
+ .. code-block:: xml
+
+ <rule id="rule2" score="INFINITY">
+ <rsc_expression id="rule_expr2" class="stonith" type="fence_xvm"/>
+ </rule>
+
+
+.. index::
+ single: rule; operation expression
+ single: operation; rule expression
+ pair: XML element; op_expression
+
+Operation Expressions
+#####################
+
+
+An ``op_expression`` is a rule condition based on an action of some resource
+agent. This rule is only valid within an ``op_defaults`` context.
+
+.. table:: **Attributes of an op_expression Element**
+
+ +---------------+-----------------------------------------------------------+
+ | Attribute | Description |
+ +===============+===========================================================+
+ | id | .. index:: |
+ | | pair: id; op_expression |
+ | | |
+ | | A unique name for this element (required) |
+ +---------------+-----------------------------------------------------------+
+ | name | .. index:: |
+ | | pair: name; op_expression |
+ | | |
+ | | The action name to match against. This can be any action |
+ | | supported by the resource agent; common values include |
+ | | ``monitor``, ``start``, and ``stop`` (required). |
+ +---------------+-----------------------------------------------------------+
+ | interval | .. index:: |
+ | | pair: interval; op_expression |
+ | | |
+ | | The interval of the action to match against. If not given,|
+ | | only the name attribute will be used to match. |
+ +---------------+-----------------------------------------------------------+
+
+Example Operation-Based Expressions
+___________________________________
+
+A small sample of how operation-based expressions can be used:
+
+.. topic:: True for all monitor actions
+
+ .. code-block:: xml
+
+ <rule id="rule1" score="INFINITY">
+ <op_expression id="rule_expr1" name="monitor"/>
+ </rule>
+
+.. topic:: True for all monitor actions with a 10 second interval
+
+ .. code-block:: xml
+
+ <rule id="rule2" score="INFINITY">
+ <op_expression id="rule_expr2" name="monitor" interval="10s"/>
+ </rule>
+
+
+.. index::
+ pair: location constraint; rule
+
+Using Rules to Determine Resource Location
+##########################################
+
+A location constraint may contain one or more top-level rules. The cluster will
+act as if there is a separate location constraint for each rule that evaluates
+as true.
+
+Consider the following simple location constraint:
+
+.. topic:: Prevent resource ``webserver`` from running on node ``node3``
+
+ .. code-block:: xml
+
+ <rsc_location id="ban-apache-on-node3" rsc="webserver"
+ score="-INFINITY" node="node3"/>
+
+The same constraint can be more verbosely written using a rule:
+
+.. topic:: Prevent resource ``webserver`` from running on node ``node3`` using a rule
+
+ .. code-block:: xml
+
+ <rsc_location id="ban-apache-on-node3" rsc="webserver">
+ <rule id="ban-apache-rule" score="-INFINITY">
+ <expression id="ban-apache-expr" attribute="#uname"
+ operation="eq" value="node3"/>
+ </rule>
+ </rsc_location>
+
+The advantage of using the expanded form is that one could add more expressions
+(for example, limiting the constraint to certain days of the week), or activate
+the constraint by some node attribute other than node name.
+
+Location Rules Based on Other Node Properties
+_____________________________________________
+
+The expanded form allows us to match on node properties other than its name.
+If we rated each machine's CPU power such that the cluster had the following
+nodes section:
+
+.. topic:: Sample node section with node attributes
+
+ .. code-block:: xml
+
+ <nodes>
+ <node id="uuid1" uname="c001n01" type="normal">
+ <instance_attributes id="uuid1-custom_attrs">
+ <nvpair id="uuid1-cpu_mips" name="cpu_mips" value="1234"/>
+ </instance_attributes>
+ </node>
+ <node id="uuid2" uname="c001n02" type="normal">
+ <instance_attributes id="uuid2-custom_attrs">
+ <nvpair id="uuid2-cpu_mips" name="cpu_mips" value="5678"/>
+ </instance_attributes>
+ </node>
+ </nodes>
+
+then we could prevent resources from running on underpowered machines with this
+rule:
+
+.. topic:: Rule using a node attribute (to be used inside a location constraint)
+
+ .. code-block:: xml
+
+ <rule id="need-more-power-rule" score="-INFINITY">
+ <expression id="need-more-power-expr" attribute="cpu_mips"
+ operation="lt" value="3000"/>
+ </rule>
+
+Using ``score-attribute`` Instead of ``score``
+______________________________________________
+
+When using ``score-attribute`` instead of ``score``, each node matched by the
+rule has its score adjusted differently, according to its value for the named
+node attribute. Thus, in the previous example, if a rule inside a location
+constraint for a resource used ``score-attribute="cpu_mips"``, ``c001n01``
+would have its preference to run the resource increased by ``1234`` whereas
+``c001n02`` would have its preference increased by ``5678``.
+
+
+.. index::
+ pair: cluster option; rule
+ pair: instance attribute; rule
+ pair: meta-attribute; rule
+ pair: resource defaults; rule
+ pair: operation defaults; rule
+ pair: node attribute; rule
+
+Using Rules to Define Options
+#############################
+
+Rules may be used to control a variety of options:
+
+* :ref:`Cluster options <cluster_options>` (``cluster_property_set`` elements)
+* :ref:`Node attributes <node_attributes>` (``instance_attributes`` or
+ ``utilization`` elements inside a ``node`` element)
+* :ref:`Resource options <resource_options>` (``utilization``,
+ ``meta_attributes``, or ``instance_attributes`` elements inside a resource
+ definition element or ``op`` , ``rsc_defaults``, ``op_defaults``, or
+ ``template`` element)
+* :ref:`Operation properties <operation_properties>` (``meta_attributes``
+ elements inside an ``op`` or ``op_defaults`` element)
+
+Using Rules to Control Resource Options
+_______________________________________
+
+Often some cluster nodes will be different from their peers. Sometimes,
+these differences -- e.g. the location of a binary or the names of network
+interfaces -- require resources to be configured differently depending
+on the machine they're hosted on.
+
+By defining multiple ``instance_attributes`` objects for the resource and
+adding a rule to each, we can easily handle these special cases.
+
+In the example below, ``mySpecialRsc`` will use eth1 and port 9999 when run on
+``node1``, eth2 and port 8888 on ``node2`` and default to eth0 and port 9999
+for all other nodes.
+
+.. topic:: Defining different resource options based on the node name
+
+ .. code-block:: xml
+
+ <primitive id="mySpecialRsc" class="ocf" type="Special" provider="me">
+ <instance_attributes id="special-node1" score="3">
+ <rule id="node1-special-case" score="INFINITY" >
+ <expression id="node1-special-case-expr" attribute="#uname"
+ operation="eq" value="node1"/>
+ </rule>
+ <nvpair id="node1-interface" name="interface" value="eth1"/>
</instance_attributes>
- </node>
- <node id="uuid2" uname="c001n02" type="normal">
- <instance_attributes id="uuid2-custom_attrs">
- <nvpair id="uuid2-cpu_mips" name="cpu_mips" value="5678"/>
+ <instance_attributes id="special-node2" score="2" >
+ <rule id="node2-special-case" score="INFINITY">
+ <expression id="node2-special-case-expr" attribute="#uname"
+ operation="eq" value="node2"/>
+ </rule>
+ <nvpair id="node2-interface" name="interface" value="eth2"/>
+ <nvpair id="node2-port" name="port" value="8888"/>
</instance_attributes>
- </node>
- </nodes>
- -------
- =====
-
- then we could prevent resources from running on underpowered machines with this rule:
-
- [source,XML]
- -------
- <rule id="need-more-power-rule" score="-INFINITY">
- <expression id="need-more-power-expr" attribute="cpu_mips"
- operation="lt" value="3000"/>
- </rule>
- -------
-
- === Using +score-attribute+ Instead of +score+ ===
-
- When using +score-attribute+ instead of +score+, each node matched by
- the rule has its score adjusted differently, according to its value
- for the named node attribute. Thus, in the previous example, if a
- rule used +score-attribute="cpu_mips"+, +c001n01+ would have its
- preference to run the resource increased by +1234+ whereas +c001n02+
- would have its preference increased by +5678+.
-
- == Using Rules to Define Options ==
-
- Rules may be used to control a variety of options:
-
- * <<s-cluster-options,Cluster options>> (+cluster_property_set+ elements)
- * <<s-node-attributes,Node attributes>> (as +instance_attributes+ or
- +utilization+ elements inside a +node+ element)
- * <<s-resource-options,Resource options>> (as +utilization+, +meta_attributes+,
- or +instance_attributes+ elements inside a resource definition element or
- +op+ , +rsc_defaults+, +op_defaults+, or +template+ element)
- * <<s-operation-properties,Operation properties>> (+meta_attributes+
- inside an +op+ or +op_defaults+ element)
-
- === Using Rules to Control Resource Options ===
-
- Often some cluster nodes will be different from their peers. Sometimes,
- these differences -- e.g. the location of a binary or the names of network
- interfaces -- require resources to be configured differently depending
- on the machine they're hosted on.
-
- By defining multiple +instance_attributes+ objects for the resource
- and adding a rule to each, we can easily handle these special cases.
-
- In the example below, +mySpecialRsc+ will use eth1 and port 9999 when
- run on +node1+, eth2 and port 8888 on +node2+ and default to eth0 and
- port 9999 for all other nodes.
-
- .Defining different resource options based on the node name
- =====
- [source,XML]
- -------
- <primitive id="mySpecialRsc" class="ocf" type="Special" provider="me">
- <instance_attributes id="special-node1" score="3">
- <rule id="node1-special-case" score="INFINITY" >
- <expression id="node1-special-case-expr" attribute="#uname"
- operation="eq" value="node1"/>
- </rule>
- <nvpair id="node1-interface" name="interface" value="eth1"/>
- </instance_attributes>
- <instance_attributes id="special-node2" score="2" >
- <rule id="node2-special-case" score="INFINITY">
- <expression id="node2-special-case-expr" attribute="#uname"
- operation="eq" value="node2"/>
- </rule>
- <nvpair id="node2-interface" name="interface" value="eth2"/>
- <nvpair id="node2-port" name="port" value="8888"/>
- </instance_attributes>
- <instance_attributes id="defaults" score="1" >
- <nvpair id="default-interface" name="interface" value="eth0"/>
- <nvpair id="default-port" name="port" value="9999"/>
- </instance_attributes>
- </primitive>
- -------
- =====
-
- The order in which +instance_attributes+ objects are evaluated is
- determined by their score (highest to lowest). If not supplied, score
- defaults to zero, and objects with an equal score are processed in
- listed order. If the +instance_attributes+ object has no rule
- or a +rule+ that evaluates to +true+, then for any parameter the resource does
- not yet have a value for, the resource will use the parameter values defined by
- the +instance_attributes+.
-
- For example, given the configuration above, if the resource is placed on node1:
-
- . +special-node1+ has the highest score (3) and so is evaluated first;
- its rule evaluates to +true+, so +interface+ is set to +eth1+.
- . +special-node2+ is evaluated next with score 2, but its rule evaluates to +false+,
- so it is ignored.
- . +defaults+ is evaluated last with score 1, and has no rule, so its values
- are examined; +interface+ is already defined, so the value here is not used,
- but +port+ is not yet defined, so +port+ is set to +9999+.
-
- === Using Rules to Control Resource Defaults ===
-
- Rules can be used for resource and operation defaults. The following example
- illustrates how to set a different +resource-stickiness+ value during and
- outside work hours. This allows resources to automatically move back to their
- most preferred hosts, but at a time that (in theory) does not interfere with
- business activities.
-
- .Change +resource-stickiness+ during working hours
- =====
- [source,XML]
- -------
- <rsc_defaults>
- <meta_attributes id="core-hours" score="2">
- <rule id="core-hour-rule" score="0">
- <date_expression id="nine-to-five-Mon-to-Fri" operation="date_spec">
- <date_spec id="nine-to-five-Mon-to-Fri-spec" hours="9-16" weekdays="1-5"/>
- </date_expression>
- </rule>
- <nvpair id="core-stickiness" name="resource-stickiness" value="INFINITY"/>
- </meta_attributes>
- <meta_attributes id="after-hours" score="1" >
- <nvpair id="after-stickiness" name="resource-stickiness" value="0"/>
- </meta_attributes>
- </rsc_defaults>
- -------
- =====
-
- Rules may be used similarly in +instance_attributes+ or +utilization+ blocks.
-
- Any single block may directly contain only a single rule, but that rule may
- itself contain any number of rules.
-
- +rsc_expression+ and +op_expression+ blocks may additionally be used to set defaults
- on either a single resource or across an entire class of resources with a single
- rule. +rsc_expression+ may be used to select resource agents within both +rsc_defaults+
- and +op_defaults+, while +op_expression+ may only be used within +op_defaults+. If
- multiple rules succeed for a given resource agent, the last one specified will be
- the one that takes effect. As with any other rule, boolean operations may be used
- to make more complicated expressions.
-
- .Set all IPaddr2 resources to stopped
- =====
- [source,XML]
- -------
- <rsc_defaults>
- <meta_attributes id="op-target-role">
- <rule id="op-target-role-rule" score="INFINITY">
- <rsc_expression id="op-target-role-expr" class="ocf" provider="heartbeat"
- type="IPaddr2"/>
- </rule>
- <nvpair id="op-target-role-nvpair" name="target-role" value="Stopped"/>
- </meta_attributes>
- </rsc_defaults>
- -------
- =====
-
- .Set all monitor action timeouts to 7 seconds
- =====
- [source,XML]
- -------
- <op_defaults>
- <meta_attributes id="op-monitor-defaults">
- <rule id="op-monitor-default-rule" score="INFINITY">
- <op_expression id="op-monitor-default-expr" name="monitor"/>
- </rule>
- <nvpair id="op-monitor-timeout" name="timeout" value="7s"/>
- </meta_attributes>
- </op_defaults>
- -------
- =====
-
- .Set the monitor action timeout on all IPaddr2 resources with a given monitor interval to 8 seconds
- =====
- [source,XML]
- -------
- <op_defaults>
- <meta_attributes id="op-monitor-and">
- <rule id="op-monitor-and-rule" score="INFINITY">
- <rsc_expression id="op-monitor-and-rsc-expr" class="ocf" provider="heartbeat"
- type="IPaddr2"/>
- <op_expression id="op-monitor-and-op-expr" name="monitor" interval="10s"/>
+ <instance_attributes id="defaults" score="1" >
+ <nvpair id="default-interface" name="interface" value="eth0"/>
+ <nvpair id="default-port" name="port" value="9999"/>
+ </instance_attributes>
+ </primitive>
+
+The order in which ``instance_attributes`` objects are evaluated is determined
+by their score (highest to lowest). If not supplied, the score defaults to
+zero. Objects with an equal score are processed in their listed order. If the
+``instance_attributes`` object has no rule, or a ``rule`` that evaluates to
+``true``, then for any parameter the resource does not yet have a value for,
+the resource will use the parameter values defined by the ``instance_attributes``.
+
+For example, given the configuration above, if the resource is placed on
+``node1``:
+
+* ``special-node1`` has the highest score (3) and so is evaluated first; its
+ rule evaluates to ``true``, so ``interface`` is set to ``eth1``.
+* ``special-node2`` is evaluated next with score 2, but its rule evaluates to
+ ``false``, so it is ignored.
+* ``defaults`` is evaluated last with score 1, and has no rule, so its values
+ are examined; ``interface`` is already defined, so the value here is not
+ used, but ``port`` is not yet defined, so ``port`` is set to ``9999``.
+
+Using Rules to Control Resource Defaults
+________________________________________
+
+Rules can be used for resource and operation defaults. The following example
+illustrates how to set a different ``resource-stickiness`` value during and
+outside work hours. This allows resources to automatically move back to their
+most preferred hosts, but at a time that (in theory) does not interfere with
+business activities.
+
+.. topic:: Change ``resource-stickiness`` during working hours
+
+ .. code-block:: xml
+
+ <rsc_defaults>
+ <meta_attributes id="core-hours" score="2">
+ <rule id="core-hour-rule" score="0">
+ <date_expression id="nine-to-five-Mon-to-Fri" operation="date_spec">
+ <date_spec id="nine-to-five-Mon-to-Fri-spec" hours="9-16" weekdays="1-5"/>
+ </date_expression>
+ </rule>
+ <nvpair id="core-stickiness" name="resource-stickiness" value="INFINITY"/>
+ </meta_attributes>
+ <meta_attributes id="after-hours" score="1" >
+ <nvpair id="after-stickiness" name="resource-stickiness" value="0"/>
+ </meta_attributes>
+ </rsc_defaults>
+
+Rules may be used similarly in ``instance_attributes`` or ``utilization``
+blocks.
+
+Any single block may directly contain only a single rule, but that rule may
+itself contain any number of rules.
+
+``rsc_expression`` and ``op_expression`` blocks may additionally be used to
+set defaults on either a single resource or across an entire class of resources
+with a single rule. ``rsc_expression`` may be used to select resource agents
+within both ``rsc_defaults`` and ``op_defaults``, while ``op_expression`` may
+only be used within ``op_defaults``. If multiple rules succeed for a given
+resource agent, the last one specified will be the one that takes effect. As
+with any other rule, boolean operations may be used to make more complicated
+expressions.
+
+.. topic:: Default all IPaddr2 resources to stopped
+
+ .. code-block:: xml
+
+ <rsc_defaults>
+ <meta_attributes id="op-target-role">
+ <rule id="op-target-role-rule" score="INFINITY">
+ <rsc_expression id="op-target-role-expr" class="ocf" provider="heartbeat"
+ type="IPaddr2"/>
+ </rule>
+ <nvpair id="op-target-role-nvpair" name="target-role" value="Stopped"/>
+ </meta_attributes>
+ </rsc_defaults>
+
+.. topic:: Default all monitor action timeouts to 7 seconds
+
+ .. code-block:: xml
+
+ <op_defaults>
+ <meta_attributes id="op-monitor-defaults">
+ <rule id="op-monitor-default-rule" score="INFINITY">
+ <op_expression id="op-monitor-default-expr" name="monitor"/>
+ </rule>
+ <nvpair id="op-monitor-timeout" name="timeout" value="7s"/>
+ </meta_attributes>
+ </op_defaults>
+
+.. topic:: Default the timeout on all 10-second-interval monitor actions on ``IPaddr2`` resources to 8 seconds
+
+ .. code-block:: xml
+
+ <op_defaults>
+ <meta_attributes id="op-monitor-and">
+ <rule id="op-monitor-and-rule" score="INFINITY">
+ <rsc_expression id="op-monitor-and-rsc-expr" class="ocf" provider="heartbeat"
+ type="IPaddr2"/>
+ <op_expression id="op-monitor-and-op-expr" name="monitor" interval="10s"/>
+ </rule>
+ <nvpair id="op-monitor-and-timeout" name="timeout" value="8s"/>
+ </meta_attributes>
+ </op_defaults>
+
+
+.. index::
+ pair: rule; cluster option
+
+Using Rules to Control Cluster Options
+______________________________________
+
+Controlling cluster options is achieved in much the same manner as specifying
+different resource options on different nodes.
+
+The difference is that because they are cluster options, one cannot (or should
+not, because they won't work) use attribute-based expressions. The following
+example illustrates how to set ``maintenance_mode`` during a scheduled
+maintenance window. This will keep the cluster running but not monitor, start,
+or stop resources during this time.
+
+.. topic:: Schedule a maintenance window for 9 to 11 p.m. CDT Sept. 20, 2019
+
+ .. code-block:: xml
+
+ <crm_config>
+ <cluster_property_set id="cib-bootstrap-options">
+ <nvpair id="bootstrap-stonith-enabled" name="stonith-enabled" value="1"/>
+ </cluster_property_set>
+ <cluster_property_set id="normal-set" score="10">
+ <nvpair id="normal-maintenance-mode" name="maintenance-mode" value="false"/>
+ </cluster_property_set>
+ <cluster_property_set id="maintenance-window-set" score="1000">
+ <nvpair id="maintenance-nvpair1" name="maintenance-mode" value="true"/>
+ <rule id="maintenance-rule1" score="INFINITY">
+ <date_expression id="maintenance-date1" operation="in_range"
+ start="2019-09-20 21:00:00 -05:00" end="2019-09-20 23:00:00 -05:00"/>
</rule>
- <nvpair id="op-monitor-and-timeout" name="timeout" value="8s"/>
- </meta_attributes>
- </op_defaults>
- -------
- =====
-
- === Using Rules to Control Cluster Options ===
- indexterm:[Rule,Controlling Cluster Options]
- indexterm:[Cluster,Setting Options with Rules]
-
- Controlling cluster options is achieved in much the same manner as
- specifying different resource options on different nodes.
-
- The difference is that because they are cluster options, one cannot (or should
- not, because they won't work) use attribute-based expressions. The following
- example illustrates how to set +maintenance_mode+ during a scheduled
- maintenance window. This will keep the cluster running but not monitor, start,
- or stop resources during this time.
-
- .Schedule a maintenance window for 9 to 11 p.m. CDT Sept. 20, 2019
- =====
- [source,XML]
- -------
- <crm_config>
- <cluster_property_set id="cib-bootstrap-options">
- <nvpair id="bootstrap-stonith-enabled" name="stonith-enabled" value="1"/>
- </cluster_property_set>
- <cluster_property_set id="normal-set" score="10">
- <nvpair id="normal-maintenance-mode" name="maintenance-mode" value="false"/>
- </cluster_property_set>
- <cluster_property_set id="maintenance-window-set" score="1000">
- <nvpair id="maintenance-nvpair1" name="maintenance-mode" value="true"/>
- <rule id="maintenance-rule1" score="INFINITY">
- <date_expression id="maintenance-date1" operation="in_range"
- start="2019-09-20 21:00:00 -05:00" end="2019-09-20 23:00:00 -05:00"/>
- </rule>
- </cluster_property_set>
- </crm_config>
- -------
- =====
-
- [IMPORTANT]
- ====
- The +cluster_property_set+ with an +id+ set to "cib-bootstrap-options" will
- 'always' have the highest priority, regardless of any scores. Therefore,
- rules in another +cluster_property_set+ can never take effect for any
- properties listed in the bootstrap set.
- ====
+ </cluster_property_set>
+ </crm_config>
+
+.. important:: The ``cluster_property_set`` with an ``id`` set to
+ "cib-bootstrap-options" will *always* have the highest priority,
+ regardless of any scores. Therefore, rules in another
+ ``cluster_property_set`` can never take effect for any
+ properties listed in the bootstrap set.
diff --git a/doc/sphinx/Pacemaker_Explained/status.rst b/doc/sphinx/Pacemaker_Explained/status.rst
index 800426752d..b5259b10fe 100644
--- a/doc/sphinx/Pacemaker_Explained/status.rst
+++ b/doc/sphinx/Pacemaker_Explained/status.rst
@@ -1,375 +1,375 @@
.. index::
single: status
single: XML element, status
Status -- Here be dragons
-------------------------
Most users never need to understand the contents of the status section
and can be happy with the output from ``crm_mon``.
However for those with a curious inclination, this section attempts to
provide an overview of its contents.
.. index::
single: node; status
Node Status
###########
In addition to the cluster's configuration, the CIB holds an
up-to-date representation of each cluster node in the ``status`` section.
.. topic:: A bare-bones status entry for a healthy node **cl-virt-1**
.. code-block:: xml
<node_state id="1" uname="cl-virt-1" in_ccm="true" crmd="online" crm-debug-origin="do_update_resource" join="member" expected="member">
<transient_attributes id="1"/>
<lrm id="1"/>
</node_state>
Users are highly recommended *not* to modify any part of a node's
state *directly*. The cluster will periodically regenerate the entire
section from authoritative sources, so any changes should be done
with the tools appropriate to those sources.
.. table:: **Authoritative Sources for State Information**
+----------------------+----------------------+
| CIB Object | Authoritative Source |
+======================+======================+
| node_state | pacemaker-controld |
+----------------------+----------------------+
| transient_attributes | pacemaker-attrd |
+----------------------+----------------------+
| lrm | pacemaker-execd |
+----------------------+----------------------+
The fields used in the ``node_state`` objects are named as they are
largely for historical reasons and are rooted in Pacemaker's origins
as the resource manager for the older Heartbeat project. They have remained
unchanged to preserve compatibility with older versions.
.. table:: **Node Status Fields**
+------------------+----------------------------------------------------------+
| Field | Description |
+==================+==========================================================+
| id | .. index: |
| | single: id; node status |
| | single: node; status, id |
| | |
| | Unique identifier for the node. Corosync-based clusters |
| | use a numeric counter. |
+------------------+----------------------------------------------------------+
| uname | .. index:: |
| | single: uname; node status |
| | single: node; status, uname |
| | |
| | The node's name as known by the cluster |
+------------------+----------------------------------------------------------+
| in_ccm | .. index:: |
| | single: in_ccm; node status |
| | single: node; status, in_ccm |
| | |
| | Is the node a member at the cluster communication later? |
| | Allowed values: ``true``, ``false``. |
+------------------+----------------------------------------------------------+
| crmd | .. index:: |
| | single: crmd; node status |
| | single: node; status, crmd |
| | |
| | Is the node a member at the pacemaker layer? Allowed |
| | values: ``online``, ``offline``. |
+------------------+----------------------------------------------------------+
| crm-debug-origin | .. index:: |
| | single: crm-debug-origin; node status |
| | single: node; status, crm-debug-origin |
| | |
| | The name of the source function that made the most |
| | recent change (for debugging purposes). |
+------------------+----------------------------------------------------------+
| join | .. index:: |
| | single: join; node status |
| | single: node; status, join |
| | |
| | Does the node participate in hosting resources? |
| | Allowed values: ``down``, ``pending``, ``member``. |
| | ``banned``. |
+------------------+----------------------------------------------------------+
| expected | .. index:: |
| | single: expected; node status |
| | single: node; status, expected |
| | |
| | Expected value for ``join``. |
+------------------+----------------------------------------------------------+
The cluster uses these fields to determine whether, at the node level, the
node is healthy or is in a failed state and needs to be fenced.
Transient Node Attributes
#########################
-Like regular :ref:`Node Attributes`, the name/value
+Like regular :ref:`node_attributes`, the name/value
pairs listed in the ``transient_attributes`` section help to describe the
node. However they are forgotten by the cluster when the node goes offline.
This can be useful, for instance, when you want a node to be in standby mode
(not able to run resources) just until the next reboot.
In addition to any values the administrator sets, the cluster will
also store information about failed resources here.
.. topic:: A set of transient node attributes for node **cl-virt-1**
.. code-block:: xml
<transient_attributes id="cl-virt-1">
<instance_attributes id="status-cl-virt-1">
<nvpair id="status-cl-virt-1-pingd" name="pingd" value="3"/>
<nvpair id="status-cl-virt-1-probe_complete" name="probe_complete" value="true"/>
<nvpair id="status-cl-virt-1-fail-count-pingd:0.monitor_30000" name="fail-count-pingd:0#monitor_30000" value="1"/>
<nvpair id="status-cl-virt-1-last-failure-pingd:0" name="last-failure-pingd:0" value="1239009742"/>
</instance_attributes>
</transient_attributes>
In the above example, we can see that a monitor on the ``pingd:0`` resource has
failed once, at 09:22:22 UTC 6 April 2009. [#]_.
We also see that the node is connected to three **pingd** peers and that
all known resources have been checked for on this machine (``probe_complete``).
.. index::
single: Operation History
Operation History
#################
A node's resource history is held in the ``lrm_resources`` tag (a child
of the ``lrm`` tag). The information stored here includes enough
information for the cluster to stop the resource safely if it is
removed from the ``configuration`` section. Specifically, the resource's
``id``, ``class``, ``type`` and ``provider`` are stored.
.. topic:: A record of the ``apcstonith`` resource
.. code-block:: xml
<lrm_resource id="apcstonith" type="apcmastersnmp" class="stonith"/>
Additionally, we store the last job for every combination of
``resource``, ``action`` and ``interval``. The concatenation of the values in
this tuple are used to create the id of the ``lrm_rsc_op`` object.
.. table:: **Contents of an lrm_rsc_op job**
+------------------+----------------------------------------------------------+
| Field | Description |
+==================+==========================================================+
| id | .. index:: |
| | single: id; action status |
| | single: action; status, id |
| | |
| | Identifier for the job constructed from the resource's |
| | ``operation`` and ``interval``. |
+------------------+----------------------------------------------------------+
| call-id | .. index:: |
| | single: call-id; action status |
| | single: action; status, call-id |
| | |
| | The job's ticket number. Used as a sort key to determine |
| | the order in which the jobs were executed. |
+------------------+----------------------------------------------------------+
| operation | .. index:: |
| | single: operation; action status |
| | single: action; status, operation |
| | |
| | The action the resource agent was invoked with. |
+------------------+----------------------------------------------------------+
| interval | .. index:: |
| | single: interval; action status |
| | single: action; status, interval |
| | |
| | The frequency, in milliseconds, at which the operation |
| | will be repeated. A one-off job is indicated by 0. |
+------------------+----------------------------------------------------------+
| op-status | .. index:: |
| | single: op-status; action status |
| | single: action; status, op-status |
| | |
| | The job's status. Generally this will be either 0 (done) |
| | or -1 (pending). Rarely used in favor of ``rc-code``. |
+------------------+----------------------------------------------------------+
| rc-code | .. index:: |
| | single: rc-code; action status |
| | single: action; status, rc-code |
| | |
| | The job's result. Refer to the *Resource Agents* chapter |
| | of *Pacemaker Administration* for details on what the |
| | values here mean and how they are interpreted. |
+------------------+----------------------------------------------------------+
| last-run | .. index:: |
| | single: last-run; action status |
| | single: action; status, last-run |
| | |
| | Machine-local date/time, in seconds since epoch, at |
| | which the job was executed. For diagnostic purposes. |
+------------------+----------------------------------------------------------+
| last-rc-change | .. index:: |
| | single: last-rc-change; action status |
| | single: action; status, last-rc-change |
| | |
| | Machine-local date/time, in seconds since epoch, at |
| | which the job first returned the current value of |
| | ``rc-code``. For diagnostic purposes. |
+------------------+----------------------------------------------------------+
| exec-time | .. index:: |
| | single: exec-time; action status |
| | single: action; status, exec-time |
| | |
| | Time, in milliseconds, that the job was running for. |
| | For diagnostic purposes. |
+------------------+----------------------------------------------------------+
| queue-time | .. index:: |
| | single: queue-time; action status |
| | single: action; status, queue-time |
| | |
| | Time, in seconds, that the job was queued for in the |
| | LRMd. For diagnostic purposes. |
+------------------+----------------------------------------------------------+
| crm_feature_set | .. index:: |
| | single: crm_feature_set; action status |
| | single: action; status, crm_feature_set |
| | |
| | The version which this job description conforms to. Used |
| | when processing ``op-digest``. |
+------------------+----------------------------------------------------------+
| transition-key | .. index:: |
| | single: transition-key; action status |
| | single: action; status, transition-key |
| | |
| | A concatenation of the job's graph action number, the |
| | graph number, the expected result and the UUID of the |
| | controller instance that scheduled it. This is used to |
| | construct ``transition-magic`` (below). |
+------------------+----------------------------------------------------------+
| transition-magic | .. index:: |
| | single: transition-magic; action status |
| | single: action; status, transition-magic |
| | |
| | A concatenation of the job's ``op-status``, ``rc-code`` |
| | and ``transition-key``. Guaranteed to be unique for the |
| | life of the cluster (which ensures it is part of CIB |
| | update notifications) and contains all the information |
| | needed for the controller to correctly analyze and |
| | process the completed job. Most importantly, the |
| | decomposed elements tell the controller if the job |
| | entry was expected and whether it failed. |
+------------------+----------------------------------------------------------+
| op-digest | .. index:: |
| | single: op-digest; action status |
| | single: action; status, op-digest |
| | |
| | An MD5 sum representing the parameters passed to the |
| | job. Used to detect changes to the configuration, to |
| | restart resources if necessary. |
+------------------+----------------------------------------------------------+
| crm-debug-origin | .. index:: |
| | single: crm-debug-origin; action status |
| | single: action; status, crm-debug-origin |
| | |
| | The origin of the current values. For diagnostic |
| | purposes. |
+------------------+----------------------------------------------------------+
Simple Operation History Example
________________________________
.. topic:: A monitor operation (determines current state of the ``apcstonith`` resource)
.. code-block:: xml
<lrm_resource id="apcstonith" type="apcmastersnmp" class="stonith">
<lrm_rsc_op id="apcstonith_monitor_0" operation="monitor" call-id="2"
rc-code="7" op-status="0" interval="0"
crm-debug-origin="do_update_resource" crm_feature_set="3.0.1"
op-digest="2e3da9274d3550dc6526fb24bfcbcba0"
transition-key="22:2:7:2668bbeb-06d5-40f9-936d-24cb7f87006a"
transition-magic="0:7;22:2:7:2668bbeb-06d5-40f9-936d-24cb7f87006a"
last-run="1239008085" last-rc-change="1239008085" exec-time="10" queue-time="0"/>
</lrm_resource>
In the above example, the job is a non-recurring monitor operation
often referred to as a "probe" for the ``apcstonith`` resource.
The cluster schedules probes for every configured resource on a node when
the node first starts, in order to determine the resource's current state
before it takes any further action.
From the ``transition-key``, we can see that this was the 22nd action of
the 2nd graph produced by this instance of the controller
(2668bbeb-06d5-40f9-936d-24cb7f87006a).
The third field of the ``transition-key`` contains a 7, which indicates
that the job expects to find the resource inactive. By looking at the ``rc-code``
property, we see that this was the case.
As that is the only job recorded for this node, we can conclude that
the cluster started the resource elsewhere.
Complex Operation History Example
_________________________________
.. topic:: Resource history of a ``pingd`` clone with multiple jobs
.. code-block:: xml
<lrm_resource id="pingd:0" type="pingd" class="ocf" provider="pacemaker">
<lrm_rsc_op id="pingd:0_monitor_30000" operation="monitor" call-id="34"
rc-code="0" op-status="0" interval="30000"
crm-debug-origin="do_update_resource" crm_feature_set="3.0.1"
transition-key="10:11:0:2668bbeb-06d5-40f9-936d-24cb7f87006a"
last-run="1239009741" last-rc-change="1239009741" exec-time="10" queue-time="0"/>
<lrm_rsc_op id="pingd:0_stop_0" operation="stop"
crm-debug-origin="do_update_resource" crm_feature_set="3.0.1" call-id="32"
rc-code="0" op-status="0" interval="0"
transition-key="11:11:0:2668bbeb-06d5-40f9-936d-24cb7f87006a"
last-run="1239009741" last-rc-change="1239009741" exec-time="10" queue-time="0"/>
<lrm_rsc_op id="pingd:0_start_0" operation="start" call-id="33"
rc-code="0" op-status="0" interval="0"
crm-debug-origin="do_update_resource" crm_feature_set="3.0.1"
transition-key="31:11:0:2668bbeb-06d5-40f9-936d-24cb7f87006a"
last-run="1239009741" last-rc-change="1239009741" exec-time="10" queue-time="0" />
<lrm_rsc_op id="pingd:0_monitor_0" operation="monitor" call-id="3"
rc-code="0" op-status="0" interval="0"
crm-debug-origin="do_update_resource" crm_feature_set="3.0.1"
transition-key="23:2:7:2668bbeb-06d5-40f9-936d-24cb7f87006a"
last-run="1239008085" last-rc-change="1239008085" exec-time="20" queue-time="0"/>
</lrm_resource>
When more than one job record exists, it is important to first sort
them by ``call-id`` before interpreting them.
Once sorted, the above example can be summarized as:
#. A non-recurring monitor operation returning 7 (not running), with a ``call-id`` of 3
#. A stop operation returning 0 (success), with a ``call-id`` of 32
#. A start operation returning 0 (success), with a ``call-id`` of 33
#. A recurring monitor returning 0 (success), with a ``call-id`` of 34
The cluster processes each job record to build up a picture of the
resource's state. After the first and second entries, it is
considered stopped, and after the third it considered active.
Based on the last operation, we can tell that the resource is
currently active.
Additionally, from the presence of a ``stop`` operation with a lower
``call-id`` than that of the ``start`` operation, we can conclude that the
resource has been restarted. Specifically this occurred as part of
actions 11 and 31 of transition 11 from the controller instance with the key
``2668bbeb...``. This information can be helpful for locating the
relevant section of the logs when looking for the source of a failure.
.. [#] You can use the standard ``date`` command to print a human-readable version
of any seconds-since-epoch value, for example ``date -d @1239009742``.
diff --git a/doc/sphinx/_static/pacemaker.css b/doc/sphinx/_static/pacemaker.css
index 7802679455..ef5b67172a 100644
--- a/doc/sphinx/_static/pacemaker.css
+++ b/doc/sphinx/_static/pacemaker.css
@@ -1,115 +1,131 @@
@import url("pyramid.css");
/* Defaults for entire page */
body {
color: #3f3f3f;
font-family: "Open Sans", sans-serif;
font-size: 11pt;
font-weight: 400;
line-height: 1.65;
}
/* Strip at top of page */
div.related {
line-height: 1.65;
color: #3f3f3f;
font-size: 10pt;
background-color: #fff;
border-bottom: solid 4px #00b2e2;
font-family: "Roboto Slab", serif;
}
div.related a {
color: #1d2429;
}
div.related ul {
padding-left: 1em;
}
/* Sidebar */
div.bodywrapper {
/* The final value must match the sidebarwidth theme option */
margin: 0 0 0 230px;
}
div.sphinxsidebar {
color: #1d2429;
background-color: #f5f6f7;
font-family: "Roboto Slab", serif;
font-size: 0.9em;
line-height: 1.65;
letter-spacing: 0.075em;
/*text-transform: uppercase;*/
}
div.sphinxsidebar h3,
div.sphinxsidebar h4 {
font-family: "Roboto Slab", serif;
color: #1d2429;
font-size: 1.4em;
font-weight: 700;
border-bottom: 3px solid #00b2e2;
line-height: 1.5;
letter-spacing: 0.075em;
background-color: #f5f6f7;
}
div.sphinxsidebar p,
div.sphinxsidebar ul,
div.sphinxsidebar h3 a,
div.sphinxsidebar a {
color: #1d2429;
}
/* Main text */
div.body {
color: #3f3f3f;
font-size: 11pt;
border: none;
}
div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
font-family: "Roboto Slab", serif;
font-weight: 700;
color: #1d2429;
font-variant: none;
line-height: 1.5;
}
div.body h1 {
border-top: none;
font-size: 3.5em;
background-color: #fff;
border-bottom: solid 3px #00b2e2;
}
div.body h2 {
font-size: 1.75em;
background-color: #fff;
border-bottom: solid 2px #00b2e2;
}
div.body h3 {
font-size: 1.5em;
background-color: #fff;
border-bottom: solid 1px #00b2e2;
}
div.body p,
div.body dd,
div.body li {
line-height: 1.65;
}
pre {
font-family: "Lucida Console", Monaco, monospace;
font-size: 0.9em;
line-height: 1.5;
background-color: #f5f6f7;
color: #1d2429;
border: none;
border-radius: 11px;
box-shadow: 0px 2px 5px #aaaaaa inset;
}
.viewcode-back,
.download {
font-family: "Open Sans", sans-serif;
}
+
+/* The pyramid theme uses an exclamation point for "note", and nothing (not
+ * even a background shade) for "important", and it supplies a light bulb icon
+ * but doesn't use it. Rearrange that a bit: use the light bulb for note, and
+ * the exclamation point (with the usual shading) for important.
+ */
+div.note {
+ background: #e1ecfe url(dialog-topic.png) no-repeat 10px 8px;
+}
+div.important {
+ border: 2px solid #7a9eec;
+ border-right-style: none;
+ border-left-style: none;
+ padding: 10px 20px 10px 60px;
+ background: #e1ecfe url(dialog-note.png) no-repeat 10px 8px;
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 3:54 AM (1 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1018186
Default Alt Text
(182 KB)
Attached To
Mode
rP Pacemaker
Attached
Detach File
Event Timeline
Log In to Comment