文档 . 2.4LTS
yum -y install gcc openssl-devel pcre-devel systemd-devel
make clean
make -j 4 TARGET=linux-glibc \
USE_OPENSSL=1 \
USE_ZLIB=1 \
USE_PCRE=1 \
USE_SYSTEMD=1
make install
[root@localhost ~]# cat /usr/lib/systemd/system/haproxy.service
[Unit]
Description=haproxy seriver
Documentation=http://www.haproxy.org/
After=network-online.target
Wants=network-online.target
[Service]
ExecStartPre=/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg -c
ExecStart=/usr/local/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
ExecReload=/bin/kill -USR2 $MAINPID
Restart=always
RestartSec=15
LimitNOFILE=65535
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
[root@localhost ~]# cat /etc/haproxy/haproxy.cfg
global
log /dev/log local1 warning
chroot /var/lib/haproxy
user root
group root
daemon
nbproc 1
defaults
log global
timeout connect 5s
timeout client 10m
timeout server 10m
listen kube-master
bind 0.0.0.0:6443
mode tcp
option tcplog
option dontlognull
option dontlog-normal
balance roundrobin
server 10.4.7.10 10.4.7.10:8443 minconn 50 maxconn 500 check inter 1000
server 10.4.7.11 10.4.7.11:8443 minconn 50 maxconn 500 check inter 1000
server 10.4.7.12 10.4.7.12:8443 minconn 50 maxconn 500 check inter 1000
listen registry
bind 0.0.0.0:5000
mode tcp
option tcplog
option dontlognull
option dontlog-normal
balance roundrobin
server 55.3.107.81 55.3.107.81:5000 check inter 10s fall 2 rise 2 weight 1
server 55.3.107.82 55.3.107.82:5000 check inter 10s fall 2 rise 2 weight 1 backup
listen haproxy-stats
bind 0.0.0.0:19000
mode http
stats enable
stats uri /stats
stats realm Haproxy\ Statistics
stats auth admin:Cc1020304050!