码迷,mamicode.com
首页 > 其他好文 > 详细

负载均衡实现故障vip自动漂移

时间:2019-07-31 11:19:55      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:ns3   vip   bin   信息   负载   路由   pad   负载均衡   环境   

环境说明演示vip自动漂移
192.168.237.50
192.168.237.51
vip: 192.168.237.5

keepalived开源软件实现
keepalived可以实现当vip挂的时候,自动漂移,基于vrrp虚拟路由冗余协议
主备,vrrp去宣告


keepalived主服务器的配置/usr/local/keepalived/etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 2
    authentication {
        auth_type PASS
        auth_pass 666666
    }
    virtual_ipaddress {
        192.168.237.5/24
    }
}


vrrp_instance配置,配置vip
state 配置主或者备
interface 配置vip使用的物理网卡
virtual_router_id 虚拟路由id
priority 权重配置,主的权重比备的高
advert_int 主每2s发个vrrp包,说明自己正常
authentication 认证信息
virtual_ipaddress 配置vip


检查配置,启动keepalived
/usr/local/keepalived/sbin/keepalived -t -f /usr/local/keepalived/etc/keepalived/keepalived.conf
/usr/local/keepalived/sbin/keepalived -f /usr/local/keepalived/etc/keepalived/keepalived.conf


keepalived备服务器的配置/usr/local/keepalived/etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
    state BACKUP
    interface ens33
    virtual_router_id 51
    priority 99
    advert_int 2
    authentication {
        auth_type PASS
        auth_pass 666666
    }
    virtual_ipaddress {
        192.168.237.5/24
    }
}


抓包可以看到vrrp协议


验证keepalived的vip自动漂移

存在问题
主起来后又会接管vip
vip的频繁漂移对于我们不太有利

负载均衡实现故障vip自动漂移

标签:ns3   vip   bin   信息   负载   路由   pad   负载均衡   环境   

原文地址:https://www.cnblogs.com/dhzg/p/11274547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!