nginx健康检测(ngx_http_upstream_check_module 淘宝)

来源:互联网 发布:什么是数据挖掘 编辑:程序博客网 时间:2024/04/27 01:01
1、首先去这里下载nginx的模块https://github.com/yaoweibin/nginx_upstream_check_module
下面是nginx打上模块补丁的安装

$ wget ‘http://nginx.org/download/nginx-1.0.14.tar.gz’
$ tar -xzvf nginx-1.0.14.tar.gz
$ cd nginx-1.0.14/
$ patch -p1 < /path/to/nginx_http_upstream_check_module/check.patch
注:因nginx版本更新,1.2以上版本的nginx,补丁为check_1.2.1+.patch
$ ./configure –add-module=/path/to/nginx_http_upstream_check_module
$ make
$ make install

之后在nginx.conf配置文件里面的upstream加入健康检查,如下:
upstream linuxyan {
server 192.168.0.21:80;
server 192.168.0.22:80;
check interval=3000 rise=2 fall=5 timeout=1000;
}

这里下面加的这句话我解释下,interval检测间隔时间,单位为毫秒,rsie请求2次正常的话,标记此realserver的状态为up,fall表示请求5次都失败的情况下,标记此realserver的状态为down,timeout为超时时间,单位为毫秒。
在server段里面可以加入查看realserver状态的页面
location /nstatus {
check_status;
access_log off;
#allow SOME.IP.ADD.RESS;
#deny all;
}

2、当type=tcp时,后台服务器,比如resin,已经启动,但其中一个应用有问题而没有启动时,是无法自动检测到这类问题。但如果resin本身就没有启动,则可以检测出来,并自动跳转。

  当type=http时,还在研究,待续。。。



0 0