nginx模块之ngx_http_upstream_module
来源:互联网 发布:数控龙门铣编程视频 编辑:程序博客网 时间:2024/06/15 04:33
说明:将多个后端主机定义为服务器组,而后可由proxy_pass,fastcgi_pass,uwsgi_pass,scgi_pass和memcached_pass进行调用
1.定义后端服务器组
Syntax: upstream name { ... }
Default: —
Context: http
说明:
定义一组服务器。服务器可以在不同端口上侦听。
2.定义服务器的地址和相关的参数
Syntax: server address [parameters];
Default: —
Context: upstream
地址格式:
IP[:port]
HOSTNAME[port]
参数:
weight=number:服务器权重
max_conns=number:最大连接次数
max_fails=number:最大失败重试次数
fail_timeout=time:设置服务器被识别为不可用超时时长
backup:备用主机
down:标记该服务器不可用
演示:
配置nginx负载均衡
编辑/etc/nginx/nginx.conf
upstream websrvs {
server 192.168.80.11:80 weight=1;
server 192.168.80.12:80 weight=1;
}
在server中指定:
proxy_pass http://websrvs
3.源地址哈希调度算法
Syntax: ip_hash;
Default: —
Context: upstream
说明:
Specifies that a group should use a load balancing method where requests
are distributed between servers based on client IP addresses. The first
three octets of the client IPv4 address, or the entire IPv6 address, are
used as a hashing key. The method ensures that requests from the same client
will always be passed to the same server except when this server is unavailable.
In the latter case client requests will be passed to another server. Most probably,
it will always be the same server as well.
4.最少连接调度算法
Syntax: least_conn;
Default: —
Context: upstream
5.保持连接
Syntax: keepalive connections;
Default: —
Context: upstream
作用:节约套接字
1.定义后端服务器组
Syntax: upstream name { ... }
Default: —
Context: http
说明:
定义一组服务器。服务器可以在不同端口上侦听。
2.定义服务器的地址和相关的参数
Syntax: server address [parameters];
Default: —
Context: upstream
地址格式:
IP[:port]
HOSTNAME[port]
参数:
weight=number:服务器权重
max_conns=number:最大连接次数
max_fails=number:最大失败重试次数
fail_timeout=time:设置服务器被识别为不可用超时时长
backup:备用主机
down:标记该服务器不可用
演示:
配置nginx负载均衡
编辑/etc/nginx/nginx.conf
upstream websrvs {
server 192.168.80.11:80 weight=1;
server 192.168.80.12:80 weight=1;
}
在server中指定:
proxy_pass http://websrvs
3.源地址哈希调度算法
Syntax: ip_hash;
Default: —
Context: upstream
说明:
Specifies that a group should use a load balancing method where requests
are distributed between servers based on client IP addresses. The first
three octets of the client IPv4 address, or the entire IPv6 address, are
used as a hashing key. The method ensures that requests from the same client
will always be passed to the same server except when this server is unavailable.
In the latter case client requests will be passed to another server. Most probably,
it will always be the same server as well.
4.最少连接调度算法
Syntax: least_conn;
Default: —
Context: upstream
5.保持连接
Syntax: keepalive connections;
Default: —
Context: upstream
作用:节约套接字
阅读全文
0 0
- nginx模块之ngx_http_upstream_module
- Nginx 负载均衡模块 ngx_http_upstream_module 详述
- Nginx 负载均衡模块 ngx_http_upstream_module 详述
- Nginx 负载均衡模块 ngx_http_upstream_module 详述
- Nginx 负载均衡模块 ngx_http_upstream_module 详述
- Nginx模块之SessionSticky
- Nginx之proxy_store模块
- nginx模块之ngx_http_proxy_module
- nginx模块之ngx_http_headers_module
- Nginx之hander模块
- Nginx之http_image_filter_module模块使用
- nginx之chunked模块解析
- nginx四 之缓存模块
- NGINX模块开发 之 验证URL参数
- 《深入理解Nginx》之HTTP模块
- nginx模块开发之handler函数
- nginx配置详解之main模块
- nginx配置详解之events模块
- CDN加速,App与Big-man
- 【23种设计模式】结构型模式 > 代理模式
- Oracle中rownum和rowid虽然是同为一个服务却有很大不同
- 如何在控制台输出mybatis所执行的SQL语句(配置LOG4J文件)
- 串口通信相关知识
- nginx模块之ngx_http_upstream_module
- 用python字典(dict)获取更多的数据
- Java HashMap遍历方式探讨
- Spring AOP
- SD卡fat32文件格式说明
- 如何将session存入redis或memcache
- Kotlin高阶函数及Lambda表达式解析
- Struts框架中的DispathchAction
- lnmp 环境执行yii项目出错 require(): open_basedir restriction in effect 错误