马哥linux-多年内部专用电子书,马哥linux-多年积累-无价之宝books haproxy.pdf

It你好linux 学习文档之haproxy 学习笔记 itnihao@ .com

It你好linux 学习文档之haproxy 学习笔记V1.0

一,haproxy的功能

软件负载均衡一般通过两种方式来实现:基于操作系统的软负载实现和基于第 应用的软负载实现。

LVS就是基于Linux操作系统实现的一种软负载,HAProxy就是开源的并且基于第三应用实现的软负载。

HAProxy相比LVS的使用要简单很多,功能方面也很丰富。当前,HAProxy支持两种主要的 模

式:"tcp"也即4层(大多用于邮件 、内部协议通信 等),和7层(HTTP)。在4层模式下,HAproxy

仅在 端和 之间转发双向流量。7层模式下,HAProxy会分析协议,并且能通过允许、拒绝、交换、

增加、修改或者删除请求(request)或者回应(response)里指定内容来控制协议,这种操作要基于特定规则。

详情可以在HAProxy 官方网站( )可以 配置说明文档(configuration.txt)和架构文

件(architecture.txt)作为 。

二,haproxy的安装

haproxy软件的安装

#!/bin/bash

#this is workonrhel6.X centos6.XOK,if in rhel5.X ,youshould configure logs foryourself

#date 2012-06-18

#authoritnihao

ha_install (){

#wget

./etc/init.d/functions

tarxvfhaproxy-1.4.21.tar.gz

cdhaproxy-1.4.21

make TARGET=linux26 PREFIX=/usr/local

make install PREFIX=/usr/local

cd../

[-d/etc/haproxy ]&&mkdir /etc/haproxy

#copyexaplesfile

cp-rfexamples//etc/haproxy/

cp-rftests//etc/haproxy/

#mkdir /var/log/haproxy

mkdir /var/haproxy

#copyconfigure file

cpconf/haproxy.init /etc/init.d/haproxy

cpconf/haproxy/etc/haproxy/haproxy.cfg

#add default services

chmod755/etc/init.d/haproxy

chkconfig--addhaproxy

chkconfig--level 345 haproxyon

servicehaproxyrestart

It你好linux 学习文档之haproxy 学习笔记 itnihao@ .com

}

r _ha (){

#add haproxylog

cat>>/etc/r .conf<< EOF

\$ModLoad imudp

\$UDPServerRun514

\$UDPServerAddress

local3.* /var/log/haproxy.log

EOF

#add haproxy.log

cat>/etc/logrotate.d/haproxy.cfg<< EOF

/var/log/haproxy.log

{

rotate4

daily

missingok

notifempty

compress

delaycompress

sharedscripts

postrotate

reload r >/dev/null 2>&1||true

endscript

}

EOF

}

ha_

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值