我正在尝试在 haproxy 中使用 external-check 选项,但是在服务重启后在日志中我看到:
Dec 30 10:41:34 1 haproxy[89540]: [WARNING] (89540) : config : 'external-check command' will be ignored for proxy 'primary' (requires 'option external-check').
Dec 30 10:41:34 1 haproxy[89540]: [WARNING] (89540) : config : 'external-check path' will be ignored for proxy 'primary' (requires 'option external-check').
haproxy.cfg的内容:
global
log 127.0.0.1 local2
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
external-check
user haproxy
group haproxy
maxconn 4000
daemon
defaults
mode tcp
log global
option tcplog
retries 3
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s
maxconn 3000
listen stats
mode http
bind *:7000
stats enable
stats uri /
listen primary
bind 192.168.57.200:5000
option external-check
external-check path "/usr/bin:/bin"
external-check command "/bin/ldapHealthCheck.sh"
option httpchk OPTIONS /master
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server patroni1 192.168.57.133:6432 maxconn 100 check port 8008
server patroni2 192.168.57.134:6432 maxconn 100 check port 8008
server patroni3 192.168.57.136:6432 maxconn 100 check port 8008
为什么当我在配置中添加此参数时仍然需要选项 external-check?
答案1
我不确定这是否是问题所在,但您的 HAProxy 在 chroot Jail 中工作(在全局 chroot /var/lib/haproxy 下)。因此,如果您想让外部检查正常工作,您需要在 chroot 中添加至少 bash。检查此线程:https://discourse.haproxy.org/t/external-check-and-chroot/2150/13 希望这可以帮助你:D