Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of HAProxy

Shulou Source: shulou.com Published: 2022-06-01 13:41:36 10月02日 Update

This article mainly introduces the example analysis of HAProxy, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

HAProxy is an agent software that provides high availability, load balancing and applications based on TCP (layer 4) and HTTP (layer 7). It supports virtual hosts. It is a free, fast and reliable solution. HAProxy is especially suitable for heavily loaded web sites, which usually require session persistence or seven-tier processing. HAProxy runs on today's hardware and can support tens of thousands of concurrent connections.

1. Install haproxy

CentOS comes with haproxy, but the version may be older. The latest stable version of haproxy can be found on the IIS source.

Cat / yum.repos.d/ius.repo [ius] name=iusrepobaseurl= https://mirrors.tuna.tsinghua.edu.cn/ius/stable/CentOS/$releasever/\$basearchgpgcheck=0enable=1eofyum-y install haproxy17u

The following is the process of compiling and installing haproxy-1.7.10.

When compiling and installing haproxy, you can rely on the pcre environment, where the compilation speed is much faster with the help of regular expression analysis, but it can be installed without this environment.

Yum-y install pcre pcre-develtar xf haproxy-1.7.10.tar.gzcd haproxy-1.7.10make TARGET=linux2628 ARCH=x86_64 PREFIX=/usr/local/haproxy USE_PCRE=1make install PREFIX=/usr/local/haproxy

When make, you need to use TARGET to specify the kernel and version, which are 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.283.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-aix52 for 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 schema, but the ARCH option is saved. Using USE_PCRE=1 means to compile in a PCRE environment to speed up the compilation.

After the compilation and installation is complete, there are only three directories: doc, share, and sbin,sbin. There is only one haproxy main program, haproxy. To facilitate the management of haproxy services, you can copy / etc/init.d/haproxy from the haproxy installed by yum.

2.haproxy command

Several commonly used ones:

# check the configuration file syntax haproxy-c-f / etc/haproxy/haproxy.cfg# starts in daemon mode, starts haproxy-D-f / etc/haproxy/haproxy.cfg [- p / var/run/haproxy.pid] haproxy-Ds-f / etc/haproxy/haproxy.cfg [- p / var/run/haproxy.pid] # in systemd managed daemon mode, and all connection and processing information will be displayed on the screen haproxy-d-f / etc/haproxy/haproxy.cfg# restart. You need to use the st option to specify the pid list haproxy-f / etc/haproxy.cfg [- p / var/run/haproxy.pid]-st `cat / var/run/ haproxy.pid` # graceful restart, namely 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` # to display the haproxy compilation and startup information haproxy-vv thank you for reading this article carefully. I hope the article "sample Analysis of HAProxy" shared by the editor will be helpful to you. At the same time, I hope you will support it and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Compilation environment article analysis version support example information only pattern site speed processing management balance downloader host main program value interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple macOS Microsoft Shulou Information