• HAProxy 实践(一)


    运行环境

    OS: Deiban 7
    软件:haproxy 1.5.8
    
    HTTP Server:
    192.168.99.1:8520
    192.168.99.1:8530
    192.168.99.1:8540
    192.168.99.1:8550
    
    MySQL Server:
    192.168.99.1:3306
    

    按照该配置在命令行下执行

    #可能需要管理员权限
    sudo haproxy -d -f ./haproxy.cfg
    

    HTTP访问地址

    http://localhost:8081
    

    MySQL访问地址

    数据库代理访问未测试

    localhost:3306
    

    配置内容

    #file haproxy.cfg
    lobal
            log /dev/log    local0
            log /dev/log    local1 notice
            chroot /var/lib/haproxy
            pidfile /var/run/haproxy.pid
            maxconn 4096
            stats socket /run/haproxy/admin.sock mode 660 level admin
            stats timeout 30s
            user haproxy
            group haproxy
            daemon
            nbproc 1
    
            # Default SSL material locations
            ca-base /etc/ssl/certs
            crt-base /etc/ssl/private
    
            # Default ciphers to use on SSL-enabled listening sockets.
            # For more information, see ciphers(1SSL). This list is from:
            #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
            ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
            ssl-default-bind-options no-sslv3
    
    # common defaults that all the ‘listen’ and ‘backend’ sections will
    # use if not designated in their block
    
    defaults
            log     global
    #       mode    http
            mode    tcp
    #       option  httplog
            option  tcplog
            option  dontlognull
            option  redispatch      
            retries 3
            timeout http-request 10s
            timeout connect 1m
            timeout connect 10s
            timeout client 1m 
            timeout server 1m 
            timeout http-keep-alive 10s 
            timeout check 10s 
            maxconn 3000
            errorfile 400 /etc/haproxy/errors/400.http
            errorfile 403 /etc/haproxy/errors/403.http
            errorfile 408 /etc/haproxy/errors/408.http
            errorfile 500 /etc/haproxy/errors/500.http
            errorfile 502 /etc/haproxy/errors/502.http
            errorfile 503 /etc/haproxy/errors/503.http
            errorfile 504 /etc/haproxy/errors/504.http
    
    listen mysql_proxy :3306
            mode    tcp
            balance roundrobin
            server  mysql_1 192.168.99.1:3306 check inter 5000 rise 2 fall 3
            server  mysql_2 192.168.99.1:3306 check inter 5000 rise 2 fall 3
    
    listen http_proxy :8081
            mode    http
            option  httplog
            stats   enable
            stats   uri       /stats
            stats   refresh   5s
            server  php_52 192.168.99.1:8520 check inter 5000 rise 2 fall 3
            server  php_53 192.168.99.1:8530 check inter 5000 rise 2 fall 3
            server  php_54 192.168.99.1:8540 check inter 5000 rise 2 fall 3
            server  php_56 192.168.99.1:8560 check inter 5000 rise 2 fall 3
    
    -----------------------------------------------------
    说明:
      a).代码仅供学习交流
      b).本文根据自身经验及网络总结所作,如有错误,谢谢指教
      c).转载请注明出处。
    -----------------------------------------------------
  • 相关阅读:
    TreeMap
    索引
    B-树、B+树
    硬盘速度、存储方式
    2-3树
    多叉树、2-3-4树
    红黑树
    平衡树、AVL树
    树、多路树、二叉树
    Java实现后缀表达式建立表达式树
  • 原文地址:https://www.cnblogs.com/xqbumu/p/5227660.html
Copyright © 2020-2023  润新知