Haproxy The log is not logged by default, and the configuration file for the system log is required, in addition to specifying the output of the log in the global segment in haproxy.conf. Take centos6.4 as an example, Haproxy uses the system's own RPM newspaper version 1.4
After installing Haproxy, the log is logged by default in the System log. In order to make it easier to debug and view the logs, we need to peel off the haproxy logs. Before configuring, let's first understand the level:local0~local7 of the log 16~23 reserved for local use 1
Background introduction:By default, the Haproxy configuration does not generate log files, without running logs, to determine whether the system is running smoothly and cannot initiate a pre-judgment failure
To create the Haproxy log file, follow these stepsVi/etc/rsyslog.confUncomment the following 2 lines:$ModLoad
I like it very much;
5. HAProxy supports virtual hosts.
The following describes how to use Haproxy as the Server Load balancer:Current Environment:
Ubuntu16.04 + Haproxy 192.168.93.21Centos6 + httpd 192.168.93.5Centos6 + httpd 192.168.93.7
Haproxy configuration file
Vi/etc/haproxy
algorithm, this algorithm is used for some session sessions recorded on the server side of the scene, can be based on the source of IP, cookies, etc. to do the cluster scheduling. For example, using the cluster scheduling algorithm based on the source IP, there are three nodes a, B, C, the first user first access is assigned to a, the second user first access is assigned to B, when the first user will be assigned to a second visit, the second user will still be assigned to the second access to
Install the haproxy and haproxy commands and the haproxy commands
Directory:1. Install haproxy2. haproxy command
1. Install haproxy
CentOS comes with haproxy, but the version may be old. You can find the latest stable version of
/sbin/nologin2. Configuration File 1) Detailed description of the configuration file
# There are no configuration files in the default installation directory. There are only three directories, "doc", "sbin", and "share". You can create directories and configuration files manually; # haproxy configuration file is mainly the following five parts: global configuration, ults default configuration, monitoring page configuration, frontend configuration, ba
a cache. However, this algorithm is not smooth, and requests distributed to servers may not achieve an ideal balance. Therefore, you may need to adjust the weights of servers from time to achieve a better balance.
5Keyword log
Log Enables event and traffic logs for each instance, so it can be used for all segments. A maximum of two log parameters can be specifi
wants to connect to the database internally, it should be implemented through haproxy.
In actual business scenarios, access to port 8099 of 192.168.5.171 is to access port 3306 of 192.168.7.7.
Ii. Configuration
Haproxy
Because haproxy uses both Layer 7 and Layer 4, we do not define the haproxy running mode in ults.
cluster configuration, is a real server, a backend corresponding to one or more entity servers
5. Combination of Listen fronted and backend
First, install the Haproxy
1. Download the latest Haproxy installation package, official website: http://www.haproxy.org, if you cannot access it, you can use the online proxy to access the download. Download: haproxy-1.5.
requires two features, the first being high performance, and the second being highly available.1. Test High PerformanceWhen the client uses the browser to open http://172.16.10.30/test.html, the browser displays information:Refresh and display the message:You can see that the cluster's load-balancing schedule takes effect to meet the high-performance requirements of the cluster.2. Test High AvailabilityDeactivate the 172.16.10.10 Nginx Server and open Http://172.16.10.30/test in the client usin
-1.4.8.tar.gz
Cd haproxy-1.4.8
Make TARGET = linux26; make install
# Here you can also write make TARGET = linux26 -- prefix =/usr/local/haproxy to add a path for haproxy installation.
Write the haproxy Configuration File. the master and slave files are the same. use this configuration file [plain] view plaincopyprint?
forwarding. This allows you to perform protocol validation instead of blindly forwarding. For example, allow SSL but deny SSH.
L More load balancing algorithms: Now, Dynamic weighted rotation (dynamical Round Robin), weighted source address hash (weighted source hash), weighted URL hash and weighted parameter hash (weighted Parameter hash) has been implemented. Other algorithms such as weighted measured Response time will also be implemented soon.
Installation and Configuration
The
-ZXVF haproxy-1.6.9.tar.gz#cd haproxy-1.6.9#make target=linux26 prefix=/usr/local/haproxy #此处TARGET =linux26 is to fill in the system kernel version uname-r, such as the version is 2.6.32-504.el6.x86_64, Fill in 26 directly.#make Install Prefix=/usr/local/haproxy#ls/usr/local/hapro
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.