首页 > 代码库 > haproxy 的安装
haproxy 的安装
1.基础安装
yum install pcre pcre-devel openssl openssl-devel tar xf haproxy-1.7.1.tar.gz cd haproxy-1.7.1 make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 PREFIX=/usr/local/haproxy make install PREFIX=/usr/local/haproxy cd examples/ cp haproxy.init /etc/init.d/haproxy chmod +x /etc/init.d/haproxy
2.本机IP:192.168.56.15
[root@bogon examples]# cat /etc/haproxy/haproxy.cfg global maxconn 100000 chroot /usr/local/haproxy uid 99 gid 99 daemon nbproc 1 pidfile /usr/local/haproxy/logs/haproxy.pid log 127.0.0.1 local0 info defaults option http-keep-alive maxconn 100000 mode http timeout connect 300000ms timeout client 300000ms timeout server 300000ms listen stats mode http bind 0.0.0.0:9999 stats enable log global stats uri /haproxy-status stats auth haadmin:123456 listen web_port bind 0.0.0.0:80 mode tcp log global [root@bogon examples]# [root@bogon examples]# /etc/init.d/haproxy restart Restarting haproxy (via systemctl): [ OK ] [root@bogon examples]#
http://192.168.56.15:9999/haproxy-status
3.对后端代理
[root@bogon examples]# cat /etc/haproxy/haproxy.cfg global maxconn 100000 chroot /usr/local/haproxy uid 99 gid 99 daemon nbproc 1 pidfile /usr/local/haproxy/logs/haproxy.pid log 127.0.0.1 local0 info defaults option http-keep-alive maxconn 100000 mode http timeout connect 300000ms timeout client 300000ms timeout server 300000ms listen stats mode http bind 0.0.0.0:9999 stats enable log global stats uri /haproxy-status stats auth haadmin:123456 listen web_port bind 0.0.0.0:80 mode tcp #tcp的方式 log global server web1 192.168.56.12:80 check inter 2000 fall 15 rise 10 server web2 192.168.56.16:80 check inter 2000 fall 15 rise 10 [root@bogon examples]# /etc/init.d/haproxy restart #inter是监控检查时间间隔,即每间隔2秒进行一次检查, rise是连续检查10次失败后将服务器从负载删除, fall是连续15次监控检查成功后重新添加至负载,一般fall大于rise几次,
[root@bogon html]# curl 192.168.56.15 192.168.56.12 web1 [root@bogon html]# curl 192.168.56.15 192.168.56.16 web2 [root@bogon html]# curl 192.168.56.15 192.168.56.12 web1 [root@bogon html]# curl 192.168.56.15 192.168.56.16 web2 [root@bogon html]# curl 192.168.56.15 192.168.56.12 web1 [root@bogon html]# curl 192.168.56.15 192.168.56.16 web2 [root@bogon html]# curl 192.168.56.15 192.168.56.12 web1 [root@bogon html]# curl 192.168.56.15 192.168.56.16 web2 [root@bogon html]# curl 192.168.56.15 192.168.56.12 web1 [root@bogon html]# curl 192.168.56.15 192.168.56.16 web2 [root@bogon html]#
查看负载状况
本文出自 “砖家博客” 博客,请务必保留此出处http://wsxxsl.blog.51cto.com/9085838/1932814
haproxy 的安装
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。