转:http://www.cnblogs.com/dkblog/archive/2011/07/06/2098949.html
http://www.cnblogs.com/super-d2/p/4134562.html
http://blog.csdn.net/youyudehexie/article/details/7592206
51 make TARGET=linux26 PREFIX=/usr/local/haproxy install
vim /usr/local/haproxy/conf/haproxy.cfg
global maxconn 51200 chroot /usr/local/haproxy uid 99 gid 99 daemon #quiet nbproc 1 pidfile /usr/local/haproxy/logs/haproxy.pid defaults mode http #retries 2 option redispatch option abortonclose timeout connect 5000ms timeout client 30000ms timeout server 30000ms #timeout check 2000 log 127.0.0.1 local0 err #[err warning info debug] balance roundrobin # option httplog # option httpclose # option dontlognull # option forwardfor listen admin_stats bind 0.0.0.0:8888 option httplog stats refresh 30s stats uri /stats stats realm Haproxy Manager stats auth admin:admin #stats hide-version listen test1 bind :12345 mode tcp server t1 10.77.50.111:8088 server t2 10.77.50.111:8099 listen test2 bind :80 option httpclose option forwardfor server s1 10.77.50.111:8088 check weight 1 minconn 1 maxconn 3 check inter 40000 server s2 10.77.50.68:808 check weight 1 minconn 1 maxconn 3 check inter 40000 //本机nginx运行在808
root@test-VirtualBox:/usr/local/haproxy/conf# /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg
测试
访问http://10.77.50.68
1.安装
2.配置
安装完毕后,进入安装目录配置文件,默认情况下目录里是没有.cfg配置文件的,可以回到安装文件目录下将examples下的haproxy.cfg拷贝到usr/local/haproxy下。
haproxy.cfg的内容如下:
# cd /usr/local/haproxy
# vi haproxy.cfg
[root@node3 haproxy]# /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg [root@node3 app]# ps -ef |grep haproxy |grep -v grep root 6950 1 0 19:35 ? 00:00:00 /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
#!/bin/bash BASE_DIR="/usr/local/haproxy" ARGV="$@" start() { echo "START HAPoxy SERVERS" $BASE_DIR/sbin/haproxy -f $BASE_DIR/haproxy.cfg } stop() { echo "STOP HAPoxy Listen" kill -TTOU $(cat $BASE_DIR/logs/haproxy.pid) echo "STOP HAPoxy process" kill -USR1 $(cat $BASE_DIR/logs/haproxy.pid) } case $ARGV in start) start ERROR=$? ;; stop) stop ERROR=$? ;; restart) stop start ERROR=$? ;; *) echo "hactl.sh [start|restart|stop]" esac exit $ERROR
chmod +x /etc/rc.d/init.d/haproxy
[root@node3 ~]# service haproxy stop STOP HAPoxy Listen STOP HAPoxy process [root@node3 ~]# ps -ef |grep haproxy |grep -v grep [root@node3 ~]# service haproxy start START HAPoxy SERVERS [root@node3 ~]# ps -ef |grep haproxy |grep -v grep root 11259 1 0 15:33 ? 00:00:00 /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术
转载请注明:haproxy负载均衡 出自老鄢博客 | 欢迎分享