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

Detailed description of the configuration file of haproxy of centos 7 and hapro

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Although HAProxy has HA before its name, it is not a highly available software, but a software used to achieve load balancing, which can achieve load balancing between four and seven layers.

About the common scheduling algorithms of haproxy, you can refer to the blog post: scheduling algorithms supported by Haproxy.

For the detailed configuration process and configuration log records of haproxy, please refer to the blog article: keepalived+Haproxy to build a highly available Web cluster.

This blog post does not talk about how to configure haproxy, but mainly about its configuration file description and parameter tuning in the production environment.

The configuration file for haproxy is usually divided into three parts: global, defaults, and listen. Global configuration, default

Recognize configuration and apply component configuration.

Global configuration:

Global log 127.0.0.1 local # configure logging. Local0 is the logging device, which is stored in the system log by default. Log 127.0.0.1 local1 notice # notice is the log level, and there are usually 24 levels # log loghost local0 info maxconn 4096 # maximum number of connections chroot / usr/share/haproxy # the root directory set by the service Generally, you need to comment out this line uid 99 # user UID gid 99 # user GID daemon # daemon mode

The default configuration parameters of defaults configuration items are generally inherited by the application component. If there is no special declaration in the application component, the default configuration parameters will be installed:

Defaults log global # defines logs as logs in global configuration defines mode http # mode as http option httplog # logs are recorded in http log format option dontlognull retries 3 # check node server failures, up to three consecutive failures It is considered that the node is unavailable redispatch # when the server load is high Automatically end long-processed connections in the current queue maxconn 2000 # maximum number of connections contimeout 5000 # connection timeout clitimeout 50000 # client timeout srvtimeout 50000 # server timeout

Listen configuration items: general configuration application module parameters:

Listen appli4-backup 0.0.0.0 listen appli4-backup 10004 # defines an application called appli4-backup / index.html # to check the server's index.html file option persist # to force the request to be sent to a server that has already dropped down. This option is generally disabled. Balance roundrobin # load balancing scheduling algorithm uses polling algorithm server inst1 192.168.114.56 check inter 80 check inter 2000 fall 3 # defines an online node server inst2 192.168.114.56 check inter 81 check inter 2000 fall 3 backup # defines a backup node # Note: among the parameters that define the backup node above, # "check inter 2000" represents a heartbeat rate between the haproxy server and the node # "fall 3" means that the node fails if the heartbeat rate is not detected for three times in a row. The configuration of a # node with "backup" means that the node is only a backup node, and it will only be installed if the primary node fails. # remove backup, which means that the master node provides services together with other master nodes.

Parameter tuning of haproxy:

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

Servers

Wechat

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

12
Report