我有两台运行Keepalived 1.2.7的服务器,主机名right 。 这里是configuration:
# keepalived.conf on left vrrp_instance VI_1 { state MASTER interface eth1 virtual_router_id 51 priority 160 advert_int 1 virtual_ipaddress { 10.10.10.200 } } # keepalived.conf on right vrrp_instance VI_1 { state MASTER interface eth1 virtual_router_id 51 priority 100 advert_int 1 virtual_ipaddress { 10.10.10.200 } }
现在我开机left 。 这里是系统日志的样子,交织和注释:
>> started servers << Aug 15 19:07:32 left Keepalived[4041]: Starting VRRP child process, pid=4043 Aug 15 19:07:32 right Keepalived[4041]: Starting VRRP child process, pid=4043 Aug 15 19:07:33 left Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Transition to MASTER STATE Aug 15 19:07:33 right Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Transition to MASTER STATE Aug 15 19:07:33 right Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Received higher prio advert Aug 15 19:07:33 right Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Entering BACKUP STATE Aug 15 19:07:34 left Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Entering MASTER STATE >> left has 10.10.10.200 << >> powered off left << Aug 15 19:08:25 right Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Transition to MASTER STATE Aug 15 19:08:26 right Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Entering MASTER STATE >> right has 10.10.10.200 << >> powered on left << Aug 15 19:08:58 left Keepalived[1027]: Starting VRRP child process, pid=1029 Aug 15 19:08:59 left Keepalived_vrrp[1029]: VRRP_Instance(VI_1) Transition to MASTER STATE Aug 15 19:09:00 left Keepalived_vrrp[1029]: VRRP_Instance(VI_1) Entering MASTER STATE Aug 15 19:09:00 right Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Received higher prio advert Aug 15 19:09:00 right Keepalived_vrrp[4043]: VRRP_Instance(VI_1) Entering BACKUP STATE >> neither has 10.10.10.200 <<
当我回来的时候,我期待着能够收回10.10.10.200。 为什么不呢? 我如何修改我的keepalived.conf ?
你希望“右”的configuration看起来像这样:
vrrp_instance VI_1 { state BACKUP interface eth1 virtual_router_id 51 priority 100 advert_int 1 virtual_ipaddress { 10.10.10.200 }
BACKUP关键字告诉keepalived在可用时回到MASTER 。
以下configuration工作 尽pipe我仍然好奇为什么在我的问题中没有 。
# keepalived.conf on left vrrp_instance VI_1 { state BACKUP interface eth1 virtual_router_id 51 priority 160 advert_int 1 preempt_delay 15 virtual_ipaddress { 10.10.10.200 } } # keepalived.conf on right vrrp_instance VI_1 { state BACKUP interface eth1 virtual_router_id 51 priority 100 advert_int 1 preempt_delay 15 virtual_ipaddress { 10.10.10.200 } }
此configuration表示在优先级较高的机器联机15秒后重新select新的主机。 有邮件列表中的preempt_delay选项的解释。
这个configuration的一个问题是:如果两台机器都停机,那么10.10.10.200当它们恢复时都不会声明。 (这是由于Vagrant所做的networking自动configuration。)