Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 49. Determining resource location with rules
For more complicated location constraints, you can use Pacemaker rules to determine a resource’s location.
49.1. Pacemaker rules
Pacemaker rules can be used to make your configuration more dynamic. One use of rules might be to assign machines to different processing groups (using a node attribute) based on time and to then use that attribute when creating location constraints.
Each rule can contain a number of expressions, date-expressions and even other rules. The results of the expressions are combined based on the rule’s boolean-op
field to determine if the rule ultimately evaluates to true
or false
. What happens next depends on the context in which the rule is being used.
Field | Description |
---|---|
|
Limits the rule to apply only when the resource is in that role. Allowed values: |
|
The score to apply if the rule evaluates to |
|
The node attribute to look up and use as a score if the rule evaluates to |
|
How to combine the result of multiple expression objects. Allowed values: |
49.1.1. Node attribute expressions
Node attribute expressions are used to control a resource based on the attributes defined by a node or nodes.
Field | Description |
---|---|
| The node attribute to test |
|
Determines how the value(s) should be tested. Allowed values: |
| The comparison to perform. Allowed values:
*
*
*
*
*
*
*
* |
|
User supplied value for comparison (required unless |
In addition to any attributes added by the administrator, the cluster defines special, built-in node attributes for each node that can also be used, as described in the following table.
Name | Description |
---|---|
| Node name |
| Node ID |
|
Node type. Possible values are |
|
|
|
The value of the |
|
The value of the |
| The role the relevant promotable clone has on this node. Valid only within a rule for a location constraint for a promotable clone. |
49.1.2. Time/date based expressions
Date expressions are used to control a resource or cluster option based on the current date/time. They can contain an optional date specification.
Field | Description |
---|---|
| A date/time conforming to the ISO8601 specification. |
| A date/time conforming to the ISO8601 specification. |
| Compares the current date/time with the start or the end date or both the start and end date, depending on the context. Allowed values:
*
*
*
* |
49.1.3. Date specifications
Date specifications are used to create cron-like expressions relating to time. Each field can contain a single number or a single range. Instead of defaulting to zero, any field not supplied is ignored.
For example, monthdays="1"
matches the first day of every month and hours="09-17"
matches the hours between 9 am and 5 pm (inclusive). However, you cannot specify weekdays="1,2"
or weekdays="1-2,5-6"
since they contain multiple ranges.
Field | Description |
---|---|
| A unique name for the date |
| Allowed values: 0-23 |
| Allowed values: 0-31 (depending on month and year) |
| Allowed values: 1-7 (1=Monday, 7=Sunday) |
| Allowed values: 1-366 (depending on the year) |
| Allowed values: 1-12 |
|
Allowed values: 1-53 (depending on |
| Year according the Gregorian calendar |
|
May differ from Gregorian years; for example, |
| Allowed values: 0-7 (0 is new, 4 is full moon). |
49.2. Configuring a Pacemaker location constraint using rules
Use the following command to configure a Pacemaker constraint that uses rules. If score
is omitted, it defaults to INFINITY. If resource-discovery
is omitted, it defaults to always
.
For information about the resource-discovery
option, see Limiting resource discovery to a subset of nodes.
As with basic location constraints, you can use regular expressions for resources with these constraints as well.
When using rules to configure location constraints, the value of score
can be positive or negative, with a positive value indicating "prefers" and a negative value indicating "avoids".
pcs constraint location rsc rule [resource-discovery=option] [role=master|slave] [score=score | score-attribute=attribute] expression
The expression option can be one of the following where duration_options and date_spec_options are: hours, monthdays, weekdays, yeardays, months, weeks, years, weekyears, and moon as described in the "Properties of a Date Specification" table in Date specifications.
-
defined|not_defined attribute
-
attribute lt|gt|lte|gte|eq|ne [string|integer|number
(RHEL 8.4 and later)|version] value
-
date gt|lt date
-
date in_range date to date
-
date in_range date to duration duration_options …
-
date-spec date_spec_options
-
expression and|or expression
-
(expression)
Note that durations are an alternative way to specify an end for in_range
operations by means of calculations. For example, you can specify a duration of 19 months.
The following location constraint configures an expression that is true if now is any time in the year 2018.
# pcs constraint location Webserver rule score=INFINITY date-spec years=2018
The following command configures an expression that is true from 9 am to 5 pm, Monday through Friday. Note that the hours value of 16 matches up to 16:59:59, as the numeric value (hour) still matches.
# pcs constraint location Webserver rule score=INFINITY date-spec hours="9-16" weekdays="1-5"
The following command configures an expression that is true when there is a full moon on Friday the thirteenth.
# pcs constraint location Webserver rule date-spec weekdays=5 monthdays=13 moon=4
To remove a rule, use the following command. If the rule that you are removing is the last rule in its constraint, the constraint will be removed.
pcs constraint rule remove rule_id