负载均衡工具haproxy安装,配置,使用
来源:互联网 发布:淘宝助理for mac版 编辑:程序博客网 时间:2024/04/30 01:39
转自:http://a280606790.iteye.com/blog/904383
一,什么是haproxy
HAProxy提供高可用性、负载均衡以及基于TCP和HTTP应用的代 理,支持虚拟主机
,它是免费、快速并且可靠的一种解决方案。HAProxy特别适用于那些负载特大的web站点,这些站点通常又需要会话保持或七层处理。 HAProxy运行在当前的硬件上,完全可以支持数以万计的并发连接。并且它的运行模式使得它可以很简单安全的整合进您当前的架构中, 同时可以保护你的web服务器不被暴露到网络上。
二,安装haproxy
下载列表地址http://haproxy.1wt.eu
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.8.tar.gz
tar zxvf haproxy-1.4.8.tar.gz
cd haproxy-1.4.8
uname -a //查看linux内核版本
make TARGET=linux26 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy
三,配置haproxy
vi /usr/local/haproxy/haproxy.cfg
- <span style="font-size: small;">global
- log 127.0.0.1 daemon debug
- maxconn 5120
- chroot /home/denghaiping/document/search/solr/haproxy-1.3.14.2
- uid 99
- # user haproxy
- gid 99
- # group ha-group
- daemon
- # quiet
- # nbproc 2 # number of processes
- pidfile /home/sgcc/demo/haproxy-1.3.14.2/haproxy.pid
- defaults
- # log global
- log 127.0.0.1 local3
- mode http
- option httplog
- option dontlognull
- option redispatch
- log 127.0.0.1 local3
- retries 3
- maxconn 2000
- contimeout 5000
- clitimeout 50000
- srvtimeout 50000
- listen yoyoseg_proxy
- bind :10001
- mode tcp
- # status monitor
- #stats uri /haproxy-stats
- # stats realm Haproxy\ statistics
- # stats auth yoyo:yoyocc8ha
- balance roundrobin
- # insert: to create a new cookie and assign the server identifier to it
- # indirect: remove the cookie for direct accesses
- # nocache: ensure that no upstream cache will store it
- # cookie SERVERID insert indirect nocache
- # cookie PHPSESSID prefix
- # appsession PHPSESSID len 32 timeout 86400000
- # force connection:close, thus disabling HTTP keep-alive
- # option httpclose
- # if the application needs to log the original client’s IP,
- # use the 'forwardfor' option which will add an 'X-Forwarded-For'
- # header with the original client's IP address.
- # option forwardfor
- # health checking
- #option httpchk HEAD /check.txt HTTP/1.0
- # inter: interval between health checking in milliseconds
- # fall: the number of failures supported before declaring that the server has fallen down
- # rise: the number of valid checks needed for the server to fully get up
- server seg_server_1 localhost:10002
- server seg_server_1 localhost:10003
- server seg_server_1 localhost:10004
- server seg_server_1 localhost:10005
- server seg_server_1 localhost:10006
- # server app_server_2 59.57.14.176:8008 cookie yoyo_app_2 check inter 2000 rise 2 fall 5
- #server app_bbs2 192.168.169.118:80 cookie app1inst2 check inter 2000 rise 2 fall 5
- </span>
三,启动haproxy
#启动haproxy
/usr/local/haproxy/haproxy -f /usr/local/haproxy/haproxy.cfg
#查看是否启动
[zhangy@BlackGhost haproxy]$ ps -e|grep haproxy
4859 ? 00:00:00 haproxy
4860 ? 00:00:00 haproxy
四,压力测试
[root@BlackGhost haproxy]# /usr/local/bin/webbench -c 100 -t 30 http://localhost:1080/phpinfo.php
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://localhost:1080/phpinfo.php
100 clients, running 30 sec.
Speed=26508 pages/min, 20929384 bytes/sec.
Requests: 13254 susceed, 0 failed.
说明:haproxy监听的端口是1080,代理192.168.18.2:10000,127.0.0.1:10000
统计监听的是8888端口 http://localhost:8888/haproxy-stats
配置说明:
1.4系列参考配置文件
http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
1.3系列参考配置文件
http://haproxy.1wt.eu/download/1.3/doc/configuration.txt
- 负载均衡工具haproxy安装,配置,使用
- 负载均衡工具haproxy安装,配置,使用
- 负载均衡工具haproxy安装,配置,使用
- 负载均衡工具haproxy安装,配置,使用
- 负载均衡工具haproxy安装,配置,使用
- 负载均衡工具haproxy安装,配置,使用
- 负载均衡(haproxy安装,配置,使用)
- 安装 HAProxy 配置负载均衡
- 负载均衡-haproxy安装配置
- 负载均衡-haproxy安装配置
- 负载均衡haproxy的安装配置
- haproxy负载均衡配置
- haproxy安装.负载均衡
- Haproxy+keepalived负载均衡配置
- 负载均衡haproxy.cfg配置
- Haproxy+keepalived负载均衡配置
- Centos6.5 负载均衡 Haproxy 1.6.9安装配置
- 基于域名负载均衡的Haproxy配置
- linux设备驱动归纳总结(五):3.IO静态映射
- Zend Framework之Zend_Controller和引导
- VS2008下安装boost
- 1060 Leftmost Digit
- 一直想知道到这样的页面,终于找到了,也许是我很out
- 负载均衡工具haproxy安装,配置,使用
- 开启暴风影音本地视频左眼功能 有图有真相
- js刷新页面
- 程序员这口饭
- I/O上的等待事件 —— db file parallel read
- 多线程(NSOperation和NSOperationQueue)
- java值SAX解析xml
- linux设备驱动归纳总结(五):4.写个简单的LED驱动
- OpenGL的填充属性函数之线框图方法的改进