负载均衡-haproxy 安装配置

HAProxy 提供高可用性、负载均衡以及基于 TCP 和 HTTP 应用的代理,支持虚拟主机,
它是免费、快速并且可靠的一种解决方案。HAProxy 特别适用于那些负载特大的 web 站
点,这些站点通常又 需要会话保持或七层处理。HAProxy 运行在当前的硬件上,完全可以
支持数以万计的并发连接。并且它的运行模式使得它可以很简单安全的整合进您当前的架
构中,同时可以保护你的 web 服务器不被暴露到网络上.
haproxy 配置中分成五部分内容,分别如下:
1、global:参数是进程级的,通常是和操作系统相关。这些参数一般只设置一次,如果配
置无误,就不需要再次进行修改
2、defaults:配置默认参数,这些参数可以被用到 frontend,backend,Listen 组件
3、frontend:接收请求的前端虚拟节点,Frontend 可以更加规则直接指定具体使用后端
的 backend
4、backend:后端服务集群的配置,是真实服务器,一个 Backend 对应一个或者多个实
体服务器
5、Listen Fronted 和 backend 的组合体
一、安装 HAProxy
1.自己搞安装包 haproxy-1.4.22.tar.gz
2.tar -zxvf haproxy-1.5.8.tar.gz
3.安装

[root@server1 mnt]# ls
haproxy-1.4.22.tar.gz
[root@server1 mnt]#
[root@server1 mnt]# tar zxf haproxy-1.4.22.tar.gz
[root@server1 mnt]# ls
haproxy-1.4.22 haproxy-1.4.22.tar.gz
[root@server1 mnt]# yum install rpm-build
[root@server1 ~]# rpmbuild ~
[root@server1 ~]# cp /mnt/haproxy-1.4.22.tar.gz /root/rpmbuild/SOURCES/
[root@server1 mnt]# cd haproxy-1.4.22
[root@server1 haproxy-1.4.22]# ls
CHANGELOG ebtree LICENSE Makefile.osx src TODO
contrib examples Makefile README SUBVERS VERDATE
doc include Makefile.bsd ROADMAP tests VERSIONdoc
[root@server1 haproxy-1.4.22]# cd examples
[root@server1 examples]# ls
acl-content-sw.cfg  haproxy.cfg
auth.cfg    haproxy.init
build.cfg   haproxy.spec
check   haproxy.vim
check.conf  init.haproxy
config.rc.haproxy   init.haproxy.flx0
content-sw-sample.cfg   linux-2.4.21-40.EL-custom.dif
cttproxy-src.cfg    option-http_proxy.cfg
debug2ansi  rc.highsock
debug2html  stats_haproxy.sh
debugfind   tarpit.cfg
errorfiles  test-section-kw.cfg
examples.cfg    url-switching.cfg
haproxy-1.1.21-flx.1.pkg
[root@server1 examples]# rpmbuild -bb haproxy.spec
[root@server1 examples]# cd /root/rpmbuild/RPMS/x86_64/
[root@server1 x86_64]# ls
haproxy-1.4.22-1.x86_64.rpm haproxy-debuginfo-1.4.22-1.x86_64.rpm
[root@server1 x86_64]# yum install * -y

配置:
这里写图片描述
启动服务:
[root@server1 share]# /etc/init.d/haproxy start
Starting haproxy: [ OK ]
测试:
访问 http://www.westos.com 测试负载
这里写图片描述
手动刷新
这里写图片描述
访问 haproxy 监控页面:http://172.25.254.1/status
这里写图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值