keepalived+haproxy配置故障

大家好。我在配置keepalived和haproxy的时候遇到脑裂的问题,还请大家帮助我分析一下,谢谢。我的环境信息如下:

一共两台虚拟机,是同个一共模板复制出来的(我怀疑问题出在这里)。

主机IP:192.168.1.136

备机IP:192.168.1.135

VIP:192.168.1.118

主机的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 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

系统咱们能有机会一起探讨一下如上的问题,如果我提供的信息不全,还请告诉我,我会立即补充。谢谢大家了。





转载于:https://my.oschina.net/u/1038048/blog/389461

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值