标签:apt min syslogd reload install systemctl 基础 can hub
Use docker、package or source installations to install
第三方仓库 https://pkgs.org/download/haproxy
docker run -it --rm haproxy:2.2 haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg
docker run -d --name my-running-haproxy -v /apps/etc/haproxy:/usr/local/etc/haproxy:ro --sysctl net.ipv4.ip_unprivileged_port_start=0 haproxy:2.2
docker run -d --name my-running-haproxy -v /apps/etc/haproxy:/usr/local/etc/haproxy:ro haproxy:2.2
# Reloading config
docker kill -s HUP my-running-haproxy
# apt-get install --no-install-recommends software-properties-common
# add-apt-repository ppa:vbernat/haproxy-2.2
# apt update && apt-cache madison haproxy
# apt-get install haproxy=2.2.\*
# haproxy -v
# haproxy -vv
dnf -y install systemd-devel
wget https://www.haproxy.org/download/2.2/src/haproxy-2.2.13.tar.gz
tar xf haproxy-2.2.13.tar.gz -C /usr/local/src
cd /usr/local/src/haproxy-2.2.13/
# less INSTALL
make ARCH=x86_64 TARGET=linux-glibc USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_SYSTEMD=1 USE_LUA=1 LUA_INC=/usr/local/src/lua-5.4.3/src/ LUA_LIB=/usr/local/src/lua-5.4.3/src/
make install PREFIX=/apps/haproxy
ln -s /usr/local/src/haproxy-2.2.13/haproxy /usr/sbin/
# haproxy -v
# haproxy -vv
PS: 升级lua到5.4.3
yum install gcc readline-devel systemd-devel
# apt install gcc iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev openssh-server libreadline-dev libsystemd-dev
# apt install lua5.3=5.3.3
curl -R -O http://www.lua.org/ftp/lua-5.4.3.tar.gz
tar zxf lua-5.4.3.tar.gz -C /usr/local/src
cd lua-5.4.3/
make all test
http://cbonte.github.io/haproxy-dconv/2.2/configuration.html
0 root@centos7:~# cat /usr/lib/systemd/system/haproxy.service
[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target
[Service]
ExecStart=/usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /var/lib/haproxy/haproxy.pid
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start haproxy
#---------------------------------------------------------------------
# Global settings HA-Proxy version 2.2.13-5f3eb59 2021/04/02 - https://haproxy.org/
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the ‘-r‘ option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen status_page
bind 0.0.0.0:8888
stats enable
stats uri /status
stats auth admin:123465
stats auth user:123465
stats realm "Welcome to the haproxy load balancer status page"
stats hide-version
#stats admin if TRUE
stats refresh 5s
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
bind :80
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 127.0.0.1:2000 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server app1 127.0.0.1:2000 check
server app2 127.0.0.1:2001 check
server app3 127.0.0.1:2002 check
server app4 127.0.0.1:5004 check
# /etc/haproxy# haproxy -v
HA-Proxy version 2.2.13-5f3eb59 2021/04/02 - https://haproxy.org/
Status: long-term supported branch - will stop receiving fixes around Q2 2025.
Known bugs: http://www.haproxy.org/bugs/bugs-2.2.13.html
Running on: Linux 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
Haproxy-1.8.20 编译安装: https://www.cnblogs.com/zhenxing06/p/12775659.html
如何在Ubuntu系统中编译安装HAProxy https://www.yisu.com/zixun/4383.html
标签:apt min syslogd reload install systemctl 基础 can hub
原文地址:https://www.cnblogs.com/firewalld/p/14715676.html