第 24 章 Configuring a node placement strategy


Pacemaker decides where to place a resource according to the resource allocation scores on every node. The resource will be allocated to the node where the resource has the highest score. This allocation score is derived from a combination of factors, including resource constraints, resource-stickiness settings, prior failure history of a resource on each node, and utilization of each node.

If the resource allocation scores on all the nodes are equal, by the default placement strategy Pacemaker will choose a node with the least number of allocated resources for balancing the load. If the number of resources on each node is equal, the first eligible node listed in the CIB will be chosen to run the resource.

Often, however, different resources use significantly different proportions of a node’s capacities (such as memory or I/O). You cannot always balance the load ideally by taking into account only the number of resources allocated to a node. In addition, if resources are placed such that their combined requirements exceed the provided capacity, they may fail to start completely or they may run with degraded performance. To take these factors into account, Pacemaker allows you to configure the following components:

  • the capacity a particular node provides
  • the capacity a particular resource requires
  • an overall strategy for placement of resources

24.1. Utilization attributes and placement strategy

To configure the capacity that a node provides or a resource requires, you can use utilization attributes for nodes and resources. You do this by setting a utilization variable for a resource and assigning a value to that variable to indicate what the resource requires, and then setting that same utilization variable for a node and assigning a value to that variable to indicate what that node provides.

You can name utilization attributes according to your preferences and define as many name and value pairs as your configuration needs. The values of utilization attributes must be integers.

Configuring node and resource capacity

The following example procedure configures utilization attributes for two nodes and then specifies the same utilization attributes that three different resources require. A node is considered eligible for a resource if it has sufficient free capacity to satisfy the resource’s requirements, as defined by the utilization attributes.

Procedure

  1. Configure utilization attributes for node1. This command configures a node attribute of CPU capacity, setting this attribute as the variable cpu and defining node1 as providing a CPU capacity of two. This command also defines a utilization attribute of RAM capacity, setting this attribute as the variable memory and defining node1 as providing a RAM capacity of 2048.

    # pcs node utilization node1 cpu=2 memory=2048
  2. Configure utilization attributes for node2. This command configures a node attribute of CPU capacity, setting this attribute as the variable cpu and defining node2 as providing a CPU capacity of four. This command also defines a utilization attribute of RAM capacity, setting this attribute as the variable memory and defining node2 as providing a RAM capacity of 2048.

    # pcs node utilization node2 cpu=4 memory=2048
  3. Specify the utilization attributes that resource dummy-small requires. In this example, dummy-small requires a CPU capacity of 1 and a RAM capacity of 1024.

    # pcs resource utilization dummy-small cpu=1 memory=1024
  4. Specify the utilization attributes that resource dummy-medium requires. In this example, dummy-medium requires a CPU capacity of 2 and a RAM capacity of 2048.

    # pcs resource utilization dummy-medium cpu=2 memory=2048
  5. Specify the utilization attributes that resource dummy-large requires. In this example, dummy-requires requires a CPU capacity of 1 and a RAM capacity of 3072.

    # pcs resource utilization dummy-large cpu=3 memory=3072

Displaying node utilization as pcs commands

You can export node utilization as a series of pcs commands by using the --output-format=cmd option. This is useful for scripting, automation, or replicating the same configuration on a different system.

注意

You can display the configured node utilization in one of three formats:

  • text: Displays the output in plain text. This is the default format.
  • json: Displays the output in a machine-readable JSON format, which is useful for scripting and automation.
  • cmd: Displays the output as a series of pcs commands, which you can use to recreate the same node utilization on a different system.
  • To display the configured node utilization as a series of pcs commands:

    # pcs node utilization --output-format=cmd

    Example output

    pcs node utilization node1 cpu=2
    pcs node utilization node2 cpu=4

Configuring placement strategy

After you have configured the capacities your nodes provide and the capacities your resources require, you need to set the placement-strategy cluster property, otherwise the capacity configurations have no effect.

Four values are available for the placement-strategy cluster property:

  • default - Utilization values are not taken into account at all. Resources are allocated according to allocation scores. If scores are equal, resources are evenly distributed across nodes.
  • utilization - Utilization values are taken into account only when deciding whether a node is considered eligible (that is, whether it has sufficient free capacity to satisfy the resource’s requirements). Load-balancing is still done based on the number of resources allocated to a node.
  • balanced - Utilization values are taken into account when deciding whether a node is eligible to serve a resource and when load-balancing, so an attempt is made to spread the resources in a way that optimizes resource performance.
  • minimal - Utilization values are taken into account only when deciding whether a node is eligible to serve a resource. For load-balancing, an attempt is made to concentrate the resources on as few nodes as possible, thereby enabling possible power savings on the remaining nodes.

The following example command sets the value of placement-strategy to balanced. After running this command, Pacemaker will ensure the load from your resources will be distributed evenly throughout the cluster, without the need for complicated sets of colocation constraints.

# pcs property set placement-strategy=balanced
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部