1.下载
https://src.fedoraproject.org/repo/pkgs/haproxy/
2.解压
mv haproxy-1.8.25.tar.gz /usr/local
tar -zxvf haproxy-1.8.25.tar.gz
3.查看linux版本
uname -r
4.查看README文件,选择适合TARGET
- linux22 for Linux 2.2
- linux24 for Linux 2.4 and above (default)
- linux24e for Linux 2.4 with support for a working epoll (> 0.21)
- linux26 for Linux 2.6 and above
- linux2628 for Linux 2.6.28, 3.x, and above (enables splice and tproxy)
- solaris for Solaris 8 or 10 (others untested)
- freebsd for FreeBSD 5 to 10 (others untested)
make TARGET=linux2628
5、编译完成之后,开始进行安装
make install PREFIX=/usr/local/haproxy
6、安装完成之后,创建目录,创建HAProxy配置文件
mkdir -p /usr/data/haproxy
mkdir /usr/local/haproxy/conf
vi /usr/local/haproxy/conf/haproxy.conf
7、向配置文件中添加配置信息
global
log 127.0.0.1 local0
#log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
chroot /usr/local/haproxy
pidfile /usr/data/haproxy/haproxy.pid
uid 99
gid 99
daemon
#debug
#quiet
defaults
log global
mode tcp
option abortonclose
option redispatch
retries 3
maxconn 2000
timeout connect 5000
timeout client 50000
timeout server 50000
listen proxy_status
bind :48066
mode tcp
balance roundrobin
server mycat_1 192.168.85.111:8066 check inter 10s
server mycat_2 192.168.85.112:8066 check inter 10s
frontend admin_stats
bind :7777
mode http
stats enable
option httplog
maxconn 10
stats refresh 30s
stats uri /admin
stats auth admin:123123
stats hide-version
stats admin if TRUE
8、启动haproxy服务
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.conf
9、查看haproxy的进程,如果存在则说明没有问题
ps -ef | grep haproxy
10、打开浏览器访问,用户名为admin,密码为123123
http://192.168.85.113:7777/admin