zoukankan      html  css  js  c++  java
  • LB_nginx调度4和7案例

    nginx1   :222   略

    nginx2   :223   略

    mysql_nfs   :22 略

    LB_nginx    :21

    /etc/nginx/nginx.conf 中添加4层代理

    include /etc/nginx/L4.conf/*.conf;

    -----------------------------------------------------------------------------------------

    stream {
    upstream ssh222 {
    server 192.168.3.222:22;
    }
    upstream ssh223 {
    server 192.168.3.223:22;
    }
    upstream ssh22 {
    server 192.168.3.22:22;
    }
    upstream mysql {
    server 192.168.3.22:3306;
    }
    server {
    listen 9222;
    proxy_pass ssh222;
    proxy_connect_timeout 1s;           //链接超时时间
    proxy_timeout 300s;      //响应超时时间
    }
    server {
    listen 9223;
    proxy_pass ssh223;
    proxy_connect_timeout 1s;
    proxy_timeout 300s;
    }
    server {
    listen 922;
    proxy_pass ssh22;
    proxy_connect_timeout 1s;
    proxy_timeout 300s;
    }
    server {
    listen 3306;
    proxy_pass mysql;
    proxy_connect_timeout 1s;
    proxy_timeout 300s;
    }
    }

    -----------------------------------------------------------------------------------------

    [root@localhost ~]# cat /etc/nginx/conf.d/default.conf
    upstream le {
    server 192.168.3.223:80;
    server 192.168.3.222:80;
    }
    upstream l {
    server 192.168.3.223:81;
    server 192.168.3.222:81;
    }
    server {
    listen 80;
    server_name www.le.com;
    location / {
    proxy_pass http://le;
    include proxy_params;
    }
    }
    server {
    listen 80;
    server_name www.l.com;
    location / {
    proxy_pass http://l;
    include proxy_params;
    }
    }

    -----------------------------------------------------------------------------------------

    负载均衡配置端口相当于端口映射

     

    负载均衡后端类型

    down 关闭,不参与负载均衡

    backup  备份状态,其他都挂了这个就起来

    max_fails  最大链接超时

    fail_timeout  文件超时时间

    max_conns  链接超时后多少秒关闭

    算法:

    rr:轮询(默认)

    wrr:加权轮询(默认weight=1,看设备性能设置)

    ip_hash 根据ip分配

    url_hash 根据url分配

    least_conn 最少连接数分配

    wlc 加权最少链接数

    --------------------------------------------

    L4用stream{}

    L7用upstream{}

  • 相关阅读:
    python模块添加
    Python 的列表排序
    python中文处理问题
    排序算法堆排序
    搜索二分搜索
    排序算法(随机)快速排序(递归)
    排序算法计数排序
    OO设计原则总结
    异常控制以及进程调度
    ubuntu12.04 alternate win7 双系统安装
  • 原文地址:https://www.cnblogs.com/Leaders543/p/12502981.html
Copyright © 2011-2022 走看看