16.2. Configuring a Pacemaker location constraint using rules


Use the following command to configure a Pacemaker constraint that uses rules.

# pcs constraint location rsc rule[resource-discovery=option] [role=promoted|unpromoted] [score=score | score-attribute=attribute] expression
  • If score is omitted, it defaults to INFINITY.
  • 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".
  • 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.

The expression option in Pacemaker rules

The expression option can be one of the following where duration_options and date_spec_options are: hours, months, weeks, and years as described in the "Properties of a Date Specification" table in Pacemaker rules.

  • defined|not_defined attribute
  • attribute lt|gt|lte|gte|eq|ne [string|integer|number|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)

Durations in Pacemaker rules

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 supported values for duration options are seconds, minutes, hours, days, weeks, months, and years.

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 on Friday the thirteenth.

# pcs constraint location Webserver rule date-spec weekdays=5 monthdays=13
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部