美文网首页
Nginx负载均衡和节点检查

Nginx负载均衡和节点检查

作者: Nonni | 来源:发表于2019-04-08 09:08 被阅读0次

    a.使用语法:

    check interval=milliseconds [fall=count] [rise=count] [timeout=milliseconds] [default_down=true|false] [type=tcp|http|ssl_hello|mysql|ajp] [port=check_port]

    b.默认值:

    如果没有配置参数,默认值是:interval=30000 fall=5 rise=2 timeout=1000 default_down=true type=tcp

    c.上下文: upstream模块

    upstream mogo {

    server mogo:8080 weight=4;

    server mogo2:8080 weight=4;

    check interval=3000 fall=5 rise=2 timeout=1000;

    ip_hash;

    }

    对mogo负载均衡条目中的所有节点,每个3秒检测一次,请求 2 次正常则标记realserver状态为up,如果检测 5 次都失败,则标记 realserver的状态为down,超时时间为1秒.

    nginx负载均衡策略:

    a.RR(Round Robin-默认) - 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,会自动剔除。

    b.ip_hash - 客户端ip绑定,每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端的服务器,可以解决session问题。

    c.least_conn - 最少连接,下一个请求将被分配到活动连接数量最少的服务器。

    相关文章

      网友评论

          本文标题:Nginx负载均衡和节点检查

          本文链接:https://www.haomeiwen.com/subject/ipnmettx.html