keepalived 的 unicast 单播模式

最近遇到一个问题,keepalived 在 OpenStack 环境下一直脑裂无法选举。在不支持组播的场景下,可以使用单播模式。

主节点:

global_defs {
   router_id LVS_DEVEL
#  vrrp_strict # 严格模式不支持单播
   vrrp_skip_check_adv_addr
   vrrp_garp_interval 0
   vrrp_gna_interval 0
   vrrp_iptables
}

vrrp_script chk_nginx {
    script "/usr/bin/killall -0 nginx && exit 0 || exit 1"
    interval 1
    weight -10
    fall 2
    rise 1
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 55
    priority 100
    advert_int 1
#   nopreempt
	unicast_src_ip 172.20.47.4
	unicast_peer {
	    172.20.47.5
	}
    authentication {
        auth_type PASS
        auth_pass 12345678
    }
    virtual_ipaddress {
        172.20.47.202
    }

	track_script {
	    chk_nginx
	}
}

备节点:

global_defs {
   router_id LVS_DEVEL
#  vrrp_strict # 严格模式不支持单播
   vrrp_skip_check_adv_addr
   vrrp_garp_interval 0
   vrrp_gna_interval 0
   vrrp_iptables
}

vrrp_script chk_nginx {
    script "/usr/bin/killall -0 nginx && exit 0 || exit 1"
    interval 1
    weight -10
    fall 2
    rise 1
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 55
    priority 95
    advert_int 1
#   nopreempt
	unicast_src_ip 172.20.47.5
	unicast_peer {
	    172.20.47.4
	}
    authentication {
        auth_type PASS
        auth_pass 12345678
    }
    virtual_ipaddress {
        172.20.47.202
    }

	track_script {
        chk_nginx
   }
}

参考:
https://www.jianshu.com/p/7c709c3be4a9
https://blog.csdn.net/weixin_34362991/article/details/93011752

猜你喜欢

转载自www.cnblogs.com/keithtt/p/12758731.html