mingk 发表于 2015-9-5 07:27:55

Deploy haproxy in centOS

Down load haproxy from http://haproxy.1wt.eu/
We could usewget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.20.tar.gz

Extract the package.
tar -xzvf haproxy-1.4.20.tar.gz


compile and install.
cd haproxy-1.4.20.tar.gz
make TARGET=linux26 PREFIX=/home/khisserver/haproxy install

Copy the haproxy to /usr/sbin/haproxy
cp /home/khisserver/haproxy/sbin/haproxy /usr/bin/haproxy


Add config file.
wget http://layer1.rack911.com/haproxy/haproxy-standard.cfg -O /etc/haproxy.cfg
wget http://layer1.rack911.com/haproxy/haproxy.init -O /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy



Update the haproxy.cfg to the following contents.



global


   maxconn   4096 # Total Max Connections. This is dependent on ulimit


   daemon


   nbproc      1 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.


defaults


   mode         http


   clitimeout60000


   srvtimeout30000


   contimeout4000


   option      httpclose # Disable Keepalive


listen admin_stats


   bind 0.0.0.0:1080


   mode         http


   stats uri /admin?stats


listen   http_proxy 150.245.172.34:8081 #This should be your current ip address


   balance   roundrobin # Load Balancing algorithm


   option httpchk


   option forwardfor # This sets X-Forwarded-For


   ## Define your servers to balance


   server server1 150.245.167.59:8080 weight 1 maxconn 512 check


   #server server2 150.245.172.60:8080 weight 1 maxconn 512 check


Start haproxy :
service haproxy start

# service haproxy start
Starting HAproxy:                                          
You have new mail in /var/spool/mail/root

Open browser:
   http://150.245.172.34:8081/It will redired to150.245.167.59:8080

Open managerment web site:
   http://150.245.172.34:1080/admin?stats
   http://onexin.iyunv.com/source/plugin/onexin_bigdata/en-resource://resourcemap/0e10d9b2308acf1f3fc5dd4f4f2e93fc
页: [1]
查看完整版本: Deploy haproxy in centOS