Http://blog.csdn.net/mahongming/article/details/6048947
Introduction
Haproxy is a proxy software that provides high availability, Server Load balancer, and TCP and HTTP applications, haproxy is a completely free proxy solution that provides TCP and HTTP applications quickly and reliably with haproxy. Haproxy is applicable to websites with large loads. These sites usually need session persistence or layer-7 processing. Haproxy supports tens of thousands of concurrent connections, and the haproxy running mode enables it to be easily and securely integrated into the architecture, while protecting Web servers from being exposed to the network.
Installation and Management
Installation Software selection instructions
Software |
Version |
Haproxy |
1.4.9 |
1) The installation steps are as follows: Upload the software to the/OPT folder.
CD/OPT Tar zxvf haproxy-1.4.9.tar.gz CD haproxy-1.4.9 Make target = linux26 prefix =/OPT Make install prefix =/OPT |
2) haproxy Management
If haproxy has been configured, start
CD/opt/haproxy/sbin ./Haproxy-F haproxy. cfg |
Enter the user name and password, and monitor the status on the following page.
Http://x.x.x.x: 1080/haproxy-Stats |
Add the haproxy startup command to the/etc/rc. Local file, as shown in figure
/Opt/haproxy/sbin/haproxy-F haproxy. cfg |
Configuration Optimization
1) haproxy configuration optimization instructions
Parameter configuration example |
Rule Description |
Maxconn 32768 |
Max connections |
Daemon |
We recommend that you start the instance in daemon mode. |
Nbproc 8 |
Number of concurrent processes of Server Load balancer |
Retries 3 |
Number of Retries |
|
|
2) haproxy configuration (haproxy. cfg) Example
Create a configuration file
CD/opt/haproxy Touch haproxy. cfg |
Configuration example
Global Log 127.0.0.1 local0 Maxconn 4096 Chroot/opt/haproxy # Uid WWW # GID WWW UID 0 GID 0 Daemon Nbproc 2 Pidfile logs/haproxy. PID # Debug # Quiet Ults Log 127.0.0.1 local3 Mode HTTP Option httplog Option httpclose Option dontlognull Option forwardfor Option redispatch Retries 2 Maxconn 2000 Balance roundrobin Stats enable Stats uri/haproxy-Stats Contimeout 5000 Clitimeout 50000 Srvtimeout 50000 Listen web_proxy 0.0.0.0: 1080 Option httpchk get/ping. jsp Server S1 192.168.15.110: 8080 weight 3 check Server S3 192.168.15.111: 8080 weight 3 check Listen mysql_proxy 0.0.0.0: 3306 Server S1 192.168.15.110: 3306 weight 3 check Server S3 192.168.15.111: 3306 weight 3 check |