nginx服务器心跳监测 |
您所在的位置:网站首页 › http心跳检测 › nginx服务器心跳监测 |
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/ |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |