大网数据广告活动
服务器运维问答

How to make HAProxy wait for successful health check before bringing server out of maintenance mode

· 52CE 我爱测

I am using HAProxy socket communication to put my backend into maintenance mode before bringing the web server down for maintenance via this command: echo "disable server cluster-01/app-01-4" | sudo socat stdio /tmp/haproxy.sock …

问题原文

原帖链接 · WickedElephant · CC BY-SA 3.0

I am using HAProxy socket communication to put my backend into maintenance mode before bringing the web server down for maintenance via this command:

echo "disable server cluster-01/app-01-4" | sudo socat stdio /tmp/haproxy.sock

The problem is that when I mark the backend available again via the socket enable command, HAProxy does not wait for any successful health checks before sending requests to the backend. So we end up losing some of the requests before HAProxy realizes the server is still down, and takes it back off line.

Is there a way to tell HAProxy to wait until the backend is healthy prior to enabling it? Or do I have to make my startup scripts smart enough to monitor the server itself prior to telling HaProxy to enable the backend again? This would obviously be less than ideal.

I'm currently doing this:
echo "enable server cluster-01/app-01-4" | sudo socat stdio /tmp/haproxy.sock

Is there something akin to this that I can use instead? echo "enable server cluster-01/app-01-4 WAIT_FOR_SUCCESSFUL_HEALTH_CHECK" | sudo socat stdio /tmp/haproxy.sock

Edit: I am using HAProxy version 1.5x

已采纳解答

原帖链接 · Michael - sqlbot · CC BY-SA 3.0

Using set server proxy-name/server-name health down prior to putting the server back in service with enable server ... appears to do what you need.

The server would eventually be taken out of service by subsequent health checks, but that doesn't help if the server was healthy when you took it out, but not healthy when you bring it back in, since HAProxy appears to assume that the server will be in the same health state when enabled that it was in when it was disabled.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。