Nginx负载均衡后端健康检查
参考文档:https://www.cnblogs.com/kevingrace/p/6685698.html
本次使用第三方模块nginx_upstream_check_module的,要使用这个第三方模块首先您需要进行下载,然后通过patch命令将补丁打入您原有的Nginx源码中,并且重新进行编译安装。
下载nginx_upstream_check_module模块
wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master
解压
unzip master

解压后的Nginx和nginx_upstream_check_module-master在同一目录下

将补丁打入源码(没有patch命令使用yum -y install patch安装)
cd nginx-1.6.3
patch -p1 < ../nginx_upstream_check_module-master/check_1.5.12+.patch
出现以下代表成功(根据nginx版本选择不同的check)

编译安装nginx
./configure --prefix=/usr/local/nginx --add-module=../nginx_upstream_check_module-master --with-http_stub_status_module
make && make install
通过以上的步骤,第三方的nginx_upstream_check_module模块就在Nginx中准备好了。接下来我们讲解一下如何使用这个模块。首先看一下upstream的配置信息
interval:必要参数,检查请求的间隔时间。
fall:当检查失败次数超过了fall,这个服务节点就变成down状态。
rise:当检查成功的次数超过了rise,这个服务节点又会变成up状态。
timeout:请求超时时间,超过等待时间后,这次检查就算失败。
default_down:后端服务器的初始状态。默认情况下,检查功能在Nginx启动的时候将会把所有后端节点的状态置为down,检查成功后,在置为up。
type:这是检查通信的协议类型,默认为http。以上类型是检查功能所支持的所有协议类型。
一个完整的nginx配置信息如下nginx.conf
worker_processes 4;
error_log logs/error.log;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream ekp {
server 10.1.1.131:8080;
server 10.1.1.132:8080;
server 10.1.1.135:8080;
check interval=3000 rise=2 fall=5;
check_keepalive_requests 100;
check_http_send "HEAD / HTTP/1.1\r\nConnection: keep-alive\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
server {
listen 80;
server_name www.test.com;
access_log /usr/local/nginx/logs/access.log;
location / { root ekp;
index index.html index.htm index.jsp;
proxy_pass http://ekp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 200m;
proxy_connect_timeout 10;
proxy_read_timeout 300;
proxy_send_timeout 300;
}
location /nstatus {
check_status;
access_log on;
}
}
}
PS:这里配置按照参考文档加timeout=1000 type=http 否则无法负载均衡
访问测试 http://ip/nstatus

Nginx负载均衡后端健康检查的更多相关文章
- Nginx负载均衡后端健康检查(支持HTTP和TCP)
之前有一篇文章记录nginx负载均衡后端检查,链接为 https://www.cnblogs.com/minseo/p/9511456.html 但是只包含http健康检查不包含tcp下面安装ngin ...
- nginx高性能WEB服务器系列之六--nginx负载均衡配置+健康检查
nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...
- Nginx负载均衡之健康检查
负载均衡实例 http{ upstream myserver { server 10.10.10.1 weight=3 max_fails=3 fail_timeout=20s; server 10. ...
- Nginx负载均衡 后端服务器怎么共享Session 问题
Nginx负载均衡 Nginx负载均衡一些基础知识: nginx 的 upstream目前支持 4 种方式的分配 1).轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端 ...
- Nginx 负载均衡 后端服务器获取前端用户真实IP
Nginx 后端 日志文件 获取的都是 前端 负载均衡器的IP 想要获取用户的真实IP 必须 使用Nginx 的模块 http_realip_module 才行!! 1. 编译 Nginx 的时候 ...
- Nginx 负载均衡 后端 监控检测 nginx_upstream_check_module 模块的使用
在使用nginx 的负载均衡 中,我们通常会使用到 Nginx 自带的 ngx_http_proxy_module 健康检测模块. ngx_http_proxy_module 自带的 健康检测模块参数 ...
- nginx负载均衡后端tomcat无法加载js资源
JS或css无法完全加载 nginx的代理缓存区,默认较小导致部分文件出现加载不全的问题,比较典型的如jQuery框架,可以通过配置调整nginx的缓存区即可.主要参考proxy参数 最终完整配置如下 ...
- Nginx负载均衡中后端节点服务器健康检查的操作梳理
正常情况下,nginx做反向代理,如果后端节点服务器宕掉的话,nginx默认是不能把这台realserver踢出upstream负载集群的,所以还会有请求转发到后端的这台realserver上面,这样 ...
- Nginx负载均衡中后端节点服务器健康检查的一种简单方式
摘自:https://cloud.tencent.com/developer/article/1027287 一.利用nginx自带模块ngx_http_proxy_module和ngx_http_u ...
随机推荐
- shell编程学习笔记(五):Shell中脚本的参数
在执行Shell脚本的时候,可以在执行时带上参数,相当于传递参数给脚本,下面我们看一下怎么使用这个参数 以下蓝色字体部分为Linux命令,红色字体的内容为输出的内容: # cd /opt/script ...
- ionic BUILD FAILED
BUILD FAILED Total time: 24.572 secs FAILURE: Build failed with an exception. What went wrong: Execu ...
- TensorFlow实战Google深度学习框架10-12章学习笔记
目录 第10章 TensorFlow高层封装 第11章 TensorBoard可视化 第12章 TensorFlow计算加速 第10章 TensorFlow高层封装 目前比较流行的TensorFlow ...
- iOS CALayer 绘图模糊有锯齿的解决方案
在CALayer中绘制图形会出现锯齿和模糊,同样绘图在UIView中就没有问题.经查资料发现不自动处理两倍像素的情况. 解决方案为:设置layer的contentsScale属性为[[UIScreen ...
- html5利用websocket完成的推送功能(tomcat)
html5利用websocket完成的推送功能(tomcat) 利用websocket和java完成的消息推送功能,服务器用的是tomcat7.0.42,一些东西是自己琢磨的,也不知道恰不恰当,不恰当 ...
- C++ thread类多线程编程
https://blog.csdn.net/dcrmg/article/details/53912941 多线程操作的thread类,简单多线程示例: #include <iostream> ...
- appium 报错
2018-11-27 18:05:56:313 - [Logcat] Logcat terminated with code 0, signal null 2018-11-27 18:05:56:31 ...
- 安全工具-Hydra
Hydra v8.2 (c) 2016 by van Hauser/THC - Please do not use in military or secret service organization ...
- Xshell Plus
https://xshell.woytu.com 一个在线生成Xshell Plus 等软件的注册码的网址: https://xshell.spppx.org/
- zoj 3430 Detect the Virus(AC自己主动机)
Detect the Virus Time Limit: 2 Seconds Memory Limit: 65536 KB One day, Nobita found that his co ...