본문 바로가기

지식창고/Linux

[리눅스/Linux] Pacemaker 이중화 설치 방법(Active-Standby 구성)

반응형
OS Version
  • CentOS 7.7.1908
클러스터 세팅 방법

1. Pacemaker 패키지 설치(Active/Standby)

# yum install -y pacemaker corosync pcs psmisc policycoreutils-python

2. hosts 파일 수정

# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 SVR-01 ::1        
localhost localhost.localdomain localhost6 localhost6.localdomain6
#Active
192.168.1.101 node1
#Standby
192.168.1.102 node2

3. Pacemaker 서비스 시작 및 등록(Active/Standby)

systemctl start pcsd.service
systemctl enable pcsd.service

4. 클러스터 계정 설정

# passwd hacluster
[root@SVR-01 ~]# passwd hacluster
Changing password for user hacluster.
New password:
Retype new password:
passwd: all authentication tokens updated successfully

5. hacluster 계정을 각 노드에 인증(Active/Standby)

  • 4번 항목에서 입력했던 패스워드를 입력
# pcs cluster auth [hostname1] [hostname2]
[root@SVR-01 ~]# pcs cluster auth node1 node2
Username: hacluster
Password:
node1: Authorized
node2: Authorized
  • Error: Uable to communicate with node2와 같은 에러 발생 시 클러스터에서 사용하는 포트 오픈(방화벽 등)을 확인해야 합니다.
  • 클러스터 활성화 필요 포트 리스트
포트 용도
TCP 2224 모든 노트에 필요(pcsd 웹 UI와 노드 간 통신에 필요)
TCP 3121 클러스터에 Pacemaker 원격 노드가 있는 경우 모든 노드에 필요
TCP 5403  
UDP 5404 corosync 멀티 캐스트 UDP에 대해 구성된 경우 corosync 노드에 필요
UDP 5405 모든 corosync 노드에 필요
TCP 21064 클러스터에 DLM이 필요한 리소스가 포함된 경우 모든 노드에 필요
TCP 9929
UDP 9929
부스 티켓 관리자를 사용하여 다중 사이트 클러스터를 설정하는 경우 모든 클러스터 노드 및 부스 중재자 노드에서 동일한 노드의 연결에 대해 열어 있어야 함

6. 클러스터 생성(Active/Standby)

# psc cluster setup --name [cluster name] node1 node2
[root@SVR-01 ~]# pcs cluster setup --name sqisoft node1 node2

Destroying cluster on nodes: node1, node2...
node2: Stopping Cluster (pacemaker)...
node1: Stopping Cluster (pacemaker)...
node2: Successfully destroyed cluster
node1: Successfully destroyed cluster

Sending 'pacemaker_remote authkey' to 'node1', 'node2'
node1: successful distribution of the file 'pacemaker_remote authkey'
node2: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
node1: Succeeded
node2: Succeeded

Synchronizing pcsd certificates on nodes node1, node2...
node1: Success
node2: Success
Restarting pcsd on the nodes in order to reload the certificates...
node1: Success
node2: Success

7. 클러스터 기동(Active)

# pcs cluster start --all
[root@SVR-01 ~]# pcs cluster start --all
node1: Starting Cluster (corosync)...
node2: Starting Cluster (corosync)...
node1: Starting Cluster (pacemaker)...
node2: Starting Cluster (pacemaker)...

8. 클러스터 status 확인(Active/Standby)

# pcs status

9. STONITH 비활성 및 Quorum 무시설정(Active)

  • STONITH 설정은 데이터의 무결성을 확보하기 위해 기본적으로 활성화되어 있는 상태로 비활성화가 필요하다.
# pcs property set stonith-enabled=false

# pcs property set no-quorum-policy=ignore

 

가상 IP(vip) 세팅하기

1. vip 세팅(Active)

# pcs resource create Cluster_VIP ocf:heartbeat:IPaddr2 ip=192.168.1.100 cidr_netmask=24 op monitor interval=20s

2. vip 확인(Active/Standby)

  • ip addr 명령어 입력 시 지정한 vip 확인되면 된다.
# pcs status

# ip addr

 

Fail-over 테스트

1. Active 서버 클러스터 중지 후 vip Standby 서버로 전환 확인

# psc cluster stop node1

 

2. 가중치 설정하기

  • Pacemaker 이중화는 가중치를 변경해서 vip를 이동시킬 수 있다.
  • 양 서버 간 가중치가 같다면 fail-over 상황에서 vip가 이동하지 않는다.
  • 가중치를 변경할 시 가중치가 더 높은쪽으로 vip가 이동한다.
  • 가중치 설정 명령어
# pcs constraint location Cluster_VIP prefers node1=100

# pcs constraint location Cluster_VIP prefers node2=50
  • 가중치 확인 명령어
# pcs constraint show
반응형