Keepalived两节点出现双VIP情况及解决方法【原创】

1、故障现象

俩台服务器keepalived的vip在俩台服务器同时出现

A:10.70.12.72

B:10.70.12.73

Keepalived两节点出现双VIP情况及解决方法【原创】_第1张图片

Keepalived两节点出现双VIP情况及解决方法【原创】_第2张图片

 

2、问题分析

1)、先分析那台服务器在提供服务

A:10.70.12.72

Keepalived两节点出现双VIP情况及解决方法【原创】_第3张图片

B:10.70.12.73

Keepalived两节点出现双VIP情况及解决方法【原创】_第4张图片

可以看到是B机器72在对外提供lvs转发服务

2)、查看俩台服务器的keepalived日志

Keepalived两节点出现双VIP情况及解决方法【原创】_第5张图片

 发现俩台的日志都是判断自己是master状态,证明俩者之间没有通过vrrp通信,来得到对方的状态信息

查看俩台服务器防火墙,发现B的防火墙没有关闭。关闭后发现keepalived日志报错如下

Nov  8 09:32:49 Cent65CTS1037061 Keepalived_vrrp: bogus VRRP packet received on eth0 !!!
Nov  8 09:32:49 Cent65CTS1037061 Keepalived_vrrp: VRRP_Instance(VI_1) Dropping received VRRP packet...
Nov  8 09:32:50 Cent65CTS1037061 Keepalived_vrrp: ip address associated with VRID not present in received packet : 10.70.12.20
Nov  8 09:32:50 Cent65CTS1037061 Keepalived_vrrp: one or more VIP associated with VRID mismatch actual MASTER advert

百度一下发现可能是VRID和别的机器相同导致的,进一步验证一下,如下

在A服务器上抓包,发现好多VRID是51的IP在对vrrp发包。问题找到了。

[root@Cent65CTS1037051 ~]# tcpdump -i eth0 vrrp -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
09:32:24.556954 IP 10.70.12.211 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
09:32:24.586937 IP 10.70.12.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 1, authtype simple, intvl 1s, length 20
09:32:24.637709 IP 10.70.12.237 > 224.0.0.18: VRRPv2, Advertisement, vrid 53, prio 150, authtype simple, intvl 1s, length 20
09:32:24.639037 IP 10.70.12.117 > 224.0.0.18: VRRPv2, Advertisement, vrid 14, prio 100, authtype simple, intvl 1s, length 20
09:32:24.641544 IP 10.70.12.202 > 224.0.0.18: VRRPv2, Advertisement, vrid 31, prio 102, authtype simple, intvl 1s, length 20
09:32:25.259017 IP 10.70.12.89 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 1, authtype simple, intvl 1s, length 20
09:32:25.557094 IP 10.70.12.211 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20
09:32:25.588104 IP 10.70.12.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 51, prio 1, authtype simple, intvl 1s, length 20  

第一,为B防火墙没有关闭,导致A和B之间不能通信,都判断自己为master绑定vip

第二,keepalived的vrid与别人的相同,并且密码还都是一样的导致,keepalived报错

 

3、解决方法

第一、服务器都要关闭防火墙,不关闭就要增加vrrp策略

 -A INPUT -p vrrp -j ACCEPT

 第二、keepalived的vrid设置的不同,且最后修改密码

    virtual_router_id 82
    authentication {
        auth_type PASS
        auth_pass 2111
     }

 

参考

Keepalived两节点出现双VIP情况及解决方法_服务器应用_Linux公社-Linux系统门户网站 https://www.linuxidc.com/Linux/2017-10/147537.htm

 

你可能感兴趣的:(Keepalived两节点出现双VIP情况及解决方法【原创】)