Centos 6.9 Nginx 1.13.9 配置健康检测模块

nginx安装
https://blog.csdn.net/hanzheng260561728/article/details/79553734

下载nginx检查模块
https://download.csdn.net/download/hanzheng260561728/10479330

解压nginx检查模块
unzip healthcheck_nginx_upstreams-master.zip

cd nginx-1.13.9
patch -p1 < ../healthcheck_nginx_upstreams-master

编译nginx
./configure --user=www --group=www --prefix=/usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_realip_module --with-stream --with-stream_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_dav_module --with-http_sub_module  --with-http_gunzip_module --with-pcre --with-debug --add-module=/root/healthcheck_nginx_upstreams-master


执行make, 注意不需要make install
make

平滑升级,拷贝nginx二进制文件
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

拷贝新生成的nginx二进制文件到指定目录
cp nginx-1.13.9/objs/nginx /usr/local/nginx/sbin/

执行nginx升级命令
make upgrade

查看升级是否成功
 /usr/local/nginx/sbin/nginx -V

查看 PID进程
ps -ef |grep nginx


配置实现nginx带健康状态的负载均衡
upstream Redis {  
 healthcheck_enabled;        #开启健康探测功能
 healthcheck_delay 1000;     #设置健康检测的时延;即对同一台RS两次检测之间的时间间隔,单位毫秒,默认为1000
 healthcheck_timeout 1000;   #设置一次健康检测的超时时间

 healthcheck_failcount 3; 

  #后方某台服务器有一次检测不到即视为宕掉;即对同一台RS检测成功或失败多少次,才决定其成功或失败,并实现启用和禁用此服务

  healthcheck_send "GET /.health HTTP/1.0";

#使用GET方法访问后方服务器站点下的.health来进行探测;即从RS上获得用于检测健康状态的文件,默认只支持http 1.0协议

}

location /monyog/ {
        healthcheck_status;
        proxy_pass http://192.168.31.13:5555/;
       }

猜你喜欢

转载自blog.csdn.net/hanzheng260561728/article/details/80695229