keepalive:
[root@proxy ~]# yum install -y keepalived
[root@proxy ~]# vim /etc/keepalived/keepalived.conf
global_defs {router_id proxy1 //设置路由ID号vrrp_iptables //不添加任何防火墙规则
}
vrrp_instance VI_1 {state MASTER //主服务器为MASTER(备服务器需要修改为BACKUP)
interface eth0 //定义网络接口virtual_router_id 51 priority 100 //服务器优先级,优先级高优先获取VIP(实验需要修改)advert_int 1authentication {auth_type passauth_pass 1111 //主备服务器密码必须一致
}virtual_ipaddress { //谁是主服务器谁获得该VIP(实验需要修改)
192.168.4.80
}
}
[root@proxy ~]# systemctl start keepalived
注意:
keepalived的日志文件路径:/var/log/messages
可以发现,出现这个问题的原因在于我在keepalived.conf配置文件中将virtual_router_id参数设置了默认id——51,然后同一内网内还有其它keepalived集群也设置了51这个默认路由id,因此keepalived报“目前xxx这个虚拟IP不能绑定到51这个路由id上”的错误。