我有一个 CentOS 7.1 (x64) droplet,配置为在 2 个 apache/php 服务器之间进行负载平衡。
我让它运行正常,但它全天随机地报告以下内容:
haproxy[12947]: backend app_backend has no server available!
HA 代理日志文件:
Nov 5 [12947]: Server app_backend/web-live is DOWN, reason: Layer4 timeout, check duration: 2001ms. 0 active and 1 backup servers left. Running on backup. 11 sessions active, 0 requeued, 0 remaining in queue.
Nov 5[12947]: Backup Server app_backend/web-backup is DOWN, reason: Layer4 timeout, check duration: 2001ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Nov 5[12947]: backend app_backend has no server available!
访问前端时显示 503 错误,然后在几秒钟内一切又恢复正常。
我的 HA 代理配置:
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
frontend tm_application
bind *:80
mode http
option forwardfor
default_backend app_backend
backend app_backend
mode http
balance roundrobin
option forwardfor
option httpchk
server web-live xx.xx.xx.xx:80 check
server web-backup xx.xx.xx.xx:80 check backup
有人能指出我哪里出了问题吗?对我来说,它似乎正在尝试检查 2000 毫秒,但由于服务器响应,它可能会失败?
更新我尝试添加 4 秒的检查间隔,但最终还是出现同样的错误 :-/
帮助 :-(