sam_yu 发表于 2015-11-20 12:32:01

Web负载均衡解决方案 HAproxy

    反向代理服务器,支持双机热备支持虚拟主机,但其配置简单,拥有非常不错的服务器健康检查功能,当其代理的后端服务器出现故障, HAProxy会自动将该服务器摘除,故障恢复后再自动将该服务器加入。

  
HAProxy提供高可用性、负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费、快速并且可靠的一种解决方案。HAProxy特别适用于那些负载特大的web站点, 这些站点通常又需要会话保持或七层处理。HAProxy运行在当前的硬件上,完全可以支持数以万计的并发连接。并且它的运行模式使得它可以很简单安全的整合进您当前的架构中, 同时可以保护你的web服务器不被暴露到网络上。
  http://cn.haproxy.org/img/haproxy-pmode.png

  1. 下载LINUX可执行文件 http://haproxy.1wt.eu/download/1.4/bin/haproxy-1.4.2-pcre-40kses-linux-i586.stripped
  2. 手动创建配置文件 test1.hacfg
  global
         log 127.0.0.1    local0
         #log 127.0.0.1 local1 notice
         #log loghost   local0 info
         maxconn 4096
         chroot ./
         uid 99
         gid 99
         daemon
         nbproc 1
         pidfile ./haproxy.pid
         #debug
         #quiet
  defaults
         log      127.0.0.1      local3
         mode   http
         option httplog
         option httpclose
         option dontlognull
         option forwardfor
         option redispatch
         retries 2
         maxconn 2000
         balance roundrobin
         stats    uri      /haproxy-stats
         contimeout       5000
         clitimeout       50000
         srvtimeout       50000
  listen web_proxy 0.0.0.0:1080
         option httpchk GET /index.php
           server wiki 192.168.1.13:80 weight 3 check
         server test 192.168.1.20:80 weight 3 check

  3. 启动服务 ./haproxy-1.4.2-pcre-40kses-linux-i586.stripped -f test1.hacfg
  重启服务 ./haproxy-1.4.2-pcre-40kses-linux-i586.stripped -f test1.hacfg -st `cat ./haproxy.pid`
  监听端口 <server ip>:1080
  图形数据统计页面 http://<server ip>:1080/haproxy-stats
  
  
  
  
  更多:
  haproxy源码:http://haproxy.1wt.eu/download/1.4/
  Haproxy 配置 session 粘贴, HAProxy MySQL负载均衡, 等等, 请参照 http://www.oschina.net/p/haproxy
页: [1]
查看完整版本: Web负载均衡解决方案 HAproxy