• 搭建haproxy


    1:下载haproxy
    wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz
    2:解压,编译,安装
    tar zxf haproxy-1.3.20.tar.gz
    cd haproxy-1.3.20
    uname -a
    make TARGET=linux2.6 PREFIX=/usr/local/product/haproxy-1.3.20
    make install PREFIX=/usr/local/product/haproxy-1.3.20
    3:ln -s /usr/local/product/haproxy-1.5.9 /usr/local/haproxy
    4:创建haproxy配置文件
    mkdir /etc/haproxy
    cd /etc/haproxy
    vi haproxy.cfg
    ########################
    global
      log 127.0.0.1 local0
      log 127.0.0.1 local1 notice
      #log loghost local0 info
      maxconn 4096
      #chroot /usr/share/haproxy
      user www
      group www
      daemon
      nbproc 8
      #debug
      #quiet

    defaults
      log global
      mode tcp
      option tcplog
      option dontlognull
      retries 3
      option redispatch
      maxconn 2000
      timeout connect 50000
      timeout client 50000
      timeout server 50000

    #Ha代理mysql
    listen mysql_db 0.0.0.0:3306
      server db_1 rdsh0t197b6ly9dth6c5.mysql.rds.aliyuncs.com:3306 check inter 2000 rise 2 fall 5

    #Ha代理http
    listen http_app 0.0.0.0:8080
      mode http
      option httplog
      balance roundrobin
      server app1 172.21.8.188:80 cookie app1 weight 5 check inter 2000 rise 2 fall 3

    #HA web页面
    #没有验证过
    listen  admin_stats
            bind  0.0.0.0:81
            mode  http
            stats refresh 30s
            stats uri /haproxy-status
            stats realm Global statistics
            stats auth httx:abc(用户名:密码)
     
    #HA代理多台机器
    #没有考证过
    listen proxy-gps-smart
            bind     0.0.0.0:9001
            mode     tcp
            option   tcplog
            balance  leastconn
            maxconn  200000
            option   tcpka
            server   gps63 172.17.100.63:2966 weight 1 check port 2966 inter 1s rise 2 fall 2
            server   gps64 172.17.100.64:2966 weight 1 check port 2966 inter 1s rise 2 fall 2
            server   gps65 172.17.100.65:2966 weight 1 check port 2966 inter 1s rise 2 fall 2
            server   gps66 172.17.100.66:2966 weight 1 check port 2966 inter 1s rise 2 fall 2
          server   gps67 172.17.100.67:2966 weight 1 check port 2966 inter 1s rise 2 fall 2



    5:启动haproxy
    /usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg

    6:haproxy 启动
    cp /haproxy-1.3.20/examples/haproxy.init /etc/init.d/haproxy
    cp /usr/local/haproxy/sbin/haproxy /usr/sbin/
    chmod a+x /etc/init.d/haproxy

  • 相关阅读:
    R语言数据集合
    转:EXCEL中如何获取从某一字符开始到最右边字符串
    转:EXCEL打乱顺序
    转:excel中怎样做柱状图
    转:linux复制/剪切文件到另一个文件夹
    转:Linux常用命令
    转:怎么在一张PPT里设置很多步骤出现的内容呀
    禅道分析
    转:BUG的严重级别分类 BUG状态标准
    转:Bug的严重等级和优先级
  • 原文地址:https://www.cnblogs.com/happlyp/p/6009505.html
Copyright © 2020-2023  润新知