haproxy 安装配置 centos 7

一个人想着一个人 提交于 2019-12-01 18:53:35

haproxy 安装配置 centos 7

yum install -y haproxy

##忽略VIP
echo "net.ipv4.ip_nonlocal_bind = 1" >>/etc/sysctl.conf
sysctl -p

cat > /etc/haproxy/haproxy.cfg << EOF
global 
    log 127.0.0.1 local3 info 
    chroot /var/lib/haproxy 
    user haproxy 
    group haproxy 
    daemon
defaults
    log global
    mode http
    option httplog
    option dontlognull
    timeout connect 5000
    timeout client 50000
    timeout server 50000
frontend k8s_api
    mode tcp
    bind *:16443
    default_backend k8s_api

backend k8s_api
    mode tcp
    balance roundrobin
    server k8s150 192.168.0.150:6443 check 
    server k8s151 192.168.0.151:6443 check 
   
listen stats
    mode http
    bind 0.0.0.0:1080
    stats enable
    stats hide-version
    stats uri /stats
    stats realm Haproxy\ Statistics
    stats auth admin:admin123
    stats admin if TRUE
EOF

systemctl enable haproxy.service 
systemctl restart haproxy.service 
systemctl status haproxy.service 
netstat -lnt | grep -E "16443|1080"

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!