HAProxy提供高可用性、負載均衡以及基於TCP和HTTP應用的代理,支持虛擬主機,它是免費、快速並且可靠的一種解決方案 |
HAProxy提供高可用性、負載均衡以及基於TCP和HTTP應用的代理,支持虛擬主機,它是免費、快速並且可靠的一種解決方案。HAProxy特別適用於那些負載特大的web站點,這些站點通常又需要會話保持或七層處理。HAProxy運行在當前的硬件上,完全可以支持數以萬計的併發連接。並且它的運行模式使得它可以很簡單安全的整合進您當前的架構中, 同時可以保護你的web服務器不被暴露到網絡上。
docker pull haproxy
mkdir /docker/haproxy-master/ touch /docker/haproxy-master/haproxy.cfg
defaults mode tcp log global option tcplog option dontlognull option http-server-close 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 mysql bind 0.0.0.0:13307 mode tcp log global default_backend mysql_server backend mysql_server balance roundrobin server mysql1 192.168.228.131:3307 check inter 5s rise 2 fall 3 server mysql2 192.168.228.131:3308 check inter 5s rise 2 fall 3 listen stats mode http bind 0.0.0.0:1080 stats enable stats hide-version stats uri /haproxyamdin?stats stats realm Haproxy\ Statistics stats auth admin:admin stats admin if TRUE
1080端口爲可視化界面
docker run -p 1080:1080 -p 13307:13307 -d --name haproxy-master -v /docker/haproxy-master/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg --privileged=true haproxy
可以看到訪問不同的server_id。
本文地址:https://www.linuxprobe.com/installation-haproxy-docke.html