Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use HAProxy

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly analyzes how to achieve the installation and use of HAProxy related knowledge points, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about how to install and use HAProxy.

HAProxy provides high availability, load balancing and agents based on TCP and HTTP applications, and supports virtual hosts. It is a free, fast and reliable solution. Let's explain the installation and use of HAProxy in detail.

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. 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` # display haproxy compilation and startup information haproxy-vv on "how to achieve the installation and use of HAProxy" is introduced here, more related content can be searched for previous articles, hope to help you answer questions, please support the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report