Keepalived无法绑定VIP故障排查经历

一 故障描述
我在台湾合作方给定的两台虚拟机上部署HAProxy+Keepalived负载均衡高可用方案。在配置完Keepalived后,重新启动Keepalived,Keepalived没有绑定VIP。

Keepalived执行程序路径为/data/app_platform/keepalived/sbin/keepalived
配置文件路径为/data/app_platform/keepalived/conf/keepalived.conf 
Keepalived的启动脚本为/etc/init.d/keepalived

keepalived.conf的内容
LB1 Master
! Configuration File for keepalived
 
global_defs {
  notification_email {
    admin@example.com
  }
  notification_email_from lb1@example.com
  smtp_server 127.0.0.1
  smtp_connect_timeout 30
  router_id LB1_MASTER
}
 
 vrrp_script chk_haproxy {
        script "killall -0 haproxy"
        interval 2
    weight 2
    }
 
 
 
 
vrrp_instance VI_1 {
    state MASTER
    interface eth1
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
 
    10.1.1.200/24      brd 10.1.1.255      dev eth1 label eth1:vip
 
    }
 
    track_script {
        chk_haproxy
                }
}

重新启动Keepalived查看日志
Mar  3 18:09:00 cv00300005248-1 Keepalived[20138]: Stopping Keepalived v1.2.15 (02/28,2015)
Mar  3 18:09:00 cv00300005248-1 Keepalived[20259]: Starting Keepalived v1.2.15 (02/28,2015)
Mar  3 18:09:00 cv00300005248-1 Keepalived[20260]: Starting Healthcheck child process, pid=20261
Mar  3 18:09:00 cv00300005248-1 Keepalived[20260]: Starting VRRP child process, pid=20262
Mar  3 18:09:00 cv00300005248-1 Keepalived_vrrp[20262]: Registering Kernel netlink reflector
Mar  3 18:09:00 cv00300005248-1 Keepalived_vrrp[20262]: Registering Kernel netlink command channel
Mar  3 18:09:00 cv00300005248-1 Keepalived_vrrp[20262]: Registering gratuitous ARP shared channel
Mar  3 18:09:00 cv00300005248-1 Keepalived_healthcheckers[20261]: Registering Kernel netlink reflector
Mar  3 18:09:00 cv00300005248-1 Keepalived_healthcheckers[20261]: Registering Kernel netlink command channel
Mar  3 18:09:00 cv00300005248-1 Keepalived_healthcheckers[20261]: Configuration is using : 3924 Bytes
Mar  3 18:09:00 cv00300005248-1 Keepalived_healthcheckers[20261]: Using LinkWatch kernel netlink reflector...
Mar  3 18:09:00 cv00300005248-1 Keepalived_vrrp[20262]: Configuration is using : 55712 Bytes
Mar  3 18:09:00 cv00300005248-1 Keepalived_vrrp[20262]: Using LinkWatch kernel netlink reflector...
Mar  3 18:09:18 cv00300005248-1 kernel: __ratelimit: 1964 callbacks suppressed
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.
Mar  3 18:09:18 cv00300005248-1 kernel: Neighbour table overflow.

查看VIP绑定情况
$ ifconfig eth1:vip
eth1:vip  Link encap:Ethernet  HWaddr 00:16:3E:F2:37:6B 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:13

没有VIP绑定

二 排查过程

1)检查VIP的配置情况
向合作方确认提供的VIP的详细情况

IPADDR  10.1.1.200
NETMASK  255.255.255.0
GATEWAY  10.1.1.1
Brodcast  10.1.1.255
 
这里设置的是

10.1.1.200/24      brd 10.1.1.255      dev eth1 label eth1:vip

2)检查iptables和selinux的设置情况
$ sudo service iptables stop
$ sudo setenforce 0
setenforce: SELinux is disabled

如果非要开启iptables的话,需要作些设定

iptables -I INPUT -i eth1 -d 224.0.0.0/8 -j ACCEPT
service iptables save

keepalived使用224.0.0.18作为Master和Backup健康检查的通信IP

3)检查相关的内核参数
HAProxy+Keepalived架构需要注意的内核参数有:

# Controls IP packet forwarding
net.ipv4.ip_forward = 1
开启IP转发功能

net.ipv4.ip_nonlocal_bind = 1
开启允许绑定非本机的IP

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4ca5e2b8cc455144f696d659baf1e772.html