第 14 章 使用 pcs 命令导出资源约束


您可以使用 pcs constraint 命令的 --output-format=cmd 选项显示可用来在不同系统上重新创建配置的资源约束的 pcs 命令。

以下示例流程创建两个资源,配置三个资源约束,并显示 6 个您可以用来在不同系统上重新创建约束的 'pcs' 命令。

流程

  1. 创建名一个为 VirtualIPIPaddr2 资源。

    # 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 Toggle word wrap
  2. 创建名一个为 Websiteapache 资源。

    # 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 Toggle word wrap
  3. Website 资源配置一个位置约束。

    # pcs constraint location Website avoids node1
    Copy to Clipboard Toggle word wrap
  4. WebsiteVirtualIP 资源配置一个托管约束。

    # pcs constraint colocation add Website with VirtualIP
    Copy to Clipboard Toggle word wrap
  5. WebsiteVirtualIP 资源配置一个顺序约束。

    # pcs constraint order VirtualIP then Website
    Adding VirtualIP Website (kind: Mandatory) (Options: first-action=start then-action=start)
    Copy to Clipboard Toggle word wrap
  6. 显示您可以用来在不同系统上重新创建约束的 pcs 命令。

    # pcs constraint --output-format=cmd
    pcs -- constraint location add location-Website-node1--INFINITY resource%Website node1 -INFINITY;
    pcs -- constraint colocation add Website with VirtualIP INFINITY \
      id=colocation-Website-VirtualIP-INFINITY;
    pcs -- constraint order start VirtualIP then start Website \
      id=order-VirtualIP-Website-mandatory
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat