Show Table of Contents
5.5. 资源组
集群的最常用元素之一是需要放在同一位置的资源组,按顺序启动,并以相反顺序停止。要简化这个配置,Pacemaker 支持组概念。
使用以下命令创建资源组,指定该组中包含的资源。如果该组不存在,这个命令可创建该组。如果该组存在,这个命令会在该组中添加附加资源。这些资源会按照这个命令中指定的顺序启动,并以与启动顺序的相反顺序停止。
pcs resource group add group_name resource_id [resource_id] ... [resource_id] [--before resource_id | --after resource_id
可使用这个命令的
--before 和 --after 选项指定所添加资源与该组中现有资源间的相对位置。
还可以使用以下命令在创建该资源时,在现有组中添加新资源。会将您创建的资源添加到名为 group_name 的组中。
pcs resource create resource_id standard:provider:type|type [resource_options] [op operation_action operation_options] --group group_name
使用以下命令从组中删除资源。如果该组中没有资源,这个命令会将该组删除。
pcs resource group remove group_name resource_id...
以下命令列出目前配置的资源组。
pcs resource group list
以下示例创建名为
shortcut 的资源组,该资源组包含现有资源 IPaddr 和 Email。
# pcs resource group add shortcut IPaddr Email
一个组所包含的资源数是无限的。资源的基本属性如下。
- 资源按照其指定顺序启动(在这个示例中,首先是
Public-IP,然后是Email)。 - 资源按照其指定顺序的相反顺序停止(首先是
Email,然后是Public-IP)。
如果该组中的某个无法在任何位置运行,那么在该资源后指定的资源将都无法运行。
- 如果
Public-IP无法在任何位置运行,那么Email也不能。 - 如果
Email无法在任何位置运行,则不会以任何方式影响Public-IP。
显然,随着组的增大,创建资源组的配置工作会明显减少。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.