下载安装haproxy-1.8.2.tar.gz
官网下载地址:https://www.haproxy.org/
解压haproxy-1.8.2.tar.gz
查看系统内核版本
查看安装的haproxy版本
创建系统服务启动方式(在源码包中的examples文件夹下拷贝,并相应修改内容)
vim /etc/init.d/haproxy修改相应的内容与之匹配
创建haproxy配置文件vim /etc/haproxy/haproxy.cfg
查看haproxy监控状态
官网下载地址:https://www.haproxy.org/
解压haproxy-1.8.2.tar.gz
tar -zxvf haproxy-1.8.2
查看系统内核版本
uname -r
make TARGET=linux2632 PREFIX=/usr/local/haproxy18
make install PREFIX=/usr/local/haproxy18
cp -rf /usr/local/haproxy18/sbin/haproxy /usr/sbin/
查看安装的haproxy版本
创建系统服务启动方式(在源码包中的examples文件夹下拷贝,并相应修改内容)
vim /etc/init.d/haproxy修改相应的内容与之匹配
创建haproxy配置文件vim /etc/haproxy/haproxy.cfg
global
log 127.0.0.1 local0
maxconn 4000
ulimit-n 80170
#uid 500
#gid 500
user xiaofeng #使用uid也可以
group xiaofeng
#chroot /usr/local/haproxy
nbproc 1
daemon
pidfile /usr/local/haproxy18/haproxy.pid
stats socket /var/run/haproxy.sock
# debug
# quiet
defaults
log 127.0.0.1 local3
mode http
option httplog
option httpclose
option dontlognull
option abortonclose
option forwardfor
option redispatch
retries 2
maxconn 2000
balance roundrobin
timeout connect 5000
timeout check 20000
timeout client 150000
timeout server 150000
listen stats
bind 0.0.0.0:10081
mode http
log 127.0.0.1 local0 err
stats uri /hastats
stats auth admin:admin
stats refresh 30s
stats hide-version
#option httpchk GET /Login.d
frontend http_80
option forwardfor
bind :80
mode http
maxconn 1500
log global
option httplog
# log the name of the virtual server
capture request header Host len 30
# log the beginning of the referrer
capture request header Referer len 50
acl test hdr_beg(host) -i test.proxy.com
use_backend zone_test if test
backend zone_test
mode http
option forwardfor
option httpchk GET / HTTP/1.1\r\nHost:test.proxy.com
server web01 192.168.0.103:80 check inter 9000 rise 3 fall 3
server web02 192.168.0.104:80 check inter 9000 rise 3 fall 3
启动haproxy服务service haproxy start查看haproxy监控状态
写的较好的haproxy博客和文档:
http://www.ttlsa.com/linux/haproxy-study-tutorial/
https://www.cnblogs.com/heiye123/articles/7928292.html
https://www.cnblogs.com/shanyou/archive/2012/10/16/2726768.html
http://blog.51cto.com/freeloda/1294094
https://www.cnblogs.com/zhangs1986/p/6517788.html