它工作正常,直到远程服务器暂时不可用。在这种情况下,服务器在日志中关闭,并且永远不会再次启动。配置非常简单:
defaults
retries 3
timeout connect 5000
timeout client 3600000
timeout server 3600000
log global
option log-health-checks
listen amazon_ses
bind 127.0.0.2:1234
mode tcp
no option http-server-close
default_backend bk_amazon_ses
backend bk_amazon_ses
mode tcp
no option http-server-close
server amazon email-smtp.us-west-2.amazonaws.com:587 check inter 30s fall 120 rise 1
问题发生时的日志如下:
Jul 3 06:45:35 jupiter haproxy[40331]: Health check for server bk_amazon_ses/amazon failed, reason: Layer4 timeout, check duration: 30004ms, status: 119/120 UP.
Jul 3 06:46:35 jupiter haproxy[40331]: Health check for server bk_amazon_ses/amazon failed, reason: Layer4 timeout, check duration: 30003ms, status: 118/120 UP.
Jul 3 06:47:35 jupiter haproxy[40331]: Health check for server bk_amazon_ses/amazon failed, reason: Layer4 timeout, check duration: 30002ms, status: 117/120 UP.
...
Jul 3 08:44:36 jupiter haproxy[40331]: Health check for server bk_amazon_ses/amazon failed, reason: Layer4 timeout, check duration: 30000ms, st
atus: 0/1 DOWN.
Jul 3 08:44:36 jupiter haproxy[40331]: Server bk_amazon_ses/amazon is DOWN. 0 active and 0 backup servers left. 0 sessions active, 0 requeued,
0 remaining in queue.
Jul 3 08:44:36 jupiter haproxy[40331]: backend bk_amazon_ses has no server available!`
就这样。只需手动重新加载服务器即可(服务 haproxy 重新加载在 FreeBSD 上)可使服务器恢复运行。我还尝试删除检查部分及其后续内容 - 仍然发生相同的情况。不能将 haproxy 配置为无限期尝试而不将服务器标记为 DOWN 吗?谢谢。
答案1
您是否尝试过使用更低的超时时间?还使用过类似的东西?\
server amazon email-smtp.us-west-2.amazonaws.com:587 check inter 5s fall 3 rise 2
还可以尝试将这些选项添加到您的后端:
mode tcp
option tcplog
option log-health-checks
然后再次检查你的 haproxy 日志,看看是否获得任何其他信息。
您还可以手动尝试从 haproxy 框到该服务器的端口 587 上的 telnet,看看当 haproxy 报告其已关闭时您是否可以连接?如果您无法通过 telnet 连接,那么 haproxy 报告其已关闭是很正常的。
您的 SMTP 盒上是否有任何速率限制、防火墙或任何其他类似的配置可能会阻止 haproxy 服务器?
答案2
我在使用 HAProxy 1.8 版本时遇到了同样的错误。我不明白发生了什么,但我重新启动了 haproxy 服务,问题就解决了。
Server xxxx is DOWN, reason: Layer4 timeout, check duration: 1001ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Aug 25 16:10:18 localhost haproxy[5749]: backend yyyyy has no server available!