赞
踩
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
目录
提示:以下是本篇文章正文内容,下面案例可供参考
HAPROXY 192.168.115.212 WEB1 192.168.115.211 WEB2 192.168.115.210
wget https://www.haproxy.org/download/1.7/src/haproxy-1.7.2.tar.gz
tar xf haproxy-1.7.2.tar.gz
cd haproxy-1.7.2
- vim /etc/haproxy/haproxy.haproxy.cfg
- global
- daemon
- maxconn 256
- pidfile /var/run/haproxy/haproxy.pid
-
-
- defaults
- mode http
- timeout connect 5000ms
- timeout client 50000ms
- timeout server 50000ms
-
-
- frontend http-in
- bind *:80
- default_backend servers
-
-
- backend servers
- server server1 192.168.115.211:80 maxconn 32
- server server2 192.168.115.210:80 maxconn 32
2 WEB1、2写访问文件
web1
echo web1 > /var/www/html/index.html
web2
echo web1web2 > /var/www/html/index.html
systemctl daemon-reload
systemctl restart haproxy
global
daemon
maxconn 256
pidfile /var/run/haproxy/haproxy.pid
defaults
mode tcp
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend servers
backend servers
server server1 192.168.115.211:80 maxconn 32
server server2 192.168.115.210:80 maxconn 32
balance roundrobin
#balance source
重启haproxy
service haproxy start
service haproxy stop
service haproxy restart | reload
也可以使用systemctl进行启停
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。