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')

다음 명령은 위치 제약 조건, 공동 배치 제약 조건 및 두 리소스에 대한 순서 제약 조건을 구성합니다.

# 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