How to intall and configure Haproxy on Centos

  1. Install Haproxy 
    CentOS/RHEL 5 , 32 bit:
    # rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm 
    CentOS/RHEL 5 , 64 bit:
    # rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm 
    CentOS/RHEL 6 , 32 bit:
    # rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm 
    CentOS/RHEL 6 , 64 bit:
    # rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    yum -y install haproxy
  2. Configure Haproxy
    vi /etc/haproxy/haproxy.cfg
    global
            log 127.0.0.1   local0
            log 127.0.0.1   local1 debug
            maxconn   45000 # Total Max Connections.
            daemon
            nbproc      1 # Number of processing cores. 
    defaults
            log     global
            mode    http
            option  httplog
            option  dontlognull
            retries 3
            option redispatch
            maxconn 20000
            timeout server 86400000
            timeout connect 86400000
            timeout client 86400000
            timeout queue   1000s
            
    # [HTTP Site Configuration]
    listen  http_web 10.10.0.112:80
            mode http
            balance roundrobin  # Load Balancing algorithm
            option httpchk
            option forwardfor
            server server1 23.253.48.253:80 weight 1 maxconn 512 check
            server server2 208.43.40.162:80 weight 1 maxconn 512 check
    
    
    # [Change HAProxy Stats URL]
    listen  stats   10.10.0.112:1936
            mode            http
            log             global
            balance roundrobin
    
            maxconn 10
    
            timeout server 86400000
            timeout connect 86400000
            timeout client 86400000
            timeout queue   1000s
    
            stats enable
            stats hide-version
            stats refresh 30s
            stats show-node
            stats realm Haproxy\ Statistics
            stats auth admin:password
            stats uri  /ha-stats
    haproxy Code
    开启防火墙 1936 端口
  3. 重启相关服务
    service iptables restart 
    service haproxy restart
    chkconfig haproxy on
  4. 后台查看网站:
    http://10.10.0.112:1936/ha-stats  or  http://10.10.0.112:1936/stats
  5. 参考链接:
    http://tecadmin.net/install-and-configure-haproxy-on-centos/

转载于:https://www.cnblogs.com/Mrhuangrui/p/4600974.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值