I built the Tomcat+nginx load Balancer cluster, the LVM load Balancing cluster, I'm going to get a haproxy load Balancer cluster, the three clusters I have to realize the LVS performance is really good (DR) but in the construction process is too cumbersome, Nginx is the use of upstream module cluster but the cluster node failure check function is not enough performance and LVM is a bit far away, so today to a middle person haproxy.
One , build haproxy cluster
1. Experimental topology
2. Virtual machine Environment (centos6.5 environment)
One haproxy server, two Nginx servers, build two websites that feed back different content, and a client (same network segment of the environment) to test
3. Experimental steps
1) Compile and install Haproxy
First install two support packages Pcre-devel, Bzip-devel
Compile and install Haproxy (version 1.4 I used)
2) Copy the configuration file to the/etc/haproxy directory
Modifying the Haproxy.cfg configuration file
3) Create a self-starter script
4) Install Nginx and make Web page
[Email protected] ~]# yum-y install Pcre-devel zlib-devel
[Email protected] ~]# tar zxf nginx-1.6.2.tar.gz
[Email protected] ~]# CD nginx-1.6.2
[Email protected] nginx-1.6.2]#/configure--prefix=/usr/local/nginx--user=nginx--group=nginx && Make & & Make Install
[Email protected] nginx-1.6.2]# useradd-m-s/sbin/nologin nginx
[Email protected] nginx-1.6.2]ln-s/usr/local/nginx/sbin/*/usr/local/sbin/
[[email protected] nginx-1.6.2] #echo "Node_1" >/usr/local/nginx/htmlindex.html
Start Nginx Service
[Email protected] nginx-1.6.2]# Nginx
shutting down the firewall
Iptables-f
First Test native effect
Second Test native effect (off firewall)
5) Open Haproxy Service
6) Testing the Web cluster
Load Balancing First Test
Enter the Haproxy IP address test on the client
Open a second
The following test is highly available, we turn off one of the analog faults if the webpage continues to open indicating high availability no problem
7) Configure Haproxy Log
It is not very convenient for haproxy logs to be saved in syslog by default, so we can store the logs separately in different files in a working environment.
First modify the configuration file:
The purpose of these two lines is to record the info and notice logs in separate files
Then modify the Rsyslog configuration to independently define the Haproxy related profile to haproxy.conf and store it under/ETC/RSYSLOG.D, and the Rsyslog will automatically load all the configuration files under the directory when it is started.
Add the following content:
The following content stores info and notice logs in different files
Start the Rsyslog service
Test log information
After the client accesses, the access records can be queried back to the Haproxy server
Haproxy load balancing and building a Web cluster