DRBD + Pacemaker + SSHFS on CentOS 7 #2 – Pacemaker
Pacemaker 구성
Master / Slave 모두 적용
1. 호스트네임 추가
:vi /etc/hosts
10.19.10.196 10-19-10-196 10.19.10.197 10-19-10-197
2. pacemaker 설치
[root@10-19-10-196 /]# yum install -y pacemaker corosync pcs
3. pacemaker 인증을 위한 비밀번호 설정
// hacluster 계정은 pacemaker 설치시 자동생성되므로 해당 계정을 이용한다.
[root@10-19-10-196 /]# passwd hacluster
4. pacemaker 서비스 실행 및 등록
[root@10-19-10-196 /]# systemctl start pcsd [root@10-19-10-196 /]# systemctl enable pcsd [root@10-19-10-196 /]# systemctl enable corosync [root@10-19-10-196 /]# systemctl enable pacemaker
Master만 적용
1. pacemaker 인증 확인
// 위에서 생성한 비밀번호 입력
[root@10-19-10-196 /]# pcs cluster auth 10-19-10-196 10-19-10-197
2. pacemaker 클러스터 구성
[root@10-19-10-196 /]# pcs cluster setup --start --name storage_cluster 10-19-10-196 10-19-10-197 --transport udpu [root@10-19-10-196 /]# pcs property set stonith-enabled=false [root@10-19-10-196 /]# pcs property set no-quorum-policy=ignore [root@10-19-10-196 /]# pcs property set default-resource-stickiness=100
3. pacemaker 리소스 등록
// cib 라는 raw xml에 설정을 저장 한 뒤 cib-push 명령어로 업데이트 해야 적용된다.
// sshfs_config 는 임의로 정한 설정이름이며, 아래 구성은 추가/수정/삭제 할 수 있다.
[root@10-19-10-196 /]# pcs cluster cib sshfs_config [root@10-19-10-196 /]# pcs -f sshfs_config resource create Storage_VIP ocf:heartbeat:IPaddr2 ip=10.19.10.195 cidr_netmask=32 nic=eth0 op monitor interval="5" timeout="10" [root@10-19-10-196 /]# pcs -f sshfs_config resource create Storage_Resource ocf:linbit:drbd drbd_resource=file_storage op monitor timeout="30" interval="5" role="Master" op monitor timeout="30" interval="6" role="Slave" [root@10-19-10-196 /]# pcs -f sshfs_config resource master DataSync Storage_Resource master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true [root@10-19-10-196 /]# pcs -f sshfs_config resource create Filesystem ocf:heartbeat:Filesystem device="/dev/drbd0" directory="/data" fstype="xfs" options="noatime" [root@10-19-10-196 /]# pcs -f sshfs_config resource group add HA-GROUP Storage_VIP Filesystem [root@10-19-10-196 /]# pcs -f sshfs_config constraint colocation add HA-GROUP DataSync INFINITY with-rsc-role=Master [root@10-19-10-196 /]# pcs -f sshfs_config constraint order promote DataSync then start Filesystem [root@10-19-10-196 /]# pcs cluster cib-push sshfs_config
4. pacemaker 클러스터 시작
[root@10-19-10-196 /]# pcs cluster start --all
5. pacemaker 클러스터 확인
[root@10-19-10-196 /]# pcs cluster status Cluster Status: Stack: corosync Current DC: 10-19-10-196 (version 1.1.20-5.el7_7.2-3c4c782f70) - partition with quorum Last updated: Mon Mar 30 12:05:03 2020 Last change: Fri Mar 20 17:13:58 2020 by root via cibadmin on 10-19-10-196 2 nodes configured 4 resources configured PCSD Status: 10-19-10-197: Online 10-19-10-196: Online
[root@10-19-10-196 /]# pcs status Cluster name: storage_cluster Stack: corosync Current DC: 10-19-10-196 (version 1.1.20-5.el7_7.2-3c4c782f70) - partition with quorum Last updated: Mon Mar 30 12:05:07 2020 Last change: Fri Mar 20 17:13:58 2020 by root via cibadmin on 10-19-10-196 2 nodes configured 4 resources configured Online: [ 10-19-10-196 10-19-10-197 ] Full list of resources: Master/Slave Set: DataSync [Storage_Resource] Masters: [ 10-19-10-196 ] Slaves: [ 10-19-10-197 ] Resource Group: HA-GROUP Storage_VIP (ocf::heartbeat:IPaddr2): Started 10-19-10-196 Filesystem (ocf::heartbeat:Filesystem): Started 10-19-10-196 Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled
// pacemaker 관련 로그 경로
/var/log/pacemaker.log
/var/log/pcsd/pcsd.log
/var/log/cluster/corosync.log
장애조치
// 마스터 서버가 장애가 나면 슬레이브 서버가 마스터로 승격이 되고 VIP가 이동된다.
// 슬레이브 서버가 장애가 나면 마스터만 동작한다.
// pcs status 커맨드를 이용하여 확인하면 DC는 master 서버로 나오고, 장애서버는 offline으로 나온다.
// 장애조치가 완료되면 해당 서버를 다시 클러스터에 등록시켜주어야 한다.
1. drbdadm up $resouce_name 또는 drbdadm up all 커맨드를 이용하여 drbd 상태를 up 시켜 준다.
2. master에서 pcs cluster status 커맨드를 이용하여 master / slave 모두 online 인지 확인한다.
3. online 상태가 확인되었다면 master에서 pcs cluster start –all 커맨드를 이용하여 클러스터를 재시작 한다.
4. pcs status 커맨드로 DC, VIP등을 확인하고 등록된 노드들이 모두 online 인지 확인한다.