我使用HAProxy作为我的应用程序的负载均衡器,并且为了使其高度可用,我使用了keepalive服务和浮动ip地址的概念。但是,每当我的主负载均衡器服务器宕机时,通过将其从网络中移除或将其关闭,我的所有服务都会宕机,而不是使辅助负载均衡器服务器可用。我的主服务器的keepalived.conf是,
global_defs
{
# Keepalived process identifier
lvs_id haproxy_DH
}
# Script used to check if HAProxy is running
vrrp_script check_haproxy
{
script "pidof haproxy"
interval 2
weight 2
}
# Virtual interface
vrrp_instance VI_01
{
state MASTER
interface eno16777984 #here eth0 is the name of network interface
virtual_router_id 51
priority 101
# The virtual ip address shared between the two loadbalancers
virtual_ipaddress {
172.16.231.162
}
track_script {
check_haproxy
}
}对于备份服务器,它就像,
global_defs
{
# Keepalived process identifier
lvs_id haproxy_DH_passive
}
# Script used to check if HAProxy is running
vrrp_script check_haproxy
{
script "pidof haproxy"
interval 2
weight 2
}
# Virtual interface
vrrp_instance VI_01
{
state BACKUP
interface eno16777984 #here eth0 is the name of network interface
virtual_router_id 51
priority 100
# The virtual ip address shared between the two loadbalancers
virtual_ipaddress {
172.16.231.162
}
track_script {
check_haproxy
}
}当两个负载均衡器都启动时,将分配虚拟IP地址并使其工作。但每当机器停机时,我的服务也会停机。我正在使用CentOS7,请帮助我。
发布于 2021-07-19 03:08:37
使用这个,
global_defs {
router_id ovp_vrrp
} vrrp_script haproxy_check {脚本"killall 0 haproxy"间隔2权重2}
接口OCP_EXT { vrrp_instance ens192
virtual_router_id 51
优先级100状态主virtual_ipaddress { 10.19.114.231 开发ens192
} track_script { haproxy_check }鉴权{ auth_type通过auth_pass 1cee4b6e-2cdc-48bf-83b2-01a96d1593e4 }}
更多信息:阅读此处,https://www.openshift.com/blog/haproxy-highly-available-keepalived
https://stackoverflow.com/questions/67822951
复制相似问题