第 14 章 使用 pcs 命令导出资源约束
您可以使用 pcs constraint
命令的 --output-format=cmd
选项显示可用来在不同系统上重新创建配置的资源约束的 pcs
命令。
以下示例流程创建两个资源,配置三个资源约束,并显示 6 个您可以用来在不同系统上重新创建约束的 'pcs' 命令。
流程
创建名一个为
VirtualIP
的IPaddr2
资源。pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24
# pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24 Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPaddr2')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建名一个为
Website
的apache
资源。pcs resource create Website apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status"
# pcs resource create Website apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status" Assumed agent name 'ocf:heartbeat:apache' (deduced from 'apache')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 为
Website
资源配置一个位置约束。pcs constraint location Website avoids node1
# pcs constraint location Website avoids node1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 为
Website
和VirtualIP
资源配置一个托管约束。pcs constraint colocation add Website with VirtualIP
# pcs constraint colocation add Website with VirtualIP
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 为
Website
和VirtualIP
资源配置一个顺序约束。pcs constraint order VirtualIP then Website
# pcs constraint order VirtualIP then Website Adding VirtualIP Website (kind: Mandatory) (Options: first-action=start then-action=start)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 显示您可以用来在不同系统上重新创建约束的
pcs
命令。Copy to Clipboard Copied! Toggle word wrap Toggle overflow