0
点赞
收藏
分享

微信扫一扫

haproxy 1.8.3 编译安装

慕容冲_a4b8 2022-07-12 阅读 57

1、安装必要的包

yum install gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel net-tools vim iotop bc zip unzip zlib-devel lrzsz tree screen lsof tcpdump wget ntpdate

2、关闭selinux 和防火墙:

sed -i '/SELINUX/s/enforcing/disabled/' /etc/sysconfig/selinux

systemctl status firewalld 

systemctl stop  firewalld 

systemctl disable firewalld 

3、tar xf haproxy-1.8.13.tar.gz   -C /usr/local/src/

cd haproxy-1.8.13;

注释:USE_CPU_AFFINITY=1 为开启haproxy 进程与cpu核心绑定,

USE_SYSTEMD=1 为支持使用 -Ws systemd-aware master-worker 模式,启动haproxy 

make ARCH=x86_64 TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_SYSTEMD=1 USE_CPU_AFFINITY=1 PREFIX=/usr/local/haproxy

​mkde install  PREFIX=/usr/local/haproxy

版本验证

[root@node03 haproxy-1.8.13]# /usr/local/haproxy/sbin/haproxy -v

HA-Proxy version 1.8.13 2018/07/30

Copyright 2000-2018 Willy Tarreau <willy@haproxy.org

4、cp haproxy /usr/sbin

vim /usr/lib/systemd/system/haproxy.service 

[Unit]    

Description=HAProxy Load Balancer

After=syslog.target network.target

[Service]

ExecStartPre=/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/conf  -c -q

ExecStart=/usr/sbin/haproxy -Ws    -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/conf -p /run/haproxy.pid          

ExecReload=/bin/kill -USR2 $MAINPID

[Install]

WantedBy=multi-user.target

5、vim /etc/haproxy/haproxy.cfg 

global

maxconn 100000

chroot /usr/local/haproxy

uid 99

gid 99

daemon

nbproc 1

stats socket /usr/local/haproxy/stats mode 600 level admin

log 127.0.0.1 local2 info                                                                                        


defaults

#option http-keep-alive

maxconn 100000

mode http

timeout connect 5000ms

timeout client  50000ms

timeout server 50000ms


listen stats

       mode http

       bind 0.0.0.0:9009

       stats enable

       stats uri     /haproxy-status

       stats auth    haadmin:123456

6、vim /etc/haproxy/conf/tomcat.cfg 

listen web_port

bind 192.168.100.100:80

mode http

log global

server 192.168.100.30 192.168.100.30:8080 check inter 3000 fall 2 rise 5

server 192.168.100.40 192.168.100.40:8080 check inter 3000 fall 2 rise 5 

7、systemctl start haproxy 

8、验证:

haproxy 1.8.3 编译安装_haproxy

haproxy 1.8.3 编译安装_haproxy_02

​​http://192.168.100.30:9009/haproxy-status​​

haproxy 1.8.3 编译安装_haproxy_03



举报

相关推荐

0 条评论