nginx 后端服务器健康检测验证

来源:本站原创 Linux 超过24 views围观 0条评论

健康检测验证

配置
upstream oaweb {
ip_hash;
server 172.16.1.25:80  max_fails=2 fail_timeout=10s;  #默认每1S检测一次 失败两次 10S内将不再分配连接
server 172.16.1.26:80  max_fails=2 fail_timeout=10s;
}

—-参数说明—-
max_fails=number      # 设定Nginx与服务器通信的尝试失败的次数。在fail_timeout参数定义的时间段内,如果失败的次数达到此值,Nginx就认为服务器不可用。在下一个fail_timeout时间段,服务器不会再被尝试。 失败的尝试次数默认是1。设为0就会停止统计尝试次数,认为服务器是一直可用的。 你可以通过指令proxy_next_upstream、fastcgi_next_upstream和 memcached_next_upstream来配置什么是失败的尝试。 默认配置时,http_404状态不被认为是失败的尝试。
fail_timeout=time       # 设定服务器被认为不可用的时间段以及统计失败尝试次数的时间段。在这段时间中,服务器失败次数达到指定的尝试次数,服务器就被认为不可用。默认情况下,该超时时间是10秒。
 

—19秒报错—服务器1.25
2017/09/18 18:25:19 [error] 14625#0: *101 connect() failed (110: Connection timed out) while connecting to upstream, client: 172.16.11.104, server: 172.16.9.69, request: "GET /wui/theme/ecology8/page/getRemindInfo.jsp?1=1505730337541= HTTP/1.1", upstream: "http://172.16.1.25:80/wui/theme/ecology8/page/getRemindInfo.jsp?1=1505730337541=", host: "172.16.9.69", referrer: "http://172.16.9.69/wui/main.jsp"
2017/09/18 18:25:36 [error] 14625#0: *156 connect() failed (110: Connection timed out) while connecting to upstream, client: 172.16.11.104, server: 172.16.9.69, request: "GET /login/Login.jsp HTTP/1.1", upstream: "http://172.16.1.25:80/login/Login.jsp", host: "172.16.9.69", referrer: "http://172.16.9.69/wui/main.jsp"
2017/09/18 18:25:39 [error] 14625#0: *156 connect() failed (110: Connection timed out) while connecting to upstream, client: 172.16.11.104, server: 172.16.9.69, request: "GET /wui/theme/ecology7/page/images/desc_wev8.png HTTP/1.1", upstream: "http://172.16.1.25:80/wui/theme/ecology7/page/images/desc_wev8.png", host: "172.16.9.69", referrer: "http://172.16.9.69/login/Login.jsp"
—33秒切换—实测试 20S左右
172.16.11.104 – – [18/Sep/2017:18:25:33 +0800] "GET /login/Login.jsp HTTP/1.1" 499 0 "http://172.16.9.69/wui/main.jsp" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" "-"
172.16.11.104 – – [18/Sep/2017:18:25:36 +0800] "GET /login/Login.jsp HTTP/1.1" 200 41418 "http://172.16.9.69/wui/main.jsp" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" "-"
172.16.11.104 – – [18/Sep/2017:18:25:39 +0800] "GET /wui/theme/ecology7/page/images/desc_wev8.png HTTP/1.1" 404 759 "http://172.16.9.69/login/Login.jsp" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" "-"
172.16.11.104 – – [18/Sep/2017:18:25:41 +0800] "GET /login/Login.jsp HTTP/1.1" 200 41418 "http://172.16.9.69/wui/main.jsp" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" "-"

文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3568转载请注明转自CCIE那点事
如果喜欢:点此订阅本站
  • 相关文章
  • 为您推荐
  • 各种观点