Show Table of Contents
第 5 章 配置集群资源
本章论述了在集群中配置资源的信息。
5.1. 创建资源
使用以下命令创建集群资源。
pcs resource create resource_id standard:provider:type|type [resource options] [op operation_action operation_options [operation_action operation_options]...] [meta meta_options...] [--clone clone_options | --master master_options | --group group_name [--before resource_id | --after resource_id]] [--disabled]
指定
--group 选项后,会将该资源添加到在此命名的资源组中。如果该资源组不存在,这个命令会创建该资源组,并将这个资源添加到该组中。有关资源组的详情,请查看 第 5.5 节 “资源组”。
--before 和 --after 选项指定所添加资源与某个资源组中已存在资源间的相对位置。
指定
--disabled 选项表示不会自动启动该资源。
下面的命令创建一个名为 VirtualIP,使用
ocf 标准,heartbeat 提供程序,以及类型 IPaddr2 的资源。这个资源的浮动地址为 192.168.0.120,该系统会每 30 秒检查一次,确定该资源是否运行。
# pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.120 cidr_netmask=24 op monitor interval=30s
另外,可省略 standard 和 provider 字段,使用以下命令创建资源。这样就默认使用
ocf 标准以及 heartbeat 提供程序。
# pcs resource create VirtualIP IPaddr2 ip=192.168.0.120 cidr_netmask=24 op monitor interval=30s
使用以下命令删除配置的资源。
pcs resource delete resource_id
例如:以下命令可删除资源 ID 为
VirtualIP 的现有资源。
# pcs resource delete VirtualIP- 有关
pcs resource create命令中 resource_id、standard、provider 和 type 字段的详情请参考 第 5.2 节 “资源属性”。 - 有关为每个资源定义资源参数的详情请参考 第 5.3 节 “具体资源参数”。
- 有关定义资源元数据选项以便集群使用,从而决定资源行为的详情,请参考 第 5.4 节 “资源元数据选项”。
- 有关定义某个资源中的操作的详情请参考 第 5.6 节 “资源操作”。

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.