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