【haproxy】进行负载均衡配置

1, 测试环境:三台虚拟机190,191,192.分别安装均安装nginx端口设置为80,
2, 190上安装haproxy
# wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz
# tar zcvf haproxy-1.3.20.tar.gz
# cd haproxy-1.3.20
# make TARGET=linux26 PREFIX=/usr/local/haproxy #将haproxy安装到/usr/local/haproxy
# make install PREFIX=/usr/local/haproxy
修改/root/haproxy-1.3.15.10/example/haproxy.cfg文件
global
log 127.0.0.1 local3
maxconn 20480
chroot /usr/local/haproxy
uid 1004 #1004为haproxy 用户的uid ,haproxy用户需要自己手动创建
gid 1004
daemon
quiet
nbproc 1
pidfile /var/run/haproxy.pid
defaults
log global
mode http
maxconn 20480
option httplog
option httpclose
option forwardfor
option dontlognull
option redispatch
retries 3
balance roundrobin
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen web_poll 192.168.0.190:8081
mode http
option httplog
option dontlognull
option logasap
option forwardfor
option httpclose
# option httpchk GET /index.html 配置负载服务器访问信息
server web1 192.168.0.191:80 cookie 1 check inter 2000 rise 3 fall 3
server web2 192.168.0.192:80 cookie 1 check inter 2000 rise 3 fall 3
server web3 192.168.0.190:80 cookie 1 check inter 2000 rise 3 fall 3
#配置haproxy的状态监控页面
listen status 192.168.0.190:8080
stats enable
stats uri /stats
stats auth admin:123456
stats realm (Haproxy\ statistic)



开启:/usr/local/sbin/haproxy –f /root/haproxy-1.3.15.10/example/haproxy.cfg
关闭:killall haproxy
注意需要将防火墙关闭:chkconfig iptables off或者chkconfig iptables stop
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值