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处理数据包之前发生的事情。

    /sbin/service iptables save

  • 相关阅读:
    Android——继续深造——从安装Android Studio 2.0开始(详)
    PHP——安装wampserver丢失MSVCR110.dll
    Marza Gift for GDC 2016
    Retrieve OpenGL Context from Qt 5.5 on OSX
    Space Time Varying Color Palette
    Screen Space Depth Varying Glow based on Heat Diffusion
    Visualization of Detail Point Set by Local Algebraic Sphere Fitting
    Glass Dragon
    Jump Flood Algorithms for Centroidal Voronoi Tessellation
    京都之行
  • 原文地址:https://www.cnblogs.com/wangmo/p/7442535.html
Copyright © 2011-2022 走看看