VM : Centos 8.2
Keepalived 2.15Keepalived v2.1.5
Maxscale 2.5.3
Maxscale 2.5.x 설치
사전 디펜던시 설치
dnf install libatomic
maxscale 설치
rpm -Uvh maxscale-2.5.3-2.rhel.8.x86_64.rpm
keepalived 다운로드
wget https://www.keepalived.org/software/keepalived-2.1.5.tar.gz
사전 디펜던시 설치
dnf install iptables-devel
dnf install libnl3-devel
rpm -Uvh ipset-devel-7.1-1.el8.x86_64.rpm libmnl-devel-1.0.4-6.el8.x86_64.rpm
압축해제
tar zxvf keepalived-2.1.5.tar.gz
환경구성 설치전 테스트
./configure
소스컴파일
make
설치
make install
keepalived.conf 저장 디렉터리 생성
mkdir /etc/keepalived
keepalived.conf 설정
vi /etc/keepalived/keepalived.conf
global_defs {
router_id maxa <-maxa 는 호스트네임으로 했으나, 변경해도 상관없음
}
vrrp_script chk_myscript {
script "/etc/keepalived/scripts/is_maxscale_running.sh"
interval 2 # check every 2 seconds
fall 2 # require 2 failures for KO
rise 2 # require 2 successes for OK
}
vrrp_instance VI_1 {
state MASTER
interface ens3
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass mypass
}
virtual_ipaddress {
192.168.1.160
}
track_script {
chk_myscript
}
notify /etc/keepalived/scripts/notify_script.sh
}
스크립트 저장디렉터리 생성
mkdir /etc/keepalived/scripts
is_maxscale_running.sh 스크립트 작성
vi /etc/keepalived/scripts/is_maxscale_running.sh
#!/bin/bash
fileName="/etc/keepalived/scripts/maxadmin_output.txt"
rm $fileName
timeout 2s maxctrl list servers > $fileName
to_result=$?
if [ $to_result -ge 1 ]
then
echo Timed out or error, timeout returned $to_result
exit 3
else
echo MaxAdmin success, rval is $to_result
echo Checking maxadmin output sanity
grep1=$(grep galera1_dr $fileName)
grep2=$(grep galera2_dr $fileName)
grep3=$(grep galera3_dr $fileName)
if [ "$grep1" ] && [ "$grep2" ] && [ "$grep3" ]
then
echo All is fine
exit 0
else
echo Something is wrong
exit 3
fi
fi
notify_script.sh 스크립트작성
vi /etc/keepalived/scripts/notify_script.sh
#!/bin/bash
TYPE=$1
NAME=$2
STATE=$3
OUTFILE=/etc/keepalived/scripts/maxscale_state.txt
case $STATE in
"MASTER") echo "Setting this MaxScale node to active mode" > $OUTFILE
maxctrl alter maxscale passive false
exit 0
;;
"BACKUP") echo "Setting this MaxScale node to passive mode" > $OUTFILE
maxctrl alter maxscale passive true
exit 0
;;
"FAULT") echo "MaxScale failed the status check." > $OUTFILE
maxctrl alter maxscale passive true
exit 0
;;
*) echo "Unknown state" > $OUTFILE
exit 1
;;
esac
방화벽설정
firewall-cmd --add-rich-rule='rule protocol value="vrrp" accept' --permanent
방화벽적용
firewall-cmd --reload
maxscale 시작
systemctl start maxscale
keepalived 시작
systemctl start keepalived
'컴이야기 > MariaDB' 카테고리의 다른 글
10.5 에서 추가된 시스템 변수 (0) | 2020.07.20 |
---|---|
MariaDB installing in minimal install RHEL8 (0) | 2020.07.20 |
Maxscale (0) | 2020.06.30 |
CRUD (0) | 2020.06.12 |
Using Galera Replication to Create Geo-distributed Clusters (0) | 2020.06.12 |