zoukankan      html  css  js  c++  java
  • keepalived脑裂问题查找

    在自己环境做keepalived+redis实验时,当重启了备用redies机器后,发现两台redies主机都拿到了VIP

    [plain] view plain copy
     
    1. [root@redis2 ~]# ip addr list  
    2. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN   
    3.     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
    4.     inet 127.0.0.1/8 scope host lo  
    5.     inet6 ::1/128 scope host   
    6.        valid_lft forever preferred_lft forever  
    7. 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000  
    8.     link/ether 52:54:00:72:6a:7c brd ff:ff:ff:ff:ff:ff  
    9.     inet 192.168.122.54/24 brd 192.168.122.255 scope global eth0  
    10.     inet 192.168.122.50/32 scope global eth0  
    11.     inet6 fe80::5054:ff:fe72:6a7c/64 scope link   
    12.        valid_lft forever preferred_lft forever  
    [plain] view plain copy
     
    1. [root@localhost ~]# ip addr list  
    2. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN   
    3.     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
    4.     inet 127.0.0.1/8 scope host lo  
    5.     inet6 ::1/128 scope host   
    6.        valid_lft forever preferred_lft forever  
    7. 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000  
    8.     link/ether 52:54:00:85:7b:a9 brd ff:ff:ff:ff:ff:ff  
    9.     inet 192.168.122.96/24 brd 192.168.122.255 scope global eth0  
    10.     inet 192.168.122.50/32 scope global eth0  
    11.     inet6 fe80::5054:ff:fe85:7ba9/64 scope link   
    12.        valid_lft forever preferred_lft forever  



    也就是出现了keepalived的脑裂现象,检查了两台主机的网络连通状态,发现网络是好的。然后在备机上抓包

    [html] view plain copy
     
    1. [root@localhost ~]#  tcpdump -i eth0|grep VRRP  
    2. tcpdump: verbose output suppressed, use -v or -vv for full protocol decode  
    3. listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes  
    4. 15:51:17.146322 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    5. 15:51:17.146577 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    6. 15:51:17.146972 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    7. 15:51:18.147136 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    8. 15:51:18.147576 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    9. 15:51:25.151399 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    10. 15:51:25.151942 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    11. 15:51:26.151703 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    12. 15:51:26.152623 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    13. 15:51:27.152456 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    14. 15:51:27.153261 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    15. 15:51:28.152955 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    16. 15:51:28.153461 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    17. 15:51:29.153766 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    18. 15:51:29.155652 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    19. 15:51:30.154275 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    20. 15:51:30.154587 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    21. 15:51:31.155042 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    22. 15:51:31.155428 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    23. 15:51:32.155539 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    24. 15:51:32.155986 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    25. 15:51:33.156357 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    26. 15:51:33.156979 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  
    27. 15:51:34.156801 IP 192.168.122.96 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 50, authtype simple, intvl 1s, length 20  
    28. 15:51:34.156989 IP 192.168.122.54 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 160, authtype simple, intvl 1s, length 20  

    备机能接收到master发过来的VRRP广播,那为什么还会有脑裂现象?发现重启后iptables还开着,检查了防火墙配置

    [plain] view plain copy
     
    1. root@localhost ~]# iptables -S  
    2. -P INPUT ACCEPT  
    3. -P FORWARD ACCEPT  
    4. -P OUTPUT ACCEPT  
    5. -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT   
    6. -A INPUT -p icmp -j ACCEPT   
    7. -A INPUT -i lo -j ACCEPT   
    8. -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT   
    9. -A INPUT -j REJECT --reject-with icmp-host-prohibited   
    10. -A FORWARD -j REJECT --reject-with icmp-host-prohibited   


    发现系统不接收VRRP协议,于是修改iptables

    [plain] view plain copy
     
    1. [root@localhost ~]# iptables -I INPUT 4 -p vrrp -j ACCEPT  
    [plain] view plain copy
     
    1. [root@localhost ~]# iptables -S  
    2. -P INPUT ACCEPT  
    3. -P FORWARD ACCEPT  
    4. -P OUTPUT ACCEPT  
    5. -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT   
    6. -A INPUT -p icmp -j ACCEPT   
    7. -A INPUT -i lo -j ACCEPT   
    8. -A INPUT -p vrrp -j ACCEPT   
    9. -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT   
    10. -A INPUT -j REJECT --reject-with icmp-host-prohibited   
    11. -A FORWARD -j REJECT --reject-with icmp-host-prohibited   
    [plain] view plain copy
     
    1. [root@localhost ~]# ip addr list  
    2. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN   
    3.     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
    4.     inet 127.0.0.1/8 scope host lo  
    5.     inet6 ::1/128 scope host   
    6.        valid_lft forever preferred_lft forever  
    7. 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000  
    8.     link/ether 52:54:00:85:7b:a9 brd ff:ff:ff:ff:ff:ff  
    9.     inet 192.168.122.96/24 brd 192.168.122.255 scope global eth0  
    10.     inet6 fe80::5054:ff:fe85:7ba9/64 scope link   
    11.        valid_lft forever preferred_lft forever  

    发现VIP没了。虽然问题解决了,但为什么备机明明能抓到master发来的VRRP广播包,但却无法改变自身状态呢?只能说明网卡接收到数据包是在iptables处理数据包之前发生的事情。

  • 相关阅读:
    python模拟shell
    10.LIKE 操作符
    9.TOP 子句--mysql limit
    8.INSERT INTO 语句 UPDATE 语句
    7.ORDER BY 子句
    6.AND & OR 运算符
    5.WHERE 子句
    4.SELECT DISTINCT 语句
    3.SELECT 语句
    2.sql分类
  • 原文地址:https://www.cnblogs.com/felixzh/p/8690568.html
Copyright © 2011-2022 走看看