CentOS7下配置防火牆放過Keepalived


在配置好keepalived主從之后,發現主從都綁定了虛擬IP;這就是所謂的“腦裂問題”;

  • 於是開始查看主從keepalived的配置文件是否有誤,vrid是否一致;最后發現配置文件是正常的;

  • 接着開始排查是否是網絡問題:

    tcpdump -i eth0|grep VRRP tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 21:00:53.202437 IP 192.168.8.123 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 50, prio 100, authtype simple, intvl 1s, length 20 21:00:53.202964 IP 192.168.8.126 > vrrp.mcast.net: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 20 21:00:53.204638 IP keepalived-slave > vrrp.mcast.net: VRRPv2, Advertisement, vrid 66, prio 80, authtype simple, intvl 1s, length 20 發現keepalived從服務器也能正常接收到vrrp包;

  • 最后考慮到,該主機啟用了firewalld防火牆;於是開始從防火牆開始着手解決問題

Keepalived是一個輕量級的HA集群解決方案,但開啟防火牆后各節點無法感知其它節點的狀態,各自都綁定了虛擬IP。網上很多文章講要配置防火牆放過tcp/112,在CentOS7下是無效的,正確的做法是配置放過vrrp協議,方法如下:

firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
firewall-cmd --direct --permanent --add-rule ipv4 filter OUTPUT 0 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
firewall-cmd --reload

Keepalived使用vrrp組播,默認地址是224.0.0.18,因此要配置防火牆放過。 完成后再用ip addr查看,集群已經正常了,只有主節點綁定虛擬IP,備份節點不會綁定了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM