2015-07-19 68 views
0

我试图配置两个活动负载平衡器服务器keepalivedkeepalived和两个活动服务器

它与标准配置略有不同,我们有两台服务器和一个虚拟IP。

所有我想要的是,当loadbalancer_1下降,然后loadbalancer_2需要他的IP地址,反之亦然。

loadbalancer_1 IP地址:xx.237.193.132/27 loadbalancer_2 IP地址:xx.237.193.134/27

当我开始loadbalancer_1在第一次,它也需要IP地址,因为在那个特定时刻保持活动尚未启动loadbalancer_2。 但是当我启动loadbalancer_2时,他的IP地址仍然在loadbalancer_1。所以,loadbalancer_1。是两个IP地址的主人。

同样的情况发生时,我首先启动loadbalancer_2,因此之前启动的服务器将成为两个IP地址的主服务器。

登录loadbalancer_1

Jul 19 19:18:00 001 Keepalived_vrrp[9751]: Registering Kernel netlink reflector 
Jul 19 19:18:00 001 Keepalived_vrrp[9751]: Registering Kernel netlink command channel 
Jul 19 19:18:00 001 Keepalived_vrrp[9751]: Registering gratuitous ARP shared channel 
Jul 19 19:18:00 001 Keepalived_vrrp[9751]: Opening file '/etc/keepalived/keepalived.conf'. 
Jul 19 19:18:00 001 Keepalived_healthcheckers[9750]: Registering Kernel netlink reflector 
Jul 19 19:18:00 001 Keepalived_healthcheckers[9750]: Registering Kernel netlink command channel 
Jul 19 19:18:00 001 Keepalived_healthcheckers[9750]: Opening file '/etc/keepalived/keepalived.conf'. 
Jul 19 19:18:00 001 Keepalived_vrrp[9751]: Configuration is using : 71869 Bytes 
Jul 19 19:18:00 001 Keepalived_vrrp[9751]: Using LinkWatch kernel netlink reflector... 
Jul 19 19:18:00 001 Keepalived_vrrp[9751]: VRRP_Instance(web_loadbalancer_2) Entering BACKUP STATE 
Jul 19 19:18:00 001 Keepalived_healthcheckers[9750]: Configuration is using : 12587 Bytes 
Jul 19 19:18:00 001 Keepalived_healthcheckers[9750]: Using LinkWatch kernel netlink reflector... 
Jul 19 19:18:01 001 Keepalived_vrrp[9751]: VRRP_Instance(web_loadbalancer_1) Transition to MASTER STATE 
Jul 19 19:18:02 001 Keepalived_vrrp[9751]: VRRP_Instance(web_loadbalancer_1) Entering MASTER STATE 
Jul 19 19:18:04 001 Keepalived_vrrp[9751]: VRRP_Instance(web_loadbalancer_2) Transition to MASTER STATE 
Jul 19 19:18:05 001 Keepalived_vrrp[9751]: VRRP_Instance(web_loadbalancer_2) Entering MASTER STATE 

登录loadbalancer_2

配置的 loadbalancer_1
Jul 19 19:18:08 002 Keepalived_vrrp[468]: Registering Kernel netlink reflector 
Jul 19 19:18:08 002 Keepalived_vrrp[468]: Registering Kernel netlink command channel 
Jul 19 19:18:08 002 Keepalived_vrrp[468]: Registering gratuitous ARP shared channel 
Jul 19 19:18:08 002 Keepalived_vrrp[468]: Opening file '/etc/keepalived/keepalived.conf'. 
Jul 19 19:18:08 022 Keepalived_vrrp[468]: Configuration is using : 71869 Bytes 
Jul 19 19:18:08 002 Keepalived_vrrp[468]: Using LinkWatch kernel netlink reflector... 
Jul 19 19:18:08 002 Keepalived_vrrp[468]: VRRP_Instance(web_loadbalancer_1) Entering BACKUP STATE 
Jul 19 19:18:08 002 Keepalived_healthcheckers[467]: Registering Kernel netlink reflector 
Jul 19 19:18:08 002 Keepalived_healthcheckers[467]: Registering Kernel netlink command channel 
Jul 19 19:18:08 002 Keepalived_healthcheckers[467]: Opening file '/etc/keepalived/keepalived.conf'. 
Jul 19 19:18:08 002 Keepalived_healthcheckers[467]: Configuration is using : 12587 Bytes 
Jul 19 19:18:08 002 Keepalived_healthcheckers[467]: Using LinkWatch kernel netlink reflector... 
Jul 19 19:18:09 002 Keepalived_vrrp[468]: VRRP_Instance(web_loadbalancer_2) Transition to MASTER STATE 
Jul 19 19:18:10 002 Keepalived_vrrp[468]: VRRP_Instance(web_loadbalancer_2) Entering MASTER STATE 
Jul 19 19:18:11 002 Keepalived_vrrp[468]: VRRP_Instance(web_loadbalancer_2) Received lower prio advert, forcing new election 

global_defs { 
    router_id loadbalancer_1 
    lvs_id loadbalancer_1 
} 
vrrp_instance web_loadbalancer_1 { 
    state MASTER 
    interface eth0 
    virtual_router_id 10 
    priority 110 
    advert_int 1 
    virtual_ipaddress { 
     xx.237.193.132/27 dev eth0 
    } 
    authentication { 
     auth_type PASS 
     auth_pass 45f3fgv1 
    } 
} 
vrrp_instance web_loadbalancer_2 { 
    state BACKUP 
    interface eth0 
    virtual_router_id 20 
    priority 200 
    smtp_alert 
    advert_int 1 
    virtual_ipaddress { 
     xx.237.193.134/27 dev eth0 
    } 
    authentication { 
     auth_type PASS 
     auth_pass 45f3fgv2 
    } 
} 

配置loadbalancer_2的:

global_defs { 
    router_id loadbalancer_2 
    lvs_id loadbalancer_2 
} 
vrrp_instance web_loadbalancer_1 { 
    state BACKUP 
    interface eth0 
    virtual_router_id 10 
    priority 100 
    advert_int 1 
    virtual_ipaddress { 
     xx.237.193.132/27 dev eth0 
    } 
    authentication { 
     auth_type PASS 
     auth_pass 45f3fgv1 
    } 
} 
vrrp_instance web_loadbalancer_2 { 
    state MASTER 
    interface eth0 
    virtual_router_id 20 
    priority 210 
    advert_int 1 
    virtual_ipaddress { 
     xx.237.193.134/27 dev eth0 
    } 
    authentication { 
     auth_type PASS 
     auth_pass 45f3fgv2 
    } 
} 
+0

当lb1停止接收消息时,您可以重新启动lb2还是keepalived/vrrpd服务来生成更多日志? – Pieter

回答

0

问题已由我解决。 最初没有关于的eth0接口(LB_1LB_2)伯IP位址,我已经在使用他们的keepalived配置。

On loadbalancer_1 : xx.237.193.132/27 
On loadbalancer_2 : xx.237.193.134/27 

然后我刚刚编辑了的keepalived配置和其他在同一子网替换那些IP地址:

For loadbalancer_1 : xx.237.193.150/27 
For loadbalancer_2 : xx.237.193.151/27 

所以,当系统启动eth0的将被初始化与旧的主IP地址,但保持活动将使用来自同一子网的其他虚拟IP地址。 我不知道为什么第一个解决方案不起作用,我没有找到任何解释或要求。

有没有人可以解释什么是问题,以及为什么我不能使用分配给操作系统启动界面的主IP地址在保持活动配置?

0

我建议添加preempt_delay 10两者MASTER部分。

看着为Server2上的最后一个日志条目

7月19日19时18分十一秒002 Keepalived_vrrp [468]:VRRP_Instance(web_loadbalancer_2)接收较低PRIO广告,迫使新的选举

它似乎它只是意识到它可以接管为VRRP主控。如果这种情况没有发生,那么稍后可能会在日志中看一看。

第一台服务器启动是正常的,因为没有其他服务器,所以假定主服务器,然后当第二台服务器变为活动时,vrrp重选应该选择配置了最高优先级的服务器。

+0

我没有帮助。看起来,当** loadbalancer_1 **获取** loadbalancer_2 ** IP地址的IP地址时,停止接收消息,因为之后我在日志文件中看不到任何条目。 –