第14章 pcs コマンドとしてのリソース制約のエクスポート
pcs constraint コマンドの --output-format=cmd オプションを使用して、別のシステムで設定されたリソース制約を再作成するために使用できる pcs コマンドを表示できます。
次の手順例では、2 つのリソースを作成し、3 つのリソース制約を設定し、別のシステムで制約を再作成するために使用できる xi`pcs` コマンドを表示します。
手順
VirtualIPという名前のIPaddr2リソースを作成します。# pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24 Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPaddr2')Websiteという名前のapacheリソースを作成します。# 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')Websiteリソースの場所の制約を設定します。# pcs constraint location Website avoids node1WebsiteとVirtualIPリソースのコロケーション制約を設定します。# pcs constraint colocation add Website with VirtualIPWebsiteおよび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