HAProxy-1.8.x version of source Compiler

 Source compiler HAProxy:  

 HAProxy official website to download the package and extract the package, switch to the package directory haproxy

[[email protected]]#tar xvf haproxy-1.8.20.tar.gz && cd haproxy-1.8.20

 Installation dependent packages

[[email protected]]#yum install gcc gcc-c++ glibc glibc-devel pcrepcre-devel openssl openssl-devel systemd-devel net-tools vim iotopbczip unzip zlib-devellrzsztree screen lsof tcpdump wget ntpdate

  Start compiling

[[email protected]]#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

  Specify the installation path

[[email protected]]#make install PREFIX=/usr/local/haproxy

  Haproxy copy the executable program under the / usr / sbin / directory

[[email protected]]#cp haproxy  /usr/sbin/

 Creating haproxy startup script 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   -c -q
ExecStart=/usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg   -p /run/haproxy.pid
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

 Create a startup script directory

[root@centos_17haproxy]#mkdir /etc/haproxy

Haproxy service startup directory and create a basic configuration file

[root@centos_17haproxy]#vim /etc/haproxy/haproxy.cfg 
global
maxconn 100000
chroot /usr/local/haproxy
#stats socket /var/lib/haproxy/haproxy.sock mode 600 level admin
user haproxy
group haproxy
daemon
nbproc 2 binding two cpu to open the following two binding on four open four
cpu-map 1 0
cpu-map 2 1
#cpu-map 3 2
#cpu-map 4 3
pidfile /usr/local/haproxy/run/haproxy.pid
log 127.0.0.1 local3 info

defaults
option http-keep-alive
option  forwardfor
maxconn 100000
mode http
timeout connect 300000ms
timeout client  300000ms
timeout server  300000ms

listen stats
 mode http
 bind 0.0.0.0:9999
 stats enable
 log global
 stats uri     /haproxy-status
 stats auth    haadmin:q1w2e3r4ys

listen  web_port
 bind 0.0.0.0:80
 mode http
 log global
 server web1  127.0.0.1:8080  check inter 3000 fall 2 rise 5

 Haproxy create a user and set the shell for the type of system can not log

[root@centos_17haproxy]#useradd -s /sbin/nologin haproxy

 Start haproxy Service

[root@centos_17haproxy]#systemctl start haproxy

 Haproxy started threads View

[Root @ centos_17haproxy] #ps -ef | grep haproxy can see that at this time the user name is nobody to start two threads, and all belong to a parent process
root 13270 1 0 21:59 ? 00:00:00 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
haproxy 13272 13270 0 21:59 ? 00:00:00 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
haproxy 13273 13270 0 21:59 ? 00:00:00 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
root 13278 12621 0 21:59 pts/0 00:00:00 grep --color=auto haproxy

Guess you like

Origin www.cnblogs.com/struggle-1216/p/12078430.html