【发布时间】:2020-08-28 20:24:21
【问题描述】:
haproxy 配置。
defaults
option forwardfor
log global
option httplog
log 127.0.0.1 local3
option dontlognull
retries 3
option redispatch
timeout connect 5000ms
timeout client 5000ms
timeout server 5000ms
listen stats
bind *:9000
mode http
..............................................
backend testhosts
mode http
balance roundrobin
option httpchk HEAD /sabrix/scripts/menu-common.js
server host1 11.11.11.11:9080 check inter 2000 rise 1 fall 2
server host2 11.11.11.12:9080 check inter 2000 rise 1 fall 2
如果11.11.11.11的服务宕机,haproxy会在2-3秒左右得到503和404错误(取决于inter值,如果inter值非常小,404错误的数量会减少)。
2020-08-25T11:58:14 11.11.11.11:9080 200 POST /tsturl1 HTTP/1.1 2274
2020-08-25T11:58:14 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 448
2020-08-25T11:58:14 11.11.11.11:9080 503 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:14 11.11.11.11:9080 404 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:14 11.11.11.11:9080 200 POST /tsturl1 HTTP/1.1 1503
2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 617
2020-08-25T11:58:16 11.11.11.11:9080 404 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 618
2020-08-25T11:58:16 11.11.11.11:9080 404 POST /tsturl1 HTTP/1.1 0
2020-08-25T11:58:16 host1 is DOWN, reason: Layer7 wrong status, code: 404, info: "Not Found", check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue. 2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 645
2020-08-25T11:58:16 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 618\
我的问题是:为什么参数重试不起作用?当后端服务器之一关闭时,haproxy 能否确保对后端服务器的每次调用都成功? Haproxy 1.5.18 的版本。我也试过 2.2.2,我得到了同样的错误。
【问题讨论】:
-
我尝试在 haproxy.cfg 中添加“http-check disable-on-404”,然后重新启动 haproxy,但它似乎不起作用。 ''' 2020-08-28T16:58:14 11.11.11.11:9080 200 POST /tsturl1 HTTP/1.1 2274 2020-08-28T16:58:14 11.11.11.22:9080 200 POST /tsturl1 HTTP/1.1 448 2020-08 -28T16:58:14 11.11.11.11:9080 503 POST /tsturl1 HTTP/1.1 0