Load balancing CentOS 7.5上带有Keepalived(v2.0.7)的Haproxy(v2.0.3)返回选定应用程序的err空响应
我们在两台非生产服务器上运行haproxy,这两台服务器通过KeepAlive进行平衡,以管理故障切换 我们最近从haproxy 1.5升级到2.0.3。在我们的非生产环境中,我们从来没有HA解决方案,因此我们决定运行KeepAlive来检测haproxy故障/停止,并将VIP应用于备份服务器 当我们应用这些更新时,一切都很好…直到我们注意到在lb中添加了一些新站点。当KeepAlive重新启动(而不是重新加载)并且lb后面有了新站点时,新站点似乎在不确定的时间内工作得很好…然后它们开始返回“err_empty_response”。似乎没有什么可以解决这个问题,直到KeepAlive重新启动,然后它们会在不确定的时间内再次工作,然后开始返回“err_empty_response” 该站点仍在统计页面中标记 令人痛苦的是,调用停止进入haproxy.log文件,这让我认为问题不在于(仅仅)haproxy 我们的尝试:Load balancing CentOS 7.5上带有Keepalived(v2.0.7)的Haproxy(v2.0.3)返回选定应用程序的err空响应,load-balancing,haproxy,failover,keepalived,Load Balancing,Haproxy,Failover,Keepalived,我们在两台非生产服务器上运行haproxy,这两台服务器通过KeepAlive进行平衡,以管理故障切换 我们最近从haproxy 1.5升级到2.0.3。在我们的非生产环境中,我们从来没有HA解决方案,因此我们决定运行KeepAlive来检测haproxy故障/停止,并将VIP应用于备份服务器 当我们应用这些更新时,一切都很好…直到我们注意到在lb中添加了一些新站点。当KeepAlive重新启动(而不是重新加载)并且lb后面有了新站点时,新站点似乎在不确定的时间内工作得很好…然后它们开始返回“e
- 在keepalived.conf中将每个环境拆分为自己的虚拟接口
- 将后端服务器上的api绑定更新为工作api(以消除作为选项的api代码)
- 使用缩短的url创建新绑定
- 减少超时(客户端、服务器)
`! Configuration File for keepalived
global_defs {
notification_email {
test@blah.com
}
notification_email_from keepalived@blah.com
smtp_server blah.mail.protection.outlook.com.
smtp_connect_timeout 30
router_id LVS_NONPROD
}
# Script used to check if HAProxy is running
vrrp_script check_haproxy {
script "pidof haproxy"
interval 2
weight 2
}
vrrp_instance VI_DEV {
state MASTER
interface ens160
virtual_router_id 52
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
}
track_script {
check_haproxy
}
}
vrrp_instance VI_TEST {
state MASTER
interface ens160
virtual_router_id 53
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
}
track_script {
check_haproxy
}
}
vrrp_instance VI_UAT {
state MASTER
interface ens160
virtual_router_id 54
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
}
track_script {
check_haproxy
}
}
vrrp_instance VI_STAGING {
state MASTER
interface ens160
virtual_router_id 55
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
}
track_script {
check_haproxy
}
}
vrrp_instance VI_SS {
state MASTER
interface ens160
virtual_router_id 56
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
}
track_script {
check_haproxy
}
}
vrrp_instance VI_NS {
state MASTER
interface ens160
virtual_router_id 57
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
xxx.xxx.xxx.xxx
}
track_script {
check_haproxy
}
}`
单倍体球状体:
`global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2 debug
tune.chksize 32768 #don't get me started...dev requirement because of antiquated requirement not coded away
tune.bufsize 32768 #refer to previous statement
tune.ssl.default-dh-param 2048
max-spread-checks 20000
tune.maxpollevents 10000
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 40000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats`
默认值:
`defaults
mode http
log global
option httplog
option log-health-checks
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 60000
timeout connect 10s
timeout client 60000
timeout server 60000
timeout http-keep-alive 30s
timeout check 30s
maxconn 30000
errorfile 503 /etc/haproxy/errorfiles/503.http`
答案有点傻。负载平衡器的内部DNS是不正确的,因此,在我尝试ssh到机器上之前,不可能对其进行远程处理,因为在网站抛出这些错误的期间。原来旧的负载平衡器将ip地址作为网络脚本的一部分(ie/etc/sysconfig/networkscripts/ifcfg-eth0:0-20) 因此,当我重新启动KeepAlive时,新实例将起作用,因为它会获取ip地址,而旧实例会将它们取回(随后导致失败,因为旧实例中没有条目) 我在旧实例上停止了haproxy,从旧服务器上删除了/etc/sysconfig/network scripts/ifcfg-eth0:*文件,在新集群上重新启动了KeepAlive,一切都正常工作
现在感觉有点傻。欢迎来到SO!你的问题是哪一个?@DavidGarcíaBodego我只是好奇是否有其他人遇到过类似的问题。经过一番思考,我倾向于认为该问题是保留的,因为失败的请求没有进入haproxy日志,但我不能肯定,因为保留的日志没有显示任何失败/问题。因此,请编辑您的帖子并包含您的问题。如果问题不清楚,用户倾向于回避。因此,在完成所有代码之后,如果没有问题,用户将回避您的问题。