keepalived腦裂問題查找

在本身環境作keepalived+redis實驗時,當重啓了備用redies機器後,發現兩臺redies主機都拿到了VIPhtml

 

[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的腦裂現象,檢查了兩臺主機的網絡連通狀態,發現網絡是好的。而後在備機上抓包redis

 

[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協議,因而修改iptablestcp

 

[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處理數據包以前發生的事情。oop

相關文章
相關標籤/搜索