Show Table of Contents
8.2. 多状态资源:有多个模式的资源
多状态资源是特殊的克隆资源。它们允许实例使用处于两个操作模式之一,即
Master 和 Slave。模式的名称没有任何特殊含义,只是在启动实例时,必须使用 Slave 状态。
可使用下面的一个命令创建作为主/辅克隆的资源。
pcs resource create resource_id standard:provider:type|type [resource options] \ --master [meta master_options]
master/slave 克隆的名称应为
resource_id-master。
另外,可使用以下命令,根据之前创建的资源或资源组创建 master/slave 资源:使用这个命令时,可指定 master/slave 克隆名称。如果未指定名称,则 master/slave 克隆的名称将为
resource_id-master 或 group_name-master。
pcs resource master master/slave_name resource_id|group_name [master_options]
有关此选项的详情请查看 第 5.1 节 “创建资源”。
在 表 8.2 “多状态资源的属性” 中论述了可为多状态资源指定的选项。
表 8.2. 多状态资源的属性
| 项 | 描述 |
|---|---|
id
|
多状态资源的名称
|
priority, target-role, is-managed
|
请查看 表 5.3 “资源元数据选项”。
|
clone-max, clone-node-max, notify, globally-unique, ordered, interleave
|
请查看 表 8.1 “资源克隆选项”。
|
master-max
| |
master-node-max
|
8.2.1. 监控多状态资源
如只要为 master 添加监控操作,可在该资源中添加附加监控操作。注:资源中的每个监控操作必须采用不同的间隔。
以下示例以 11 秒为间隔在 master 资源中为
ms_resource 设置监控操作。这个监视器资源是默认的 10 秒间隔监控操作之外的资源。
# pcs resource op add ms_resource interval=11s role=Master8.2.2. 多状态限制
在大多数情况下,多状态资源可在每个活跃集群节点中有单一副本。如果不是这种情况,则可使用资源位置限制指明首先为其分配副本的集群节点。这些限制与常规资源的编写没有任何不同。
有关资源位置限制的详情,请参考 第 6.1 节 “位置限制”。
可创建节点共置限制,用来指定该资源是 master 还是 slave 资源。以下命令创建资源节点共置限制。
pcs constraint colocation add [master|slave] source_resource with [master|slave] target_resource [score] [options]
有关资源位置限制的详情,请查看 第 6.3 节 “资源节点共置(Colocation)”。
配置包含多状态资源的排序限制时,可为资源指定的操作之一是
promote,表示将该资源从 slave 状态提升至 master。此外,可指定 demote,表示将该资源从 master 降级为 slave。
配置排序限制的命令如下。
pcs constraint order [action] resource_id then [action] resource_id [options]
有关资源排序限制的详情,请查看 第 6.2 节 “顺序限制”。

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.