12.5. pcs コマンドとしてのリソース制約のエクスポート
Red Hat Enterprise Linux 9.3 では、pcs constraint
コマンドの --output-format=cmd
オプションを使用して、設定済みのリソース制約を別のシステムで再作成するのに使用できる pcs
コマンドを表示できます。
次のコマンドは、IPaddr2
リソースと apache
リソースを作成します。
# pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24 Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPaddr2') # 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')
次のコマンドは、2 つのリソースの場所の制約、コロケーション制約、および順序制約を設定します。
# pcs constraint location Website avoids node1 # pcs constraint colocation add Website with VirtualIP # pcs constraint order VirtualIP then Website Adding VirtualIP Website (kind: Mandatory) (Options: first-action=start then-action=start)
リソースと制約を作成した後に次のコマンドを実行すると、別のシステムで制約を再作成するために使用できる 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