How to install HAProxy and HAProxy commands in CentOS
1. Install HAProxy
CentOS comes with haproxy, but the version may be old. You can find the latest stable version of haproxy on the IUS source.
Cat <eof>/etc/yum. repos. d/ius. repo
[Ius]
Name = iusrepo
Baseurl = https://mirrors.tuna.tsinghua.edu.cn/ius/stable/centos/?releasever/##basearch
Gpgcheck = 0
Enable = 1
Eof
Yum-y install haproxy17u
The following is the process of compiling and installing the haproxy-1.7.10.
During the compilation and installation of haproxy, you can use the pcre environment. In this environment, the Compilation speed will be much faster with the help of regular expressions, but it can also be installed without this environment.
Yum-y install pcre-devel
Tar xf haproxy-1.7.10.tar.gz
Cd haproxy-1.7.10
Make TARGET = linux2628 ARCH = x86_64 PREFIX =/usr/local/haproxy USE_PCRE = 1
Make install PREFIX =/usr/local/haproxy
You must use TARGET to specify the kernel and version. The version is as follows:
-Linux22 for Linux 2.2
-Linux24 for Linux 2.4 and above (default)
-Linux24e for Linux 2.4 with support for a working epoll (> 0.21)
-Linux26 for Linux 2.6 and above
-Linux2628 for Linux 2.6.28, 3.x, and above (enables splice and tproxy)
-Solaris for Solaris 8 or 10 (others untested)
-Freebsd for FreeBSD 5 to 10 (others untested)
-Netbsd for NetBSD
-Osx for Mac OS/X
-Openbsd for OpenBSD 5.7 and above
-Aix51 for AIX 5.1
-Aix52for AIX 5.2
-Cygwin for Cygwin
-Haiku for Haiku
-Generic for any other OS or version.
-Custom to manually adjust every setting
Use ARCH to specify the architecture, but the ARCH option can be saved. The use of USE_PCRE = 1 indicates that the PCRE environment is used for compilation to speed up compilation.
After compilation and installation, there are only three directories: doc, share, and sbin. There is only one haproxy main program haproxy in sbin. To facilitate management of haproxy services, copy/etc/init. d/haproxy from haproxy installed in yum.
2. HAProxy command
Frequently used:
# Check the Configuration File Syntax
Haproxy-c-f/etc/haproxy. cfg
# Start in daemon mode and in daemon mode managed by systemd
Haproxy-D-f/etc/haproxy. cfg [-p/var/run/haproxy. pid]
Haproxy-Ds-f/etc/haproxy. cfg [-p/var/run/haproxy. pid]
# Enable the debugging function to display all connection and processing information on the screen.
Haproxy-d-f/etc/haproxy. cfg
# Restart. You must use the st option to specify the pid list.
Haproxy-f/etc/haproxy. cfg [-p/var/run/haproxy. pid]-st 'cat/var/run/haproxy. Pi'
# Graceful restart, that is, reload. You need to use the sf option to specify the pid list
Haproxy-f/etc/haproxy. cfg [-p/var/run/haproxy. pid]-sf 'cat/var/run/haproxy. pid'
# Show haproxy compilation and startup information
Haproxy-vv
Build highly available cluster Keepalived + Haproxy Load Balancing https://www.bkjia.com/Linux/2016-12/138917.htm
Basic configuration of HAproxy (Load Balancing + Log independence + Dynamic and Static separation + read/write separation) https://www.bkjia.com/Linux/2017-03/141614.htm
Https://www.bkjia.com/Linux/2017-03/141593.htm for Keepalived + HAProxy configuration under CentOS 7
Https://www.bkjia.com/Linux/2016-12/138749.htm for reverse proxy and load balancing with HAproxy
HAProxy + Keepalived for high-availability Load Balancing https://www.bkjia.com/Linux/2016-06/132225.htm
Configure the HTTP Load balancer https://www.bkjia.com/Linux/2015-01/112487.htm with HAProxy
Ubuntu 16.04 installation HAProxy 1.5.11 tcp load balancing https://www.bkjia.com/Linux/2016-06/132689.htm
CentOS 7.2 deploy Haproxy 1.7.2 https://www.bkjia.com/Linux/2017-10/147553.htm
For details about HAproxy, click here
HAproxy: click here
This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151322.htm