11장. Determining which nodes a resource can run on


Location constraints determine which nodes a resource can run on. You can configure location constraints to determine whether a resource will prefer or avoid a specified node.

In addition to location constraints, the node on which a resource runs is influenced by the resource-stickiness value for that resource, which determines to what degree a resource prefers to remain on the node where it is currently running. For information about setting the resource-stickiness value, see Configuring a resource to prefer its current node.

11.1. Configuring location constraints

You can configure a location constraint to control which nodes a cluster resource can run on in a cluster. You can use a location constraint to make a resource prefer a specific node or to prevent it from running on certain nodes.

11.1.1. Configuring a basic location constraint

You can configure a basic location constraint to specify whether a resource prefers or avoids a node, with an optional score value to indicate the relative degree of preference for the constraint.

Procedure

  • The following command creates a location constraint for a resource to prefer the specified node or nodes. Note that it is possible to create constraints on a particular resource for more than one node with a single command:

    # pcs constraint location rsc prefers node[=score] [node[=score]] ...
  • The following command creates a location constraint for a resource to avoid the specified node or nodes:

    # pcs constraint location rsc avoids node[=score] [node[=score]] ...
  • The following table summarizes the meanings of the basic options for configuring location constraints:

    Expand
    표 11.1. Location Constraint Options
    FieldDescription

    rsc

    A resource name

    node

    A node’s name

    score

    Positive integer value to indicate the degree of preference for whether the given resource should prefer or avoid the given node. INFINITY is the default score value for a resource location constraint.

    A value of INFINITY for score in a pcs constraint location rsc prefers command indicates that the resource will prefer that node if the node is available, but does not prevent the resource from running on another node if the specified node is unavailable.

    A value of INFINITY for score in a pcs constraint location rsc avoids command indicates that the resource will never run on that node, even if no other node is available. This is the equivalent of setting a pcs constraint location add command with a score of -INFINITY.

    A numeric score (that is, not INFINITY) means the constraint is optional, and will be honored unless some other factor outweighs it. For example, if the resource is already placed on a different node, and its resource-stickiness score is higher than a prefers location constraint’s score, then the resource will be left where it is.

11.1.2. Configuring a location constraint with regular expressions

pcs supports regular expressions in location constraints on the command line. These constraints apply to multiple resources based on the regular expression matching resource name. This allows you to configure multiple location constraints with a single command line.

Procedure

  • The following command creates a location constraint to specify that resources dummy0 to dummy9 prefer node1:

    # pcs constraint location 'regexp%dummy[0-9]' prefers node1

11.1.3. Configuring a location constraint with extended regular expressions

Since Pacemaker uses POSIX extended regular expressions as documented at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04, you can specify the same constraint with the following command.

Procedure

  • To configure a location constraint with extended regular expressions:

    # pcs constraint location 'regexp%dummy[[:digit:]]' prefers node1

11.1.4. Displaying location constraints

You can list all current location constraints.

  • If resources is specified, location constraints are displayed per resource. This is the default behavior.
  • If nodes is specified, location constraints are displayed per node.
  • If specific resources or nodes are specified, then only information about those resources or nodes is displayed.

Procedure

  • To list all current location constraints:

    # pcs constraint location [config [resources [resource...]] | [nodes [node...]]] [--full]
  • To display all current location, order, and colocation constraints, use the following command. To show the internal constraint IDS, specify the --full option:

    # pcs constraint [config] [--full]

    By default, listing resource constraints does not display expired constraints. To include expired constraints in the listing, use the --all option of the pcs constraint command. This will list expired constraints, noting the constraints and their associated rules as (expired) in the display.

  • To list the constraints that reference specific resources:

    # pcs constraint ref resource ...
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동