章节目录
- 后端服务器在负载均衡调度中的状态
- 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
浏览器请求,观察响应结果
![2836699-6b73617d25157516.png](https://i-blog.csdnimg.cn/blog_migrate/a5a3665ae221b0970210c6c065cea70b.webp?x-image-process=image/format,png)
响应结果
如上图所示,多次请求 http://eshop-cache04/ 只显示可用后端服务器节点 eshop-cache04:8083。
iptables drop 8083 端口,不对外提供服务
iptables -I INPUT -p tcp --dport 8083 -j DROP
重新访问浏览器
![2836699-b82fc6b68a47837f.png](https://i-blog.csdnimg.cn/blog_migrate/fccb6d86cc1c00d7958b162ddb463a52.webp?x-image-process=image/format,png)
8083对应服务迟迟不响应
最终响应结果为:
![2836699-e53d6f2043652844.png](https://i-blog.csdnimg.cn/blog_migrate/9d6583e2cbdbd8d9aa026c542625e763.webp?x-image-process=image/format,png)
backup备份节点后端服务器响应请求
清除iptables 规则
iptables -F
![2836699-c51a8edeb8503ec1.png](https://i-blog.csdnimg.cn/blog_migrate/c14a315266f5db6461957c1251524a2c.webp?x-image-process=image/format,png)
page3对应后端应用服务器重新响应