CentOS6下Haproxy的安装配置

Posted 快乐的GTD吧

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6下Haproxy的安装配置相关的知识,希望对你有一定的参考价值。

Haproxy 是一个开源的负载均衡和反向代理软件,其提供了高可用的网络服务。其一般是应用于web服务,但同时也能为SMTP和终端服务等提供可靠的支持。

1、下载安装haproxy

wget ftp://195.220.108.108/linux/centos/6.8/os/x86_64/Packages/haproxy-1.5.4-3.el6.x86_64.rpm   --下载
rpm -ivh haproxy-1.5.4-3.el6.x86_64.rpm   -安装

2、配置Haproxy

cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak
vi /etc/haproxy/haproxy.cfg
/etc/haproxy/haproxy.cfg文件

更多关于Haproxyacl配置请参考博文:http://blog.csdn.net/tantexian/article/details/50015975
复制代码
global
    log 127.0.0.1 local0 info
    chroot /containers/loadbalancer/lb-gxevnalt/
    stats socket /containers/loadbalancer/lb-gxevnalt/stats.sock
    user haproxy
    group haproxy
    maxconn 100000
    tune.maxaccept 100000
    daemon

defaults
    option dontlognull
    retries 3
    option redispatch
    maxconn 100000
    timeout client 50s
    timeout server 50s
    timeout connect 5s

listen lb-gxevnalt_80 0.0.0.0:80
    mode http
    balance leastconn
    log global
    log-format "%Tl",%{+Q}ci,"%fi:%fp",%{+Q}bi,%{+Q}r,%ST,%B,%{+Q}hr,%Tt
    option forwardfor
    option http-server-close
    capture request header Host len 255
    capture request header User-Agent len 255
    capture request header Referer len 255
    capture request header Cookie len 255
    timeout http-request 10s
    timeout http-keep-alive 55s
    server lb-gxevnalt_80_i-calrmvwp_80 10.53.0.86:80 cookie i-calrmvwp_80 weight 10 check inter 3000 rise 3 fall 5
    server lb-gxevnalt_80_i-jkhngdlw_80 10.53.0.87:80 cookie i-jkhngdlw_80 weight 10 check inter 3000 rise 3 fall 5
    acl aaa_com hdr(host) -m str aaa.com
    acl www_aaa_com hdr(host) -m str www.aaa.com
    redirect prefix http://shop.aaa.com code 301 if aaa_com or www_aaa_com

listen lb-gxevnalt_443 0.0.0.0:443
    mode tcp
    balance leastconn
    no log
    timeout client 60s
    timeout server 60s
    server lb-gxevnalt_443_i-calrmvwp_443 10.53.0.86:443 weight 10 check inter 5000 rise 3 fall 5
    server lb-gxevnalt_443_i-jkhngdlw_443 10.53.0.87:443 weight 10 check inter 5000 rise 3 fall 5
复制代码

 假若想访问监控界面:配置stats uri  /haproxy项,重启服务:

设置防火墙:

iptables -I INPUT -p tcp --dport 5000 -j ACCEPT  
service iptables save
service iptables restart 

监控界面:

3、开机启动

chkconfig haproxy on
service haproxy start

负载均衡-haproxy安装配置

HAproxy均衡负载部署和配置文件详解 

负载均衡之Haproxy配置详解(及httpd配置)

CentOS6下Haproxy的安装配置

 

原文: CentOS6下Haproxy的安装配置

 

以上是关于CentOS6下Haproxy的安装配置的主要内容,如果未能解决你的问题,请参考以下文章

haproxy安装配置及haproxy+keepalived配置

centos7下haproxy1.7的使用与配置

Azure SLB + httpd + ILB + HAProxy + Atlas + MySQL

mysql复制+keepalived+haproxy配置(负载均衡)

MySQL日常运维之 MySQL双主复制+keepalived+haproxy配置(负载均衡)

HAProxy安装配置SSL