zoukankan      html  css  js  c++  java
  • Haproxy 代理

    一:安装haproxy

      1:解压   编译   安装

      tar zxf haproxy-1.7.9.tar.gz 

          cd  haproxy-1.7.9

          uname -e

          make TARGET=linux2.6 PREFIX=/usr/local/haproxy

         make install PREFIX=/usr/local/haproxy

    二:创建haproxy配置文件

        mkdir /etc/haproxy

        cd /etc/haproxy/

        vi   haproxy.cfg

    ########################
    global
        log 127.0.0.1 local0
        log 127.0.0.1 local1 notice
        maxconn 4096
        user www
        group www
        daemon
        nbproc 8

    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代理192.168.6.140 22端口
    listen sshd
        bind 0.0.0.0:11000
        server 140_ssh 192.168.6.140:22 check inter 2000 rise 2 fall 5

    #Ha代理http
    listen 192.168.6.140_tomcat
        bind 0.0.0.0:11001
        mode http
        balance roundrobin
        server web1 192.168.6.140:8080 weight 1 maxconn 10000 check inter 3s rise 3 fall 3

    # Ha代理redis

    listen redis
        bind 0.0.0.0:9999
        balance leastconn
        mode tcp
        # redis 健康检查,确保只有master提供连接
        option tcp-check
        tcp-check connect
        tcp-check send PING
        tcp-check expect string +PONG
        tcp-check send info replication
        tcp-check expect string role:master
        tcp-check send QUIT
        tcp-check expect string +OK
        server redis01 127.0.0.1:6380 check port 6380 inter 5s fastinter 2s downinter 5s rise 3 fall 3
        server redis02 127.0.0.1:6381 check port 6381 inter 5s fastinter 2s downinter 5s rise 3 fall 3

    # Ha web页面配置

    listen status

        bind *:10000
        mode http
        stats enable
        stats uri /status
        stats refresh 5s
        stats show-node
        stats show-legends
        stats hide-version
        bind-process 2

    三:配置haproxy启动脚本

    cp /haproxy-1.7.9/examples/haproxy.init /etc/init.d/haproxy
    cp /usr/local/haproxy/sbin/haproxy /usr/sbin/
    chmod a+x /etc/init.d/haproxy

    四:启动haproxy服务

    /usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg

    /etc/init.d/haproxy start

  • 相关阅读:
    stm32 IO模式
    stm32的ADC
    bsp
    stm32的硬件调试设置
    RTC实时时钟
    快手2019笔试题 “回文子串" 解题思路
    C++内存修改器开源代码
    FC游戏修改教程(hack)小白文。
    GLFW+GLEW搭建opengl环境(备忘)
    8086 IO读写操作
  • 原文地址:https://www.cnblogs.com/happlyp/p/9771748.html
Copyright © 2011-2022 走看看