第 14 章 Exporting resource constraints as pcs commands


You can display the pcs commands that can be used to re-create configured resource constraints on a different system using the --output-format=cmd option of the pcs constraint command.

The following example procecures creates two resources, configures three resource constraints, and displays the xi`pcs` commands you can use to re-create the constraints on a different system.

Procedure

  1. Create an IPaddr2 resource named VirtualIP.

    # pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24
    Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPaddr2')
  2. Create an apache resource named Website.

    # 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')
  3. Configure a location constraint for the Website resource.

    # pcs constraint location Website avoids node1
  4. Configure a colocation constraint for the Website and VirtualIP resources.

    # pcs constraint colocation add Website with VirtualIP
  5. Configure an order constraint for the Website and VirtualIP resources.

    # pcs constraint order VirtualIP then Website
    Adding VirtualIP Website (kind: Mandatory) (Options: first-action=start then-action=start)
  6. Display the pcs commands you can use to re-create the constraints on a different system.

    # 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
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部