First, install the Haproxy
1. Go to the home directory and download the latest Haproxy installation package.
Cd/home
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.24.tar.gz
2. Unzip:
TAR-ZXVF haproxy-1.4.24.tar.gz
Rename to Haproxy
MV Haproxy-1.4.24.tar.gz Haproxy
Create Directory/usr/local/haproxy
Mkdir/usr/local/haproxy
3. Installation
CD Haproxy
Make Target=linux26 Prefix=/usr/local/haproxy
Make install Prefix=/usr/local/haproxy
Cd/usr/local/haproxy
Mkdir/usr/local/haproxy/conf
cp/home/haproxy/examples/haproxy.cfg/home/haproxy/haproxy/conf/
4. Modify the configuration
Vi/usr/local/haproxy/conf/haproxy.cfg
:
Content:
# This config needs haproxy-1.1.28 or haproxy-1.2.1global log 127.0.0.1 local0 log 127.0.0.1 local1 Notice #log loghost local0 info maxconn 4096 chroot/usr/share/haproxy uid gid Daemon #debug #quietdefaults log Global mode http option httplog Option dontlognull retries 3 option Redispatch maxconn contimeout clitimeout 50000 srvtimeout 50000 Listen Web bind *:8666 mode http Balance Roundrobin stats uri/haproxy-stats stats Refresh 10s stats Realm haproxy\ Statistics Stats auth admin:admin option httpchk head/index.html server web1 127.0.0.1:8080 weight 1 maxconn 10000 Check I Nter 3s rise 3 Fall 3 Server web2 127.0.0.1:8081 weight 1 maxconn 10000 check Inter 3s rise 3 Fall 3 server Web3 127.0.0.1:8082 weight 1 maxconn 10000 check Inter 3s rise 3 Fall 3
Second, the Tomcat service cluster and session sharing reference:
Nginx+tomcat for load balancing and session sharing (Linux CENTOS7 Environment) (2nd)
Three, 3 tomcat configuration completed and started, start haproxy
./usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/conf/haproxy.cfg
The Close Haproxy command is:
Killall Haproxy
Haproxy+tomcat for load balancing and session sharing (Linux CENTOS7 environment)