zoukankan      html  css  js  c++  java
  • 搭建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

  • 相关阅读:
    HDU
    POJ
    快速幂运算
    RocketMQ集群
    RocketMQ角色介绍
    RocketMQ初探
    MySQL 串行隔离级别小记
    分布式事务笔记
    MySQL分库分表篇
    MySQL主从篇
  • 原文地址:https://www.cnblogs.com/happlyp/p/6009505.html
Copyright © 2011-2022 走看看