Install HAProxy 1.5.11 in Ubuntu 16.04 for tcp load balancing
The latest version of haproxy1.5.11 has been downloaded. The installation process is as follows:
1. Decompress haproxy-1.5.11.tar.gz: tar xzvf haproxy-1.5.11.tar.gz
2. Enter the extract Directory: cd haproxy-1.5.11
3. query the kernel version: uname-r. You can use cat README to check the version number of the compilation platform. The new Ubuntu version is linux2628.
4. source code compilation: sudo make TARGET = linux2628 PREFIX =/usr/local/haproxy pay attention to Case sensitivity. If it is changed to lower case, compilation fails or is not compiled to the specified path.
5. install: sudo make install PREFIX =/usr/local/haproxy
6. Write the configuration file cd/usr/local/haproxy and sudo vi haproxy. cfg. Fill in the following content:
########### Global configuration #########
Global
Daemon
Nbproc 1
Pidfile/var/run/haproxy. pid
######## Default configuration ############
Ults
Mode http # default mode {tcp | http | health}, tcp is Layer 4, http is Layer 7, health only returns OK
Retries 2 # If the connection fails twice, the server is considered unavailable. You can also set
Option redispatch # When the server corresponding to the serverId fails, it is forcibly directed to other healthy servers.
Option abortonclose # When the server load is high, the link for processing the queue for a long time is automatically terminated.
Maxconn 4096 # default maximum number of connections
Timeout connect 5000 ms # connection timeout
Timeout client 30000 ms # client timeout
Timeout server 30000 ms # server timeout
# Timeout check 2000 # = heartbeat detection timeout
Log 127.0.0.1 local0 err # [err warning info debug]
######## Statistics page configuration ########
Listen admin_stats
Bind 0.0.0.0: 1080 # listening port
Mode http # Layer-7 http mode
Option httplog # Use http log format
# Log 127.0.0.1 local0 err
Maxconn 10
Stats refresh 30 s # statistics page automatic refresh time
Stats uri/stats # url of the statistics page
Stats realm XingCloud \ Haproxy # text displayed in the password box on the statistics page
Stats auth admin: admin # user name and password settings on the statistics page
Stats hide-version # hide the HAProxy version on the statistics page
######## Test configuration #################
Listen test
Bind 0.0.0.0: 8080 # note that the port number is not lower than 1024
Mode tcp
# Maxcon 4086
# Log 127.0.0.1 local0 debug
Server s1 192.168.1.201: 8080
Server s2 192.168.1.202: 8080
7. Run haproxy:
Sudo/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy. cfg
8. Enable Automatic Running upon startup:
Sudo vi/etc/rc. local, add at the end of the document:
/Usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy. cfg
Haproxy + Keepalived build Weblogic high-availability server Load balancer Cluster
Keepalived + HAProxy configure high-availability Load Balancing
Haproxy + Keepalived + Apache configuration notes in CentOS 6.3
Haproxy + KeepAlived WEB Cluster on CentOS 6
Haproxy + Keepalived build high-availability Load Balancing
Configure an HTTP Load balancer using HAProxy
For details about HAproxy, click here
HAproxy: click here
This article permanently updates the link address: