sudo groupadd haproxy
sudo useradd -g haproxy haproxy -s /sbin/nologin
wget https://github.com/haproxy/haproxy/archive/v1.9.0.tar.gz
tar -xzvf v1.9.0.tar.gz
cd haproxy-1.9.0/
make TARGET=linux2628 ARCH=x86_64 PREFIX=/usr/local/haproxy
sudo make install PREFIX=/usr/local/haproxy
/usr/local/haproxy/etc/ha.cfg
global
maxconn 1024
pidfile /usr/local/haproxy/etc/haproxy.pid
user haproxy
group haproxy
chroot /usr/local/haproxy
log /usr/local/haproxy/log/haproxy.log local2 info
defaults
log 127.0.0.1 local2 info
mode tcp
option tcplog
timeout client 30000ms
timeout connect 3000ms
timeout server 30000ms
listen test
bind 0.0.0.0:2000
mode tcp
server s1 127.0.0.1:2001 check send-proxy
server s2 127.0.0.1:2002 check send-proxy
log 127.0.0.1 local2
启动HAPROXY
/usr/local/haproxy/sbin/haproxy -f ./etc/ha.cfg