Keepalived是一個輕量級的HA集羣解決方案,但開啓防火牆後各節點沒法感知其它節點的狀態,各自都綁定了虛擬IP。網上不少文章講要配置防火牆放過tcp/112,在CentOS7下是無效的,正確的作法是配置放過vrrp協議,方法以下:bash
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,所以要配置防火牆放過。tcp
完成後再用ip addr查看,集羣已經正常了,只有主節點綁定虛擬IP,備份節點不會綁定了。ide