nginx服务器心跳监测-第三方插件nginx_upstream_check_module

linux默认使用centos7系统

1.首先安装nginx

下载解压nginx包,在/opt/local/目录中下载包并解压
# mkdir -p /opt/local
# cd /opt/local
# wget http://nginx.org/download/nginx-1.18.0.tar.gz
# tar -zxvf nginx-1.18.0.tar.gz
# mv nginx-1.18.0 nginx
# mkdir -p /opt/local/nginx/module
# mkdir -p /opt/local/nginx/logs

 

2.下载nginx_upstream_check_module插件
# cd /opt/local/nginx/module
# git clone https://github.com/yaoweibin/nginx_upstream_check_module.git
(安装git命令:yum -y install git)

 

3.插件环境安装及编译
# cd  /opt/local/nginx/
# yum -y install gcc-c++                         (如果是ubuntu,则是sudo apt-get install )
# yum -y install pcre pcre-devel             (如果是ubuntu,则是sudo apt-get install libpcre3 libpcre3-dev)

# patch -p1 < /opt/local/nginx/module/nginx_upstream_check_module/check_1.14.0+.patch   #(打补丁这一步千万不能遗漏!!!
# ./configure --prefix=/opt/local/nginx --add-module=/opt/local/nginx/module/nginx_upstream_check_module --conf-path=/opt/local/nginx/conf/nginx.conf 
# make && make install


如果编译最后出现以下信息,不用管,没啥问题:
cp: ‘conf/koi-win’ and ‘/opt/local/nginx/conf/koi-win’ are the same file
make[1]: *** [install] Error 1
make[1]: Leaving directory `/opt/local/nginx'
make: *** [install] Error 2

 

4.启动或停止服务
# cd  /opt/local/nginx/
启动nginx服务
# ./sbin/nginx &

停止nginx服务
# ./sbin/nginx -s stop

重启nginx服务
# ./sbin/nginx -s reload -c /opt/local/nginx/conf/nginx.conf

 

5.修改配置文件nginx.conf

在http节点下增加upstream,里面填写要监测的nginx服务器信息,例如

对应在server中增加个location,用来查询upstream中的几个nginx服务的实时状态。

查看所有状态的html格式:http://localhost:80/backend_status

要想看具体状态,后面可以跟上?status=[up|down]

要想看具体格式的数据,后面可以跟上?format=[html|json|csv]

例如:

查看正常状态的json格式:http://localhost:80/backend_status?status=up&format=json

 

 

6.至于插件中upstream的各项参数含义,参考https://github.com/yaoweibin/nginx_upstream_check_module/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值