centos7 安装 Haproxy
下载 haproyx2.1.0
1
| wgete https://hekr-files.oss-cn-shanghai.aliyuncs.com/soft/haproxy/haproxy-2.1.0.tar.gz
|
解压
1
| tar -xvf haproxy-2.1.0.tar.gz
|
安装
为了支持 SSL ,必须安装 OpenSSL: yum -y install openssl-devel.x86_64
编译:
1 2
| cd haproxy-2.1.0 make -j $(nproc) TARGET=linux-glibc USE_RT=1 ARCH=x86_64 USE_OPENSSL=1 ADDLIB=-lz USE_LINUX_TPROXY=1 USE_ZLIB=1
|
如果报错:(只有在内核低于3.0才会发生):
1
| A raw syscall is useless, setns() is only supported in linux >= 3.0.
|
则需要指定参数: USE_NS=
保存以下配置到配置文件 haproxy.cfg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| global ulimit-n 10400009 maxconn 99999 maxpipes 99999 tune.maxaccept 500 log 127.0.0.1 local0 log 127.0.0.1 local1 notice
defaults log global mode http option dontlognull timeout connect 5000ms timeout client 50000ms timeout server 50000ms
listen mqtt mode tcp bind *:1883 option tcplog balance leastconn server node_1 10.10.164.229:1883 check option clitcpka timeout client 3h timeout server 3h option tcplog
|
启动
./haproxy -f haproxy.cfg