|
fail_timeout,在经验了max_fails次失败后,停息处事的时刻。max_fails可以和fail_timeout一路行使,举办康健状态搜查。
- [root@nginx ~]# vim /etc/nginx/nginx.conf
- upstream webservers {
- server 192.168.18.201 weight=1 max_fails=2 fail_timeout=2;
- server 192.168.18.202 weight=1 max_fails=2 fail_timeout=2;
- }
10.从头加载一下设置文件
- [root@nginx ~]# service nginx reload
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- 从头载入 nginx: [确定]
从头载入 nginx: [确定]
11.遏制处事器并测试
先遏制Web1,举办测试。
- [root@web1 ~]# service httpd stop
- 遏制 httpd: [确定]

注,各人可以看到,此刻只能会见Web2,再从头启动Web1,再次会见一下。
- [root@web1 ~]# service httpd start
- 正在启动 httpd: [确定]

注,各人可以看到,此刻又可以从头会见,声名nginx的康健状态查检设置乐成。但各人想一下,假如不幸的是全部处事器都不能提供处事了怎么办,用户打开页面就会呈现堕落页面,那么会带来用户体验的低落,以是我们能不能像设置LVS是设置sorry_server呢,谜底是可以的,但这里不是设置sorry_server而是设置backup。
12.设置backup处事器
- [root@nginx ~]# vim /etc/nginx/nginx.conf
- server {
- listen 8080;
- server_name localhost;
- root /data/www/errorpage;
- index index.html;
- }
- upstream webservers {
- server 192.168.18.201 weight=1 max_fails=2 fail_timeout=2;
- server 192.168.18.202 weight=1 max_fails=2 fail_timeout=2;
- server 127.0.0.1:8080 backup;
- }
- [root@nginx ~]# mkdir -pv /data/www/errorpage
- [root@nginx errorpage]# cat index.html
- <h1>Sorry......</h1>
13.从头加载设置文件
- [root@nginx errorpage]# service nginx reload
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- 从头载入 nginx: [确定]
14.封锁Web处事器并举办测试
- [root@web1 ~]# service httpd stop
- 遏制 httpd: [确定]
- [root@web2 ~]# service httpd stop
- 遏制 httpd: [确定]

注,各人可以看到,当全部处事器都不能事变时,就会启动备份处事器。好了,backup处事器就设置到这里,下面我们来设置ip_hash负载平衡。
15.设置ip_hash负载平衡 (编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|