下载最新版本
wgethttp://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.17.tar.gz
解压安装
[root@localhostsrc]#tar-zxfhaproxy-1.4.17.tar.gz[root@localhostsrc]#cdhaproxy-1.4.17[root@localhosthaproxy-1.4.17]#makeTARGET=linux26PREFIX=/usr/local/haproxy[root@localhosthaproxy-1.4.17]#makeinstallPREFIX=/usr/local/haproxy
设置配置文件
[root@localhosthaproxy-1.4.17]#mkdir/usr/local/haproxy/etc[root@localhosthaproxy-1.4.17]#vi/usr/local/haproxy/etc/haproxy.cfgglobalmaxconn5120chroot/usr/local/haproxyuid99gid99daemonquietnbproc2pidfile/usr/local/haproxy/haproxy.piddefaultslogglobalmodehttpoptionhttplogoptiondontlognulllog127.0.0.1local3retries3optionredispatchmaxconn2000contimeout5000clitimeout50000srvtimeout50000listentest10.130.193.235:8000modehttpbalanceroundrobinoptionhttpcloseoptionforwardforstick-tabletypeipsize10240kexpire30mstickonsrcserverpf0110.130.193.9:1433weight1minconn1maxconn3checkinter40000servernagios10.130.193.237:80weight1minconn1maxconn3checkinter40000listenstats10.130.193.235:8888statsenablestatsuri/admin-statusstatsauthloadbalancer:loadbalancerstatsadminifTRUE
启动haproxy,然后可以通过gui查看状态。
[root@localhosthaproxy-1.4.17]#/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/etc/haproxy.cfg[root@localhosthaproxy-1.4.17]#ps-ef|grephaproxynobody187551011:30?00:00:00/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/etc/haproxy.cfgnobody187561011:30?00:00:00/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/etc/haproxy.cfgroot187581689011:30pts/000:00:00grephaproxy
重启haproxy
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg -st `cat /usr/local/haproxy/haproxy.pid`650) this.width=650;” width=”800″ height=”600″ border=”0″ src=”http://cdn.verydemo.com/upload/2013_05_01/13673784878280.jpg” alt=”” />
不论你在什么时候开始,重要的是开始之後就不要停止