Souce Install keepalived on CentOS 7

구성 목표

HAProxy 서버를 두대 설치하여 KeepAlived를 이용하여 FailOver 구성
HAProxy Master IP : 172.19.10.106
HAProxy BACKUP IP : 172.19.10.107
VIP : 172.19.10.105
// 모든 설치과정은 Master/Backup 모두 동일하며, 설정파일 내용만 약간 다름
// HAProxy는 MASTER/BACKUP 서버 모두 사전 설치 되 있는 상태에서 진행

사전 설치 – HAProxy

 

설치

의존성 패키지 설치

[root@172-19-10-106 /]# yum install -y kernel-headers kernel-devel libnfnetlink-devel libnl-devel

 

keepalived 다운로드

[root@172-19-10-106 /]# cd /data/apps/dn
[root@172-19-10-106 dn]# wget http://www.keepalived.org/software/keepalived-2.0.11.tar.gz

 

압축해제

[root@172-19-10-106 dn]# tar xvzf keepalived-2.0.11.tar.gz

 

컴파일 및 설치

[root@172-19-10-106 dn]# cd keepalived-2.0.11
[root@172-19-10-106 keepalived-2.0.11]# ./configure --prefix=/data/apps/src/keepalived-2.0.11 --with-kernel-dir=/lib/modules/$(uname -r)/build
[root@172-19-10-106 keepalived-2.0.11]# make && make install

 

링크생성

[root@172-19-10-106 keepalived-2.0.11]# ln -s /data/apps/src/keepalived-2.0.11 /data/apps/ln/keepalived

 

sysconfig 설정 링크 및 편집

[root@172-19-10-106 keepalived-2.0.11]# ln -s /data/apps/ln/keepalived/etc/sysconfig/keepalived /etc/sysconfig/keepalived

: vi /etc/sysconfig/keepalived

# Options for keepalived. See `keepalived --help' output and keepalived(8) and
# keepalived.conf(5) man pages for a list of all options. Here are the most
# common ones :
#
# --vrrp               -P    Only run with VRRP subsystem.
# --check              -C    Only run with Health-checker subsystem.
# --dont-release-vrrp  -V    Dont remove VRRP VIPs & VROUTEs on daemon stop.
# --dont-release-ipvs  -I    Dont remove IPVS topology on daemon stop.
# --dump-conf          -d    Dump the configuration data.
# --log-detail         -D    Detailed log messages.
# --log-facility       -S    0-7 Set local syslog facility (default=LOG_DAEMON)
#

KEEPALIVED_OPTIONS="-D -S 3 -f /etc/keepalived/keepalived.conf"

 

keepalived 설정 링크 및 편집

[root@172-19-10-106 keepalived-2.0.11]# ln -s /data/apps/ln/keepalived/etc/keepalived /etc/keepalived

: vi /etc/keepalived/keepalived.conf

# KeepAlived MASTER 서버 config
global_defs {
    router_id umount_HAProxy01
}

vrrp_script chk_haproxy {
    script "/sbin/pidof haproxy"
    interval 5
    weight 2
}

vrrp_instance HAProxy {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 101
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass A3BB833DD44CEFEA384E48C5A55C0A35
    }
    unicast_peer {
        172.19.10.107
    }
    virtual_ipaddress {
        172.19.10.105
    }
    track_script {
        chk_haproxy
    }
}
# KeepAlived BACKUP 서버 config
global_defs {
    notification_email {
        fallboyz@umount.net
    }
    notification_email_from fallboyz@umount.net
    smtp_server localhost
    smtp_connect_timeout 30
    router_id umount_HAProxy02
}

vrrp_script chk_haproxy {
    script "/sbin/pidof haproxy"
    interval 5
    weight 2
}

vrrp_instance HAProxy {
    interface eth0
    state SLAVE
    virtual_router_id 51
    smtp_alert
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass A3BB833DD44CEFEA384E48C5A55C0A35
    }
    unicast_peer {
        172.19.10.106
    }
    virtual_ipaddress {
        172.19.10.105
    }
    track_script {
        chk_haproxy
    }
}

 

systemd 파일생성
: vi /etc/systemd/system/keepalived.service

[Unit]
Description=LVS and VRRP High Availability Monitor
After= network-online.target syslog.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/keepalived.pid
KillMode=process
EnvironmentFile=-/etc/sysconfig/keepalived
ExecStart=/data/apps/ln/keepalived/sbin/keepalived $KEEPALIVED_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

 

systemd 등록 및 실행

[root@172-19-10-106 keepalived-2.0.11]# systemctl enable keepalived
[root@172-19-10-106 keepalived-2.0.11]# systemctl start keepalived

You may also like...

Subscribe
Notify of
guest

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x