加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

install keepalived on RedHat/CentOS to provide IP failover f

发布时间:2021-01-19 17:38:39 所属栏目:Linux 来源:网络整理
导读:副标题#e# table id="toc" class="toc" tr td div id="toctitle" Contents Keepalived provides a strong and robust health checking for LVS clusters. It implements a framework of health checking on multiple layers for server failover,and VRRPv2

Your main configuration directory is located at /usr/local/etc/keepalived and configuration file name is keepalived.conf. First,make backup of existing configuration:

# cd /usr/local/etc/keepalived
# cp keepalived.conf keepalived.conf.bak

Edit keepalived.conf as follows on lb0:

vrrp_instance VI_1 {
       interface eth0
       state MASTER
       virtual_router_id 51
       priority 101
       authentication {
           auth_type PASS
           auth_pass Add-Your-Password-Here
       }
       virtual_ipaddress {
               202.54.1.1/29 dev eth1
       }
}

Edit keepalived.conf as follows on lb1 (note priority set to 100 i.e. backup load balancer):

vrrp_instance VI_1 {
       interface eth0
       state MASTER
       virtual_router_id 51
       priority 100
       authentication {
           auth_type PASS
           auth_pass Add-Your-Password-Here
       }
       virtual_ipaddress {
               202.54.1.1/29 dev eth1
       }
}

Save and close the file. Finally start keepalived on both lb0 and lb1 as follows:

# /etc/init.d/keepalived start

/var/log/messages will keep track of VIP:

# tail -f /var/log/messages

Feb 21 04:06:15 lb0 Keepalived_vrrp: Netlink reflector reports IP 202.54.1.1 added
Feb 21 04:06:20 lb0 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 202.54.1.1

Verify that VIP assigned to eth1:

# ip addr show eth1

Sample outputs:

3: eth1:  mtu 1500 qdisc pfifo_fast qlen 10000
   link/ether 00:30:48:30:30:a3 brd ff:ff:ff:ff:ff:ff
   inet 202.54.1.11/29 brd 202.54.1.254 scope global eth1
   inet 202.54.1.1/29 scope global secondary eth1

ping failover test

Open UNIX / Linux / OS X desktop terminal and type the following command to ping to VIP:

# ping 202.54.1.1
Login to lb0 and halt the server or take down networking:
# halt

Within seconds VIP should move from lb0 to lb1 and you should not see any drops in ping. On lb1 you should get the following in /var/log/messages:

Feb 21 04:10:07 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) forcing a new MASTER election
Feb 21 04:10:08 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Feb 21 04:10:09 lb1 Keepalived_healthcheckers: Netlink reflector reports IP 202.54.1.1 added

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读