안녕하세요
이번시간에는 저번에 이어 "RHEL9.6 에서 High Availability 구성 하기 - part 2 : Cluster 구성 및 리소스 구성" 에 대해
알아보겠습니다.
제가 실제로 구성해보고 테스트 해본것입니다~
지난주에 패키지 설치까지 완료했으니 이제 클러스터 구성을 해보겠습니다.
------------------------------
1. Host 파일 수정
------------------------------
> 1번,2번 서버 모두 동일하게 설정
# cat /etc/hosts
### VIP
192.168.122.93 mysql_cluster
### Service IP
192.168.122.91 rhel96ha01
192.168.122.92 rhel96ha02
### Heartbeat IP
100.100.100.91 rhel96ha01_hb
100.100.100.92 rhel96ha02_hb
------------------------------
2. Service 설치 - mysqld
------------------------------
yum install mysql-server
- 서비스를 mysqld로 설정 하였습니다.
. /data/ 디렉토에 mysql 데이터를 가져다놓고, share 볼륨으로 만들었습니다.
/dev/mysql_data/lv_data 10G 285M 9.7G 3% /data
==> 이 볼륨 생성은 하단에 HALVM 생성을 참고하세요
# cat /etc/my.cnf.d/mysql-server.cnf
[mysqld]
datadir=/data/mysql <<<<<--- 수정부분
#datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
pid-file=/run/mysqld/mysqld.pid
------------------------------
3. Cluster 구성
------------------------------
1) pacemaker 실행 및 자동실행 ( node1, node2)
systemctl start pcsd
systemctl enable pcsd
2) hacluster 패스워드 설정 ( node1, node2)
echo redhat | passwd --stdin hacluster
3) pcs 명령을 실행할 노드의 클러스터에 있는 각 노드에 대해 사용자 hacluster 를 인증 (node1)
# pcs host auth rhel96ha01 rhel96ha02 -u hacluster -p redhat
4) test_cluster 라는 클러스터를 생성
# pcs cluster setup --start test_cluster rhel96ha01 rhel96ha02 totem token=10000 join=100
> 클러스터 생성 확인
# pcs status
Cluster name: test_cluster
WARNINGS:
No stonith devices and stonith-enabled is not false
Cluster Summary:
* Stack: unknown (Pacemaker is running)
* Current DC: NONE
* Last updated: Tue Jul 22 22:11:13 2025 on rhel96ha01_hb
* Last change: Tue Jul 22 22:11:03 2025 by hacluster via hacluster on rhel96ha01_hb
* 2 nodes configured
* 0 resource instances configured
Node List:
* Node rhel96ha01_hb: UNCLEAN (offline)
* Node rhel96ha02_hb: UNCLEAN (offline)
Full List of Resources:
* No resources
Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/enabled
5) 클러스터 기본 환경설정 및 확인 ( node1)
pcs property set stonith-enabled=false
(세팅 모두 완료 후 ture 변경
pcs resource defaults update resource-stickiness=1000
pcs property set no-quorum-policy=stop
pcs resource defaults update migration-threshold=1
# pcs property show
# pcs property config
# pcs quorum status
6) HALVM 생성 (share 볼륨이 LVM 일때 )
>node1,node2
# cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf_orig
# vim /etc/lvm/lvm.cof
# system_id_source = "none"
====>수정 system_id_source = "uname"
>node1
# pvcreate /dev/sda1
# vgcreate --setautoactivation n mysql_data /dev/sda1
# lvcreate -l 100%FREE -n lv_data mysql_data
# mkfs.xfs /dev/mysql_data/lv_data
# vgs -o+systemid
# lvs
----------
>>> 만약 LVM 볼륨을 생성해놓은 상태에서 HA 볼륨으로 적용하려면
# vgchange --setautoactivation n <VG이름>
> 확인
# vgs -o +autoactivation
7) Cluster Resource 생성(node1)
> VIP 생성
pcs resource create vip ocf:heartbeat:IPaddr2 ip=192.168.122.93 cidr_netmask=24 nic=enp1s0 op monitor interval=30s timeout=45s --group test_cluster
> HALVM 생성
pcs resource create mysql_data LVM-activate vgname=mysql_data vg_access_mode=system_id --group test_cluster
> Filesystem 생성
pcs resource create fs-mysql ocf:heartbeat:Filesystem device=/dev/mysql_data/lv_data directory=/data fstype=xfs op monitor interval=45 timeout=60 OCF_CHECK_LEVEL=20 --group test_cluster
# ip addr
# df -hP
# pcs status
> APP 스크립트 작성
- start, stop 형식으로 등록
# vim /etc/init.d/mysql
----------------------------------------------------------------------------------------------------
#!/bin/sh
case $1 in
start)
echo " ########## start APP ########## "
su - root -c "systemctl start mysqld"
;;
stop)
echo " ########## stop APP ########## "
su - root -c "systemctl stop mysqld"
;;
status)
if [ ` ps -ef | grep mysqld | grep -v grep | wc -l ` -ge 1 ];then
exit 0
else
exit 3
fi
;;
*)
echo "please check mysql"
esac
----------------------------------------------------------------------------------------------------
> APP 등록
pcs resource create mysql-APP lsb:mysql op monitor interval=30s --group test_cluster
8) 다음 명령은 지정된 노드 또는 노드를 선호하는 리소스에 대한 위치 제한 조건을 생성
pcs constraint location test_cluster prefers rhel96ha01=1000
pcs constraint location test_cluster prefers rhel96ha02=500
9) Fence Device 설정(vbmc 설정시)
> Host 서버에서
# vbmc list
+----------------+---------+---------+------+
| Domain name | Status | Address | Port |
+----------------+---------+---------+------+
| RHEL96-ha01 | running | :: | 8001 |
| RHEL96-ha02 | running | :: | 8002 |
node1, node2번에서 테스트
> Connetc test
fence_ipmilan -A password -P -a 192.168.122.1 -u 8002 -l admin -p redhat -o status
fence_ipmilan -A password -P -a 192.168.122.1 -u 8001 -l admin -p redhat -o status
# 1번 노드
pcs stonith create ipmi1 fence_ipmilan pcmk_host_list="rhel96ha01" ip=192.168.122.1 delay=15 ipport="8001" username=admin password=redhat lanplus=on auth=password op monitor interval=1800s
# 2번 노드
pcs stonith create ipmi2 fence_ipmilan pcmk_host_list="rhel96ha02" ip=192.168.122.1 ipport="8002" username=admin password=redhat lanplus=on auth=password op monitor interval=1800s
기타 설명
> 리소스 등록 시 fence device 작동 방지
# pcs property set stonith-enabled=false
> 리소스 모두 등록이 완료되면 다시 true로 설정
# pcs property set stonith-enabled=true
- 장애 처리 후 리소스 이동 방지 설정
# pcs resource defaults update resource-stickiness=1000
이렇게 구성이 완료됩니다.
상세 내용 보겠습니다.
# pcs status
Cluster name: test_cluster
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: rhel96ha02 (version 2.1.9-1.el9-49aab9983) - partition with quorum
* Last updated: Sat Aug 2 19:47:47 2025 on rhel96ha01
* Last change: Wed Jul 23 23:09:46 2025 by hacluster via hacluster on rhel96ha02
* 2 nodes configured
* 6 resource instances configured
Node List:
* Online: [ rhel96ha01 rhel96ha02 ]
Full List of Resources:
* Resource Group: test_cluster:
* vip (ocf:heartbeat:IPaddr2): Started rhel96ha01
* mysql_data (ocf:heartbeat:LVM-activate): Started rhel96ha01
* fs-mysql (ocf:heartbeat:Filesystem): Started rhel96ha01
* mysql-APP (lsb:mysql): Started rhel96ha01
* ipmi1 (stonith:fence_ipmilan): Started rhel96ha02
* ipmi2 (stonith:fence_ipmilan): Started rhel96ha02
Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/enabled
# pcs property
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=test_cluster
dc-version=2.1.9-1.el9-49aab9983
have-watchdog=false
last-lrm-refresh=1753277034
no-quorum-policy=stop
stonith-enabled=true
# pcs stonith config
Resource: ipmi1 (class=stonith type=fence_ipmilan)
Attributes: ipmi1-instance_attributes
auth=password
delay=15
ip=192.168.122.1
ipport=8001
lanplus=on
password=redhat
pcmk_host_list=rhel96ha01
username=admin
Operations:
monitor: ipmi1-monitor-interval-1800s
interval=1800s
Resource: ipmi2 (class=stonith type=fence_ipmilan)
Attributes: ipmi2-instance_attributes
auth=password
ip=192.168.122.1
ipport=8002
lanplus=on
password=redhat
pcmk_host_list=rhel96ha02
username=admin
Operations:
monitor: ipmi2-monitor-interval-1800s
interval=1800s
# pcs resource defaults
Meta Attrs: build-resource-defaults
migration-threshold=1
resource-stickiness=1000
이렇게 RHEL9.6버전에서 HA 구성 사례를 공유했습니다.
감사합니다.~