很多业务都会使用 keepalived 做高可用, 由于业务调整, keepalived 需要维护 100 VIP, 直接修改 virtual_ipaddress 配置文件
virtual_ipaddress { 1.1.1.1/24 brd 1.1.1.255 dev eth0 1.1.1.2/24 brd 1.1.1.255 dev eth0 1.1.1.3/24 brd 1.1.1.255 dev eth0 1.1.1.4/24 brd 1.1.1.255 dev eth0 1.1.1.5/24 brd 1.1.1.255 dev eth0 # 忽略90条 1.1.1.96/24 brd 1.1.1.255 dev eth0 1.1.1.97/24 brd 1.1.1.255 dev eth0 1.1.1.98/24 brd 1.1.1.255 dev eth0 1.1.1.99/24 brd 1.1.1.255 dev eth0 1.1.1.100/24 brd 1.1.1.255 dev eth0 }
重启keepalived服务后发现, 只有 20 个 ip, 绑定到 eth0 接口上
# tail /var/log/messages Feb 12 08:45:14 xxxxx Keepalived_vrrp[12452]: => Declare others VIPs into the excludedvip block Feb 12 08:45:14 xxxxx Keepalived_vrrp[12452]: VRRP_Instance(VI_1) trunc to the first 20 VIPs. Feb 12 08:45:14 xxxxx Keepalived_vrrp[12452]: => Declare others VIPs into the excludedvip block Feb 12 08:45:14 xxxxx Keepalived_vrrp[12452]: VRRP_Instance(VI_1) trunc to the first 20 VIPs.
查看官方文档后,发现 vip 最多支持 20 个 http://www.keepalived.org/changelog.html
VRRP packet lenght are limited to a 20 VIPs, if you want more VRRP VIPs add them to the "virtual_ipaddress_excluded" configuration block.
文档也已经说明 VRRP(虚拟路由器冗余协议) 限制 20 VIP, 如果需要更多, 请使用 virtual_ipaddress_excluded 配置,
virtual_ipaddress { 1.1.1.1/24 brd 1.1.1.255 dev eth0 1.1.1.2/24 brd 1.1.1.255 dev eth0 1.1.1.3/24 brd 1.1.1.255 dev eth0 } virtual_ipaddress_excluded { 1.1.1.4/24 brd 1.1.1.255 dev eth0 1.1.1.5/24 brd 1.1.1.255 dev eth0 # 忽略90条 1.1.1.96/24 brd 1.1.1.255 dev eth0 1.1.1.97/24 brd 1.1.1.255 dev eth0 1.1.1.98/24 brd 1.1.1.255 dev eth0 1.1.1.99/24 brd 1.1.1.255 dev eth0 1.1.1.100/24 brd 1.1.1.255 dev eth0 }
重启服务后, ip address 看到所有ip了, 不过virtual_ipaddress_excluded只做 ip绑定, 不做心跳检查.
另外看到其他人使用 notify_master, 和 notify_backup 同样也可以实现超过 20 VIP
notify_master /scripts/add_vip.sh #添加VIP的脚本 notify_backup /scripts/del_vip.sh #删除VIP的脚本
254个VIP时脚本生成keepalived.conf配置文件
转载请注明:爱开源 » keepalived 超过 20 个VIP