概述
1.下载安装包
2. 将安装包上传至本地目录
3.解压
tar xvf haproxy-1.5.19.tar.gz
4.创建haproxy安装目录
mkdir /usr/local/haproxy
5.编译并安装haproxy
cd /home/haproxy-1.5.19/
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
make install PREFIX=/usr/local/haproxy
6.为haproxy启动程序建立连接
ln -sv /usr/local/haproxy/sbin/haproxy /usr/sbin/
7.mkdir -p /var/lib/haproxy
8.编辑haproxy配置文件
vi /etc/haproxy/haproxy.cfg
global
chroot /usr/local/haproxy
pidfile /var/lib/haproxy/haproxy.pid
maxconn 3000
user root
group root
daemon
log 127.0.0.1 local3 infocd
stats socket /var/lib/haproxy/haproxy.sock
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 3s
timeout client 30s
timeout server 30s
timeout http-keep-alive 500
timeout check 3s
frontend https
bind *:443 ssl crt /etc/haproxy/****.pem
mode http
default_backend https
log global
backend https
mode http
balance source
log global
server r1 **** maxconn 1000 check inter 1000 fall 3 rise 3
server r2 **** maxconn 1000 check inter 1000 fall 3 rise 3
server r3 **** maxconn 1000 check inter 1000 fall 3 rise 3
9.创建haproxy启动文件
vi /usr/lib/systemd/system/haproxy.service
[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target
[Service]
ExecStartPre=/usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg -c -q
ExecStart=/usr/local/haproxy/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /var/lib/haproxy/haproxy.pid
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
10.复制haproxy配置文件
cp /etc/haproxy/haproxy.cfg /usr/local/haproxy/
11.启动haproxy
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
12.ps -ef确认haproxy启动成功
最后
以上就是精明冬天为你收集整理的haproxy编译安装的全部内容,希望文章能够帮你解决haproxy编译安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复