章节目录

  • 后端服务器在负载均衡调度中的状态
  • backup 状态演示

后端服务器在负载均衡调度中的状态

参数 含义
down 当前的server暂时不参与负载均衡
backup 预留的备份服务器
max_fails 允许请求失败的次数
fail_timeout 经过max_fails服务暂停的时间默认10留给运维人员解决后端服务器问题的时间
max_conns 限制最大的接收的连接数

backup 状态演示

设置 nginx upstream server 状态:

upstream testUpstream {
   server eshop-cache04:8081 down;//不启用
   server eshop-cache04:8082 backup;//所有应用服务器失效状态下启用
   server eshop-cache04:8083 max_fails=1 fail_timeout=10s;//允许失败次数1次,失败1次后,暂停时间10s
}

重新加载配置文件

nginx -s reload

浏览器请求,观察响应结果

响应结果

如上图所示,多次请求 http://eshop-cache04/ 只显示可用后端服务器节点 eshop-cache04:8083。

iptables drop 8083 端口,不对外提供服务

iptables -I INPUT -p tcp --dport 8083 -j DROP

重新访问浏览器

8083对应服务迟迟不响应

最终响应结果为:
backup备份节点后端服务器响应请求

清除iptables 规则

iptables -F
page3对应后端应用服务器重新响应