为什么动态添加的服务器没有被检查?

问题描述 投票:0回答:0

我正在为一个简单的后端服务器设置 HAProxy。这是我的

haproxy.cfg
文件:

global
  user haproxy
  group haproxy
  stats socket /var/run/haproxy.sock mode 660 level admin expose-fd listeners
  daemon

frontend webapp
  mode http
  bind *:80
  default_backend webservers

backend webservers
  mode http
  balance roundrobin
  server s1 web1:5000 check
  server s2 web2:5000 check

listen stats
  bind *:9999
  mode http
  stats enable
  stats uri /stats
  stats hide-version

现在,在向端口

:80
发送请求并启动我的 HAProxy 容器后,我打开 HAProxy 统计页面并看到以下内容:

请注意,即使我没有在

haproxy.cfg
文件中明确定义它,第 4 层健康检查也会在这些服务器上执行。现在我使用 Runtime API 添加服务器,明确地:

echo "add server webservers/s3 10.89.1.47:5000 check" | socat stdio /var/run/haproxy.sock

同时将状态切换为就绪,

echo "set server webservers/s3 state ready" | socat stdio /var/run/haproxy.sock

然后我在 HAProxy 统计页面中看到以下内容:

请求现在正在新服务器上进行负载平衡,这很好。但是,我注意到它的状态是“no check”,表示没有在新服务器上执行任何健康检查。我确信我添加的服务器已启动并正在运行,并且可以有效地处理请求。不过,我希望它具有与默认服务器相同的状态,默认服务器会进行健康检查。你能告诉我为什么在检查默认服务器时没有在我的新服务器上执行健康检查吗?

我已经尝试添加

option tcp-check
但这没有用。另外,据我了解,如果我的模式是
option tcp-check
,我不应该设置
mode http

config haproxy
© www.soinside.com 2019 - 2024. All rights reserved.