亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

HAproxy負載均衡部署

標簽:
Premiere

1、安装HAproxy

yum -y install haproxy

2、编辑配置文件


#---------------------------------------------------------------------

# Example configuration for a possible web application.  See the

# full configuration options online.

#

#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt

#

#---------------------------------------------------------------------

#---------------------------------------------------------------------

# Global settings

#---------------------------------------------------------------------

global

    # to have these messages end up in /var/log/haproxy.log you will

    # need to:

    #

    # 1) configure syslog to accept network log events.  This is done

    #    by adding the '-r' option to the SYSLOGD_OPTIONS in

    #    /etc/sysconfig/syslog

    #

    # 2) configure local2 events to go to the /var/log/haproxy.log

    #   file. A line like the following can be added to

    #   /etc/sysconfig/syslog

    #

    #    local2.*                       /var/log/haproxy.log

    #

    log         127.0.0.1 local2       #定义日志

    chroot      /var/lib/haproxy      #定义haproxy的家目录,

    pidfile     /var/run/haproxy.pid   #定义pid

    maxconn     4000               #设置最大并发连接数

    user        haproxy            #用户名

    group       haproxy            #用户组

    daemon                         #以守护进程模式运行

    # turn on stats unix socket

    stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------

# common defaults that all the 'listen' and 'backend' sections will

# use if not designated in their block

#---------------------------------------------------------------------

defaults   #默认参数

    mode                    http

    log                     global

    option                  httplog

    option                  dontlognull

    option http-server-close

    option forwardfor       except 127.0.0.0/8

    option                  redispatch

    retries                 3

    timeout http-request    10s

    timeout queue           1m

    timeout connect         10s

    timeout client          1m

    timeout server          1m

    timeout http-keep-alive 10s

    timeout check           10s

    maxconn                 3000

listen stats    #状态信息

    mode http 

    bind *:1080  #绑定端口

    stats enable #开启或者关闭

    stats hide-version #关闭版本信息

    stats uri   /haproxy?admin #web状态界面的url

    stats realm Haproxy\ Statistics #

    stats auth admin:admin  #认证的用户名:密码

    stats admin if TRUE     #如果认证成功开启admin


frontend http-in     #前端配置

   bind *:80        #前端绑定端口

   mode http        #http

   log global       #全局日志

   option httpclose #

   option logasap

   capture request header Host len 20

   capture request header Referer len 60

   default_backend http-server

backend http-server   #后端web服务集群

   balance roundrobin  #调度算法模式

   server web1 192.168.10.150:81  check maxconn 4000  #后端web列表

   server web2 192.168.10.122:80  check maxconn 3000



作者:小沙弥Gavin
链接:https://www.jianshu.com/p/99e2bdddcfff


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消