请输入您要查询的百科知识:

 

词条 haproxy
释义

基本信息

什么是HAProxy

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

安装HAProxy

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

global

maxconn 5120

chroot /usr/local/haproxy

uid 99

gid 99

daemon

quiet

nbproc 2

pidfile /usr/local/haproxy/haproxy.pid

defaults

log global

mode http

option httplog

option dontlognull

log 127.0.0.1local3

retries 3

option redispatch

maxconn 2000

contimeout 5000

clitimeout 50000

srvtimeout 50000

listen webinfo :1080

mode http

balance roundrobin

option httpclose

option forwardfor

server phpinfo1 192.168.18.2:10000 check weight 1 minconn 1 maxconn 3 check inter 40000

server phpinfo2 127.0.0.1:80 check weight 1 minconn 1 maxconn 3 check inter 40000

listen webmb :1081

mode http

balance roundrobin

option httpclose

option forwardfor

server webmb1 192.168.1.91:10000 weight 1 minconn 1 maxconn 3 check inter 40000

server webmb2 127.0.0.1:10000 weight 1 minconn 1 maxconn 3 check inter 40000

listen stats :8888

mode http

transparent

stats uri / haproxy-stats

stats realm Haproxy \\ statistic

stats auth zhangy:xtajmd

启动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

说明

HAProxy监听的端口是1080,代理192.168.18.2:10000,127.0.0.1:10000

统计监听的是8888端口 http://localhost:8888/haproxy-stats

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/2/7 4:12:18