系统 CentOS 5.8 x64

wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.26.tar.gz

cd haproxy-1.3.26

make TARGET=linux26 PREFIX=/opt/local/haproxy

make install PREFIX=/opt/local/haproxy

mkdir /opt/local/haproxy/conf

cd /opt/local/haproxy/conf/

vim haproxy.cfg

后台配置模式

------------------------------------------------------------------------------------------------

global

log 127.0.0.1  local0

maxconn 65535

chroot /opt/local/haproxy

uid 502

gid 502

daemon

nbproc 8

pidfile /opt/local/haproxy/haproxy.pid

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

timeout connect   5000

timeout client    50000

timeout server    50000

listen  172.24.0.100

bind *:80

mode http

option httplog

log global

option httpchk HEAD /index.jsp HTTP/1.0

server web1 172.24.0.101:8080 weight 2  check inter 2000 rise 2 fall 3

server web2 172.24.0.102:8080 weight 2  check inter 2000 rise 2 fall 3

添加 日志

vi /etc/syslog.conf      (centos 5.X版本)

vi /etc/rsyslog.conf     (centos 6.X版本)

local3.*                        /var/log/haproxy.log

local0.*                        /var/log/haproxy.log

vi /etc/sysconfig/syslog   (centos 5.X版本)

vi /etc/sysconfig/rsyslog  (centos 6.X版本)

SYSLOGD_OPTIONS="-m 0"

修改为

SYSLOGD_OPTIONS="-r -m 0"

重启日志服务

service syslog restart

/opt/local/haproxy/sbin/haproxy -f /opt/local/haproxy/haproxy.cfg    启动haproxy

或者用 脚本 来做启动 重启 关闭

vi /etc/init.d/haproxy

-----------------------------------------------------------------------------------------

#!/bin/bash

BASE_DIR="/opt/local/haproxy"

ARGV="$@"

start()

{

echo "START HAPoxy SERVERS"

$BASE_DIR/sbin/haproxy -f $BASE_DIR/conf/haproxy.cfg

}

stop()

{

echo "STOP HAPoxy Listen"

kill -TTOU $(cat $BASE_DIR/haproxy.pid)

echo "STOP HAPoxy process"

kill -USR1 $(cat $BASE_DIR/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/init.d/haproxy

1.4版本以后的 启动 出现

--------------------------------------------------------------------------------------------------

[WARNING] 022/092301 (26090) : Proxy 'www.xxx.com': in multi-process mode, stats will be limited to process assigned to the current request.

那是因为配置文件 nbproc > 1 所导致的...可将 配置文件 nbproc 设置为 1 或者修改编译文件..

在源码配置src/cfgparse.c找到如下行

if (nbproc > 1) {

if (curproxy->uri_auth) {

Warning("Proxy '%s': in multi-process mode, stats will be limited to process assigned to the current request.\n", curproxy->id);

if (!LIST_ISEMPTY(&curproxy->uri_auth->admin_rules)) {

Warning("Proxy '%s': stats admin will not work correctly in multi-process mode.\n", curproxy->id);

}

修改 nbproc > 1 这个数值就可以...

----------------------------------------------------------------------------------------------------

option httpchk HEAD /index.php HTTP/1.0  这个为监控页面..在跟目录增加index.php文件,否则报503错误.

web监控 页面  http://www.xxxx.com/haproxy-stats

IP数据转发设置

-------------------------------------------------------------------------------

global   maxconn 65535 #最大连接数,HAProxy是数据转发,每条数据链路占用两个连接。

daemon   #daemon方式运行

nbproc 1

group nobody

user nobody

defaults

timeout server  86400s

timeout client  86400s

timeout connect 8640s

#log 127.0.0.1 local7.* warning

listen  xxxxx_80

bind 本机IP:80

mode tcp    #tcp模式,只转发,不分析

option tcpka

option srvtcpka

option clitcpka

server xxxxxx_80_src 目标IP:80 check inter 1000 rise 1 fall 2 #目标服务器定义

-------------------------------------------------------------------------------------

HAProxy 7层 负载均衡的更多相关文章

  1. [转帖]HAProxy 7层 负载均衡

    HAProxy 7层 负载均衡 https://www.cnblogs.com/jicki/p/5546902.html HAProxy 系统 CentOS 5.8 x64 wget http://h ...

  2. 大型网站系统架构实践(四)http层负载均衡之haproxy实践篇(一)

    方案 上篇文章讲到了负载均衡的相关理论知识,这篇文章我打算讲讲实践方法以及实践中遇到的问题 方案:haproxy http层负载均衡 安装一个haproxy服务,两个web服务 haproxy:192 ...

  3. http层负载均衡之haproxy

    http层负载均衡之haproxy实践篇(一) 方案 上篇文章讲到了负载均衡的相关理论知识,这篇文章我打算讲讲实践方法以及实践中遇到的问题 方案:haproxy http层负载均衡 安装一个hapro ...

  4. http层负载均衡之 haproxy实践篇

    方案 上篇文章讲到了负载均衡的相关理论知识,这篇文章我打算讲讲实践方法以及实践中遇到的问题 方案:haproxy http层负载均衡 安装一个haproxy服务,两个web服务 haproxy:192 ...

  5. 四层和七层负载均衡的特点及常用负载均衡Nginx、Haproxy、LVS对比

    一.四层与七层负载均衡在原理上的区别 图示: 四层负载均衡与七层负载均衡在工作原理上的简单区别如下图: 概述: 1.四层负载均衡工作在OSI模型中的四层,即传输层.四层负载均衡只能根据报文中目标地址和 ...

  6. Windows Azure支持七层负载均衡--Application Gateway

    一直以来Windows Azure的负载均衡(Loadbalancer)功能一直被客户诟病,无法其竞争对手(特别是国内的云厂商)匹敌. Windows Azure的负载均衡器是四层的,前期的版本不支持 ...

  7. 项目实战4—HAProxy实现高级负载均衡实战和ACL控制

     haproxy实现高级负载均衡实战 环境:随着公司业务的发展,公司负载均衡服务已经实现四层负载均衡,但业务的复杂程度提升,公司要求把mobile手机站点作为单独的服务提供,不在和pc站点一起提供服务 ...

  8. 项目详解4—haproxy 反向代理负载均衡

    一.企业服务架构图及负载均衡的要求 1.场景说明 在企业生产环境中,每天会有很多的需求变更,比如增加服务器.新业务上线.url路由修改.域名配置等等,对于前端负载均衡设备来说,容易维护,复杂度低,是首 ...

  9. Web负载均衡学习笔记之四层和七层负载均衡的区别

    0x00 简介 简单理解四层和七层负载均衡: ① 所谓四层就是基于IP+端口的负载均衡:七层就是基于URL等应用层信息的负载均衡:同理,还有基于MAC地址的二层负载均衡和基于IP地址的三层负载均衡. ...

随机推荐

  1. spring 入门级程序示例

    public interface Action { public String execute(String str); } 接口 public class UpperAction implement ...

  2. asp之FSO大全

    <%Function ShowDriveInfo(strFolder)'显示磁盘信息'strRootFolder="/"'strDrivInfo=ShowDriveInfo( ...

  3. Content-Type小解

    在Http请求中,经常用Content-Type来定义网络文件的类型和网页的编码,在发送请求,返回数据时决定浏览器将以什么形式,什么编码来读取此文件. 常用类型: text 文本类型 1.text/p ...

  4. php moungoDB

    moungoDB 语法 SQL查询语句 Mongo查询语句 CREATE TABLE USERS (a Number, b Number) 隐式的创建,或 MongoDB::createCollect ...

  5. fidder 调试本地文件

  6. margin:0 auto

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  7. android 学习之RecyclerView

    RecyclerView:ListView的升级版,它提供了更好的性能而且更容易使用.该控件是一个可以装载大量的视图集合,并且可以非常效率的进行回收和滚动.当你list中的元素经常动态改变时可以使用R ...

  8. 优化のzen cart调用WordPress

    zen cart调用wordpress博客系统文章的方法 zencart根目录下新建blog 解压wp进去然后 wp-admin 安装 数据库共用 之前将wordpress和zencart整合起来 是 ...

  9. AutoMapper使用简单总结

    近期,在用AutoMapper整理一些模型对象映射,顺便小结一下使用的体会.难免有写得不对的地方,谢谢指出! 1. AutoMapper是一个.NET的对象映射工具,可以方便地进行对象间的赋值处理. ...

  10. 剑指offer 复杂链表的复制 (有向图的复制)

    时间复杂度O(3N) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...