我正在使用 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,请帮助。