2015-07-19 58 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地址時,停止接收消息,因爲之後我在日誌文件中看不到任何條目。 –