1. Install wget HTTP://DOWNLOAD.CHINAUNIX.NET/DOWNLOAD.PHP?ID=25784&RESOURCEID=12508TAR-ZXVF HAPROXY-1.3.15.10.TAR.GZCD haproxy-1.3.15.10make target=linux26 prefix=/usr/local/haproxy (#将haproxy安装到/usr/local/ Haproxy) make install Prefix=/usr/local/haproxycd/usr/local/haproxyvi haproxy.cfg
2. Configuration
After installation, go to the installation directory configuration file, by default, there is no. cfg configuration file, you can go back to the installation file directory under the examples haproxy.cfg copy under the Usr/local/haproxy.
The contents of haproxy.cfg are as follows:
# Cd/usr/local/haproxy
# VI Haproxy.cfg
global Maxconn 51200 chroot/usr/local/haproxy UID 99 GID 99 &NB Sp daemon #quiet Nbproc 1 pidfile/usr/local/haproxy/logs/haproxy.pid defaults mode http #retries 2 option Redi spatch option abortonclose Timeout connect 5000ms &NBSP ; Timeout client 30000ms Timeout server 30000ms #timeout check 2000 log 127.0.0.1 local0 err #[err warning Info debug] Balance Roun drobin# option httplog# option httpclose# option dontlognull# option Forwardfor listen admin_stats &NBS P Bind 0.0.0.0:8888 option httplog Stats Refresh 30s &nbs P Stats URI/stats Stats Realm Haproxy manager Stats auth admin:admin &nbs P #stats Hide-version listen test1 bind:12345 mode tcp Server T1 127.0.0.1:8881 Server T2 192.168.1.102:8881 list En test2:80 option httpclose option forwardfor &N Bsp Server S1 127.0.0.1:8081 Check weight 1 minconn 1 Maxconn 3 check Inter 40000 Server S2 127.0.0 .1:8082 Check Weight 1 minconn 1 Maxconn 3 check Inter 40000 3. Start Haproxy
[[email protected] haproxy]#/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/haproxy.cfg[[email protected] app] # ps-ef |grep haproxy |grep-v greproot 6950 1 0 19:35? 00:00:00/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/haproxy.cfg
visit: Http://192.168.2.150:8888/stats4. Test: As we bind the loopback interface to the 127.0.0.1:8081 port on the native 127.0.0.1:80 port, the last time we installed the httpd, the binding is 127.0.0.1:8081http://www.cnblogs.com/ super-d2/p/4134467.html Access http://192.168.2.137:8081/can see this without configuring Haproxy before we visit http://192.168.2.137:80/is inaccessible, Because this service is not available on port 80, if we start haproxy now, we can access it again: through Haproxy we implement proxy access http://192.168.2.137:80/
Haproxy installation Configuration