状态 | 概述 |
down |
当前的server暂时不参与负载均衡 |
backup |
预留的备份服务器 |
max_fails |
允许请求失败的次数 |
fail_timeout |
经过max_fails失败后, 服务暂停时间 |
max_conns |
限制最大的接收连接数 |
1.down状态配置测试
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80 down;
server 172.16.1.8:80;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}
2.backup状态测试
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80;
server 172.16.1.8:80;
server 172.16.1.10:80 backup;
server 172.16.1.11:80 backup;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}
3.max_fails配置
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80 max_fails=3 fail_timeout=10s;
server 172.16.1.8:80;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}
4.测试max_conns最大TCP连接数
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80 max_conns=10;
server 172.16.1.8:80;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}