keepalived+haproxy配置故障

你們好。我在配置keepalived和haproxy的時候遇到腦裂的問題,還請你們幫助我分析一下,謝謝。個人環境信息以下:服務器

一共兩臺虛擬機,是同個一共模板複製出來的(我懷疑問題出在這裏)。網絡

主機IP:192.168.1.136測試

備機IP:192.168.1.135ui

VIP:192.168.1.118spa

主機的keepalived的配置以下:操作系統

global_defs {日誌

   notification_email {router

     rootserver

   }接口

   notification_email_from root

   smtp_server 192.168.0.55

   smtp_connect_timeout 30

   router_id HAproxy

}


vrrp_script chk_haproxy {

                script "/opt/check_haproxy.sh"

                interval 2

                weight 2

}


vrrp_instance HAproxy1 {

  state MASTER #標示狀態爲MASTER 備份機爲BACKUP

  interface eth0

  virtual_router_id 51

  priority 100 #MASTER權重爲100,BACKUP權重爲90

  advert_int 1

  authentication {

     auth_type PASS #主從服務器驗證方式

     auth_pass 1111

  }

    track_interface {           # 監控的接口

      eth0

      eth1

    }

  virtual_ipaddress {

     192.168.1.118/24 dev eth0 

  }

  track_script { 

     chk_haproxy ### 執行監控的服務 

  }

}

備機的keepalived的配置以下:

global_defs {

   notification_email {

    root

   }

   notification_email_from root

   smtp_server 192.168.0.55

   smtp_connect_timeout 30

   router_id HAproxy

}


vrrp_script chk_haproxy {

                script "/opt/check_haproxy.sh"

                interval 2

                weight 2

}

vrrp_instance HAproxy1 {

  state BACKUP #標示狀態爲MASTER 備份機爲BACKUP

#interface eth0:1

  #interface eth0.1

  interface eth0

  virtual_router_id 51

  priority 90 #MASTER權重爲100,BACKUP權重爲90

  advert_int 1

  authentication {

     auth_type PASS #主從服務器驗證方式

     auth_pass 1111

  }

    track_interface {           # 監控的接口

      eth0

      eth1

    }

  virtual_ipaddress {

     192.168.1.118/24 dev eth0 

  }

  track_script { 

     chk_haproxy ### 執行監控的服務 

  }

}

主備機網絡是通的。

主備機操做系統是CentOS6.1,keepalived的版本是Keepalived v1.2.15。

在個人測試環境中,我用上面的配置在主備機分別啓動keepalived之後,發現備機先進入BACKUP在轉換到MASTER模式。以下爲日誌

Keepalived[22262]: Starting Keepalived v1.2.15 (03/15,2015)

Keepalived[22263]: Starting VRRP child process, pid=22264

Keepalived_vrrp[22264]: Netlink reflector reports IP 192.168.1.135 added

Keepalived_vrrp[22264]: Netlink reflector reports IP 172.16.1.21 added

Keepalived_vrrp[22264]: Netlink reflector reports IP fe80::250:56ff:feb5:311e added

Keepalived_vrrp[22264]: Netlink reflector reports IP fe80::250:56ff:feb5:b8c4 added

Keepalived_vrrp[22264]: Registering Kernel netlink reflector

Keepalived_vrrp[22264]: Registering Kernel netlink command channel

Keepalived_vrrp[22264]: Registering gratuitous ARP shared channel

Keepalived_vrrp[22264]: Opening file '/etc/keepalived/keepalived.conf'.

Keepalived_vrrp[22264]: Configuration is using : 66715 Bytes

Keepalived_vrrp[22264]: Using LinkWatch kernel netlink reflector...

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Entering BACKUP STATE

Keepalived_vrrp[22264]: VRRP sockpool: [ifindex(2), proto(112), unicast(0), fd(10,11)]

Keepalived_vrrp[22264]: VRRP_Script(chk_haproxy) succeeded

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Transition to MASTER STATE

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Entering MASTER STATE

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) setting protocol VIPs.

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Sending gratuitous ARPs on eth0 for 192.168.1.118

avahi-daemon[1783]: Registering new address record for 192.168.1.118 on eth0.IPv4.

Keepalived_vrrp[22264]: VRRP_Instance(HAproxy1) Sending gratuitous ARPs on eth0 for 192.168.1.118

系統我們能有機會一塊兒探討一下如上的問題,若是我提供的信息不全,還請告訴我,我會當即補充。謝謝你們了。

相關文章
相關標籤/搜索