我需要一些建議如何設置haproxy。我有兩個Web服務器已啓動並正在運行。爲了測試他們跑在8080端口上第4層「連接被拒絕」與haproxy
現在我HAProxy的服務器上的一個簡單的節點服務器,我開始HAProxy的,給了我如下:
$> /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg
[WARNING] 325/202628 (16) : Server node-backend/server-a is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 325/202631 (16) : Server node-backend/server-b is DOWN, reason: Layer4 timeout, check duration: 2001ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 325/202631 (16) : backend 'node-backend' has no server available!
只是一個提醒:如果我做的:
haproxy$> wget server-a:8080
我得到節點服務器的響應。
這裏是我的haproxy.cfg:
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode tcp
log global
option tcplog
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
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend www
bind *:80
default_backend node-backend
#---------------------------------------------------------------------
# round robin balancing between the various backends
#--------------------------------------------------------------------
backend node-backend
balance roundrobin
mode tcp
server server-a 172.19.0.2:8080 check
server server-b 172.19.0.3:8080 check
如果我刪除check
選項它似乎工作。任何建議如何我可以解決這個haproxy的檢查機制?
我雖然這L4使用'模式tcp'究竟設置。那麼究竟是什麼定義L4或L7? –
L4是第4層檢查(OSI模型)L7是第7層檢查。 因此L4會回覆狀態碼500,404,200,301等。 L7將查看請求返回的「內容」... http標頭,json字符串,結果體內的任何內容 –