keepalived haproxy 主备配置

global_defs {
router_id k8s_master
}

vrrp_script chk_http_port {
script "/etc/keepalived/check_haproxy.sh"
interval 2
}


vrrp_instance k8s_master {
state MASTER
interface bond1
virtual_router_id 188
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass wangqing123
}
virtual_ipaddress {
10.16.16.254/20
}

unicast_src_ip 10.16.16.39
unicast_peer {
10.16.16.40
}


track_script {
chk_http_port
}

}

##check_haproxy.sh


#!/bin/bash
A=`ps -C haproxy --no-header |wc -l`
if [ $A -eq 0 ];then
#/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg

/etc/init.d/haproxy start

sleep 3
if [ `ps -C haproxy --no-header |wc -l` -eq 0 ];then
pkill -9 keepalived
fi
fi

扫描二维码关注公众号,回复: 1870269 查看本文章

猜你喜欢

转载自www.cnblogs.com/Qing-840/p/9264331.html