云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > redhat 6.4(64位)下HAproxy+Keepalived 负载均衡架构搭建

redhat 6.4(64位)下HAproxy+Keepalived 负载均衡架构搭建

  • 62 次阅读
  • 3 次下载
  • 2025/5/24 14:58:23

capture cookie ASPSESSION len 32 srvtimeout 20000

option httpclose # disable keep-alive

option checkcache # block response if set-cookie & cacheab le

rspidel ^Set-cookie:\\ IP= # do not let this cookie tell our intern al IP address

errorloc 502 http://192.168.114.58/error502.html errorfile 503 /etc/haproxy/errors/503.http

编辑配置文件(两台Haproxy配置文件相同):

# vim /usr/local/haproxy/conf/haproxy.cfg

defaults

log global mode http option httplog option dontlognull retries 3

option redispatch maxconn 2000

contimeout 5000 clitimeout 50000 srvtimeout 50000

listen web 192.168.10.222:80

mode http

option httplog

log global

option httpchk HEAD /test/test.jsp

server ha1 192.168.10.71:8080 check inter 2000 fall 3 weight 20 server ha2 192.168.10.72:8080 check inter 2000 fall 3 weight 10

创建启动文件:

# vim /etc/rc.d/init.d/haproxy #!/bin/sh #

# haproxy #

# chkconfig: 35 85 15

# description: HAProxy is a free, very fast and reliable solution # offering high availability, load balancing, and # proxying for TCP and HTTP-based applications # processname: haproxy

# config: /usr/local/haproxy/conf/haproxy.cfg # pidfile: /var/run/haproxy.pid

# Source function library. . /etc/rc.d/init.d/functions

# Source networking configuration. . /etc/sysconfig/network

# Check that networking is up.

[ \

config=\exec=\prog=$(basename $exec)

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/haproxy

check() {

$exec -c -V -f $config }

start() {

$exec -c -q -f $config if [ $? -ne 0 ]; then

echo \ return 1

fi

echo -n $\

# start it up here, usually something like \ daemon $exec -D -f $config -p /var/run/$prog.pid retval=$? echo

[ $retval -eq 0 ] && touch $lockfile return $retval }

stop() {

echo -n $\

# stop it here, often \ killproc $prog retval=$? echo

[ $retval -eq 0 ] && rm -f $lockfile return $retval }

restart() {

$exec -c -q -f $config if [ $? -ne 0 ]; then

echo \ return 1 fi stop start }

reload() {

$exec -c -q -f $config if [ $? -ne 0 ]; then

echo \ return 1 fi

echo -n $\

$exec -D -f $config -p /var/run/$prog.pid -sf $(cat /var/run/$prog.pid) retval=$? echo

return $retval }

force_reload() { restart }

fdr_status() { status $prog }

case \

start|stop|restart|reload) $1 ;;

force-reload) force_reload ;;

checkconfig) check ;; status)

fdr_status ;;

condrestart|try-restart)

[ ! -f $lockfile ] || restart ;; *)

echo $\ad|force-reload}\ exit 2 esac

# chmod +x /etc/rc.d/init.d/haproxy

3、启动测试haproxy

# service haproxy start

4、haproxy日志配置

默认情况下,HAProxy为了节省读写IO所消耗的性能,默认情况下没有日志输出,以下是我配置log的过程:

RHEL6.4 默认使用的是rsyslog管理log

搜索更多关于: redhat 6.4(64位)下HAproxy+Keepal 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

capture cookie ASPSESSION len 32 srvtimeout 20000 option httpclose # disable keep-alive option checkcache # block response if set-cookie & cacheab le rspidel ^Set-cookie:\\ IP= # do not let this cookie tell our intern al IP address errorloc 502 http://192.168.114.58/

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com