centos7 编译安装haproxy2.4.13

编译安装

yum install gcc pcre-static pcre-devel systemd-devel -y
http://www.haproxy.org/download/2.4/src/haproxy-2.4.13.tar.gz -O ~/haproxy.tar.gz
tar xzvf ~/haproxy-2.4.13.tar.gz -C ~/
cd ~/haproxy-2.4.13
make TARGET=linux-glibc USE_PROMEX=1 USE_OPENSSL=0 USE_SYSTEMD=1 #haproxy2.4.+版本使用
make install
mkdir -p /etc/haproxy
mkdir -p /var/lib/haproxy
touch /var/lib/haproxy/stats
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
#cp examples/haproxy.init /etc/init.d/haproxy
#chmod 755 /etc/init.d/haproxy
cd admin/systemd
make haproxy.service
cp haproxy.service /usr/lib/systemd/system/
vi haproxy.service
LimitNOFILE=1024000
LimitNPROC=1024000

systemctl daemon-reload
useradd -r haproxy
haproxy -v
systemctl enable haproxy.service

开启日志

vi /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
local0.* /var/log/haproxy/haproxy.log
service rsyslog restart

增加web状态及prometheus metrics

frontend haproxy_status
   bind *:8100
   mode http
   option httplog
   option http-use-htx
   http-request use-service prometheus-exporter if { path /metrics }
   stats enable
   stats uri /status
   stats refresh 10s

防火墙

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-port=8181/tcp
sudo firewall-cmd --reload

web管理

http://<load balancer public IP>:<http_front port>/haproxy?stats

web管理加密(http://ip:8181)

listen stats
  bind *:8181
  stats enable
  stats uri /
  stats realm Haproxy\ Statistics
  stats auth username:password

TCP配置

vi /etc/haproxy/haproxy.cfg
global
   log 127.0.0.1 local0 info
   chroot /var/lib/haproxy
   stats timeout 30s
   user haproxy
   group haproxy
   daemon

# turn on stats unix socket
#stats socket /var/lib/haproxy/stats mode 600 level admin

defaults
   log global
   mode http
   option httplog
   option dontlognull
   maxconn 256000
   timeout connect 5000
   timeout client 50000
   timeout server 50000

listen stat
    bind 0.0.0.0:8888
    mode http
    http-request use-service prometheus-exporter if { path /metrics }
    stats enable
    stats refresh 30s
    stats uri /stats
    stats realm Haproxy\ Statistics
    stats auth admin:eufkfonlfjls
    #stats hide-version

listen F2B-prod-ext-80
    bind *:10080
    mode tcp
    balance roundrobin
    option tcplog
    server f2b-prod-ext-kunlun 10.9.144.245:80 maxconn 100000 check inter 5s weight 10
    #server f2b-prod-ext-penglai 10.9.165.198:80 maxconn 100000 check inter 5s weight 10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

StarsL.cn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值