zoukankan      html  css  js  c++  java
  • Soat控制HAProxy 动态增减服务器

    Soat控制HaProxy 动态增减服务器

    安装HaProxy-1.5.18:

    yum install haproxy -y
    yum install socat -y
    

    HaProxy-1.5.18 配置:

    
    global
        log         127.0.0.1 local2
        chroot      /var/lib/haproxy
        pidfile     /var/run/haproxy.pid
        maxconn     4000
        user        haproxy
        group       haproxy
        daemon
        # turn on stats unix socket  
        # 这里很重要,level为admin,否则使用socat时会提示权限拒绝
        stats socket /var/lib/haproxy/stats  mode 600 level admin
    
    defaults
        mode                      tcp
        log                     global
        option                  dontlognull
        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
    
    frontend tcp
    bind 0.0.0.0:6379        #发起http请求80端口,会被转发到设置的ip及端口
    default_backend app
    backend app
        balance     roundrobin
        server  redis1 10.10.116.206:6379 check
        server  redis2 10.10.48.62:6379 check
    
    
    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
    listen status
            bind *:9090
            stats enable
            stats hide-version
            #stats scope . //限定报告的区段,可以使用"listen","frontend","backend"区段的名称,"."表示当前区段
            stats uri /haproxy?stats //修改url
            stats realm "HAProxy statistics" //提示信息
            stats auth admin:123445 //启用认证
            #stats admin if TRUE //启用管理员模式,可以控制后端服务器
    

    haproxy 开启自定义日志:

    vim /etc/rsyslog.conf 
    # 下面2行的注释去掉
    $ModLoad imudp                           
    $UDPServerRun 514
    
    # 新增加下面这行,位置可以自己定义 但目录一定要存在和有权限写入
    local2.* /data/logs/haproxy.log
    
    # 重启rsyslog 
    /etc/init.d/rsyslog restart
    
    # 查看日志:
    tail -f /data/logs/haproxy.log 
    

    Socat 控制Haproxy:

    # 查看haproxy的info 信息:
    echo "show info" | socat stdio /var/lib/haproxy/stats 
    
    # 查看haproxy 的帮助信息:
    echo "help" | socat stdio /var/lib/haproxy/stats 
    
    # 关闭app组内的redis1 服务器:
    echo "disable server app/redis1" | socat stdio /var/lib/haproxy/stats 
    
    # 开启app组内的redis1 服务器:
    echo "enable server app/redis1" | socat stdio /var/lib/haproxy/stats 
    
    # 查看status 信息:
    echo "show stat " | socat stdio /var/lib/haproxy/stats 
    
  • 相关阅读:
    GDI+之图形缩放之画蛇添足
    Could not load type 'Microsoft.Expression.DesignModel.Core.ISharedInstanceBuilder'
    Win7自带显示驱动在Thinkpad T400中的异常:Display Driver Stopped Responding and Has Recovered
    Silverlight5.0中,ImageBrush不再支持TileMode属性
    GDI+中启动双缓存后缩放失效的问题
    Result of Transforming XML by XSLT in Different Browsers
    Difference of Getting DOM ElementsM Between IE6 & FF2
    项目进入R1 Preview,总算可以偷着乐会了
    原来mod_cache是需要代理的
    在Fedora11上安装Chrome
  • 原文地址:https://www.cnblogs.com/zhenxing06/p/12840258.html
Copyright © 2011-2022 走看看