리눅스/Pacemaker(HA Cluster)

[HA] Pacemaker Cluster (CentOS7, KVM, pacemaker) - 4

ㅎㄷㄹㅁㅇ 2024. 4. 17. 14:19
반응형

Pacemaker 구성 4

 

 

Pacemaker Constraints

Pacemaker 클러스터에서는 등록된 리소스에 대해서 제약조건을 설정 할 수 있습니다. 리소스에 제한을 두어 위치를 지정한 노드에서 시작하거나, 특정 리소스의 다음 순서에 시작되게 할 수 있습니다. 또 어떤 리소스가 같이 실행되어야 시작 할 수 있게도 설정이 가능합니다. 

 

 

Constraints의 종류

Location Constraints:

위치 제약 조건으로 리소스를 원하는 위치에서 지정하여 시작 할 수 있게 해줍니다. 초기 Score 값을 지정하고 해당 Score 값이 높은 노드에서 최초 시작합니다. 리소스의 위치는 Score 와 resource-stickiness 값에 영향을 받습니다. 


Ordering Constraints:

순서 지정 제약 조건으로 리소스의 순서를 정하는데 사용합니다. 특정 조건을 만족해야 순차적인 리소스 시작이 가능합니다. 


Colocation Constraints:

리소스 배치의 개념을 가진 제약 조건으로 한 리소스의 위치가 다른 리소스의 위치에 따라 결정되도록 구성 할 수있습니다. 

 

Pacemaker Constraint 등록

Location Constraints

- maintenance mode true 로 변경 / stonith 모니터링 false로 변경
# pcs property set maintenance-mode=true
# pcs property set stonith-enabled=false

- location constraints 설정
# pcs constraint location test_svc prefers c77_ha01.hb=200
# pcs constraint location test_svc prefers c77_ha02.hb=0

# pcs constraint location vip rule score=-INFINITY vip1 lt 1 or not_defined vip1


- maintenance mode false 로 변경 / stonith 모니터링 true로 변경
# pcs property set maintenance-mode=false
# pcs property set stonith-enabled=true

 

stonith-enabled=true / maintenance-mode=false 설정을 변경하는 이유는 안전하게 클러스터 설정을 하려는 이유입니다. stonith-enabled 설정을 변경하여, 특이사항이 발생하더라도 fencing을 통한 절체가 이루어지 않도록 합니다. maintenance-mode 또한 유지보수 모드로 모니터링을 중지하여, 리소스 fail 상황이 발생하더라도 리소스의 이동이 발생하지 않도록 합니다. 

 

# pcs constraint location test_svc prefers c77_ha01.hb=200
# pcs constraint location test_svc prefers c77_ha02.hb=0

 

위의 설정을 확인해보면 test_svc 그룹의 location constraint는 c77_ha01.hb의 score 값을 200, c77_ha02.hb의 score 값에는 0을 주어 score 의 차이로 초기 리소스를 ha01 노드에서 시작하게 합니다. 앞서 설정했던   resource-stickiness=1000 이 score 의 가변 값이고 더 높은 score를 가지고 있는 곳에서 리소스가 시작하게 됩니다. 만약 ha01 노드에서 리소스 fail이 발생하면  ha02 노드에서 resource-stickiness 값이 1000이 증가하여 200 vs 1000 이 되므로 ha02로 리소스가 이동합니다. 
 

 

# pcs constraint location vip rule score=-INFINITY vip1 lt 1 or not_defined vip1

 

위의 설정은 vip 리소스의 location constraint를 지정합니다. 해석하자면, ping 리소스의 이름은 vip1 의 값이 1보다 작거나 정의가 되어있지 않을 경우 score 값이 -INFINITY 로 변경되고 반대편 노드로 리소스가 이동합니다.

 

 

  • score 의 우선순위

 

-INFINITY <음수 <0 <양수 <INFINITY

 

 

  • pcs config show 정보를 통해 현재 설정되어 있는 리소스 보기
# pcs config show
Cluster Name: ha_cluster
Corosync Nodes:
 c77_ha01.hb c77_ha02.hb
Pacemaker Nodes:
 c77_ha01.hb c77_ha02.hb

Resources:
 Group: test_svc
  Resource: vip (class=ocf provider=heartbeat type=IPaddr2)
   Attributes: cidr_netmask=24 ip=192.168.122.186 nic=eth0
   Operations: monitor interval=10s timeout=20s (vip-monitor-interval-10s)
               start interval=0s timeout=20s (vip-start-interval-0s)
               stop interval=0s timeout=20s (vip-stop-interval-0s)
 Clone: vip_ping-clone
  Resource: vip_ping (class=ocf provider=pacemaker type=ping)
   Attributes: debug=1 host_list=192.168.122.1 name=vip1 timeout=6
   Operations: monitor interval=10 timeout=60 (vip_ping-monitor-interval-10)
               start interval=0s timeout=60 (vip_ping-start-interval-0s)
               stop interval=0s timeout=20 (vip_ping-stop-interval-0s)

Stonith Devices:
 Resource: ipmifence1 (class=stonith type=fence_ipmilan)
  Attributes: auth=password ipaddr=200.200.20.1 ipport=631 lanplus=1 login=admin passwd=growin pcmk_host_list=c77_ha01.hb
  Operations: monitor interval=60s (ipmifence1-monitor-interval-60s)
 Resource: ipmifence2 (class=stonith type=fence_ipmilan)
  Attributes: auth=password ipaddr=200.200.20.1 ipport=632 lanplus=1 login=admin passwd=growin pcmk_host_list=c77_ha02.hb
  Operations: monitor interval=60s (ipmifence2-monitor-interval-60s)
Fencing Levels:

Location Constraints:
  Resource: test_svc
    Enabled on: c77_ha01.hb (score:200) (id:location-test_svc-c77_ha01.hb-200)
    Enabled on: c77_ha02.hb (score:0) (id:location-test_svc-c77_ha02.hb-0)
  Resource: vip
    Constraint: location-vip
      Rule: boolean-op=or score=-INFINITY  (id:location-vip-rule)
        Expression: vip1 lt 1  (id:location-vip-rule-expr)
        Expression: not_defined vip1  (id:location-vip-rule-expr-1)
Ordering Constraints:
Colocation Constraints:
Ticket Constraints:

Alerts:
 No alerts defined

Resources Defaults:
 failure-timeout=30s
 migration-threshold=1
 resource-stickiness=1000
Operations Defaults:
 No defaults set

Cluster Properties:
 cluster-infrastructure: corosync
 cluster-name: ha_cluster
 dc-version: 1.1.20-5.el7-3c4c782f70
 have-watchdog: false
 stonith-enabled: true
 stonith-timeout: 30s

Quorum:
  Options:

 

 

 

 

Pacemaker Constraint 삭제

  • 기존 constraint 설정

 

# pcs constraint show --full
Location Constraints:
  Resource: test_svc
    Enabled on: c77_ha01.hb (score:200) (id:location-test_svc-c77_ha01.hb-200)
    Enabled on: c77_ha02.hb (score:0) (id:location-test_svc-c77_ha02.hb-0)
  Resource: vip
    Constraint: location-vip
      Rule: boolean-op=or score=-INFINITY  (id:location-vip-rule)
        Expression: vip1 lt 1  (id:location-vip-rule-expr)
        Expression: not_defined vip1  (id:location-vip-rule-expr-1)
Ordering Constraints:
Colocation Constraints:
Ticket Constraints:

 

  • constraint 삭제
- constraint 값 삭제
# pcs constraint remove location-test_svc-c77_ha02.hb-0


- 확인
# pcs constraint show --full
Location Constraints:
  Resource: test_svc
    Enabled on: c77_ha01.hb (score:200) (id:location-test_svc-c77_ha01.hb-200)
  Resource: vip
    Constraint: location-vip
      Rule: boolean-op=or score=-INFINITY  (id:location-vip-rule)
        Expression: vip1 lt 1  (id:location-vip-rule-expr)
        Expression: not_defined vip1  (id:location-vip-rule-expr-1)
Ordering Constraints:
Colocation Constraints:
Ticket Constraints:

 

contraint 삭제는 pcs constraint show --full 명령어를 통해 보여지는 id  값을 삭제하면 됩니다. 리소스 삭제와 다르게 id 값을 삭제하는 이유는 해당 제약 조건을 더 상세하게 나눌 경우 더 세밀하게 삭제를 하기 위함입니다. 

 

 

 

 

Location Constraint를 추가 해봤습니다. 제약 조건의 경우 너무 다양한 조건을 걸 수 있으며, 특정 리소스의 위치에 따라 리소스의 위치가 정하게 될 수도 있으며 순서 제어도 가능합니다. 이번에 알아본 위치 제약 조건을 사용하면 특정 리소스의 초기 위치를 설정 할 수 있습니다.  

 

 

 

이전 글 보기

[LINUX] Pacemaker Cluster (CentOS7, KVM, pacemaker) - 3

 

[LINUX] Pacemaker Cluster (CentOS7, KVM, pacemaker) - 3

Pacemaker 구성 3 목차 Pacemaker Resource Pacemaker 클러스터를 사용하는 목적은 이중화에 있습니다. HA, Loadbalance 등의 목적으로 등록된 리소스(서비스) 를 목적에 맞게 고가용성으로 사용하는 것을 목적

handari.tistory.com

 

Ref.

https://access.redhat.com/documentation/ko-kr/red_hat_enterprise_linux/8/html/configuring_and_managing_high_availability_clusters/assembly_determining-which-node-a-resource-runs-on-configuring-and-managing-high-availability-clusters

https://grooveyou.tistory.com/56

 

반응형
TOP