In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Nginx1.10.1 adds back-end web health check upstream_check module
Due to the service needs of the company, it is necessary to balance the reverse proxy and replication in the established architecture into a cluster to cope with the high turnover.
However, after building a cluster structure, the remote web machine at the back end needs to rely on nginx's upstream_check for health check.
Experimental environment:
The application of IP operating system involves software
Load balancing layer 172.16.22.2 CentOS 7.2 nginx-1.10.1
Backend web01 172.16.22.3 CentOS 7.2 Tomcat-7.0.72
Backend web02 172.16.22.4 CentOS 7.2 Tomcat-7.0.72
The following settings are only made in the load balancer layer, and operate on a single server. The cluster members of another load balancer machine can also follow the steps below.
Here are my general installation steps:
1. Source code installed nginx1.10.1 version
two。 First of all, I downloaded the nginx_upstream_check_module model.
Wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/master.zip
3. Unlock the master.zip
[root@z soft] # unzip nginx_upstream_check_module.zip
Enter into the nginx_upstream_check_module
[root@z nginx_upstream_check_module] # pwd
/ data0/soft/nginx_upstream_check_module
-- mainly to make preparations for the convenience of doing a good job later.
4. Enter into the source code directory of nginx1.10.1
[root@z ~] # cd / usr/local/nginx-1.10.1
5. Due to the need to perform a post-mortem health check on nginx, it is necessary to complete the installation of the order.
[root@z nginx-1.10.1] # rpm-qa | grep patch
Patch-2.7.1-8.el7.x86_64
If patch is not installed, yum install-y patch
6. Enter nginx-1.10.1 after upstream_check entry.
[root@z nginx-1.10.1] # patch-p0
< /data0/soft/nginx_upstream_check_module/check_1.11.1+.patch 7.打完補丁就進行編譯 因為需要添加-add-module=/root/nginx_upstream_check_module-master 如果其他编译参数和之前保持一致,但又不记得之前的编译参数, 可使用 nginx -V 命令查看。 [root@z nginx-1.10.1]# /usr/local/nginx/sbin/nginx -V nginx version: nginx/1.10.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre 所以就進行編譯,只要在後面添加upstream_check_module-master 即如下: [root@z nginx-1.10.1]#./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/tmp/nginx/client/ \ --http-proxy-temp-path=/var/tmp/nginx/proxy/ \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi \ --with-pcre \ --add-module=/data0/soft/nginx_upstream_check_module-master/ [root@z nginx-1.10.1]# make && make install [root@z nginx-1.10.1]# make clean #注:因為我是在原來已安装的版本上安插nginx_upstream_check_module模塊,所以nginx.conf是在原來的基礎上生成的,所以不需要另外備份。要是谨慎点還是把原來的配置檔案備份一下,再進行編譯安裝。 8.到了这,就是重點了,配置nginx檢測後端節點健康狀況 vim /etc/nginx.conf 添加upstream模塊 upstream information{ server 172.16.22.3:80 max_fails=2; server 172.16.22.4:80 max_fails=2; check interval=3000 rise=2 fall=5 timeout=1000 type=http; } --嵌套進http內即可 #注,指令参数的意义 - interval:向后端发送的健康检查包的间隔ms。 - fall(fall_count): 如果连续失败次数达到fall_count,服务器就被认为是down。 - rise(rise_count): 如果连续成功次数达到rise_count,服务器就被认为是up。 - timeout: 后端健康请求的超时时间。 - default_down: 设定初始时服务器的状态,如果是true,就说明默认是down的,如果是false,就是up的。 默认值是true,也就是一开始服务器认为是不可用,要等健康检查包达到一定成功次数以后才会被认为是健康的。 - type:健康检查包的类型,现在支持以下多种类型 - tcp:简单的tcp连接,如果连接成功,就说明后端正常。 - ssl_hello:发送一个初始的SSL hello包并接受服务器的SSL hello包。 - http:发送HTTP请求,通过后端的回复包的状态来判断后端是否存活。 - mysql: 向mysql服务器连接,通过接收服务器的greeting包来判断后端是否存活。 - ajp:向后端发送AJP协议的Cping包,通过接收Cpong包来判断后端是否存活。 - port: 指定后端服务器的检查端口。你可以指定不同于真实服务的后端服务器的端口, 比如后端提供的是443端口的应用,你可以去检查80端口的状态来判断后端健康状况。默认是0,表示跟后端server提供真实服务的端口一样。 9.通过访问nginxstatus頁面,查看后端机器是否真的連接上了的准备工作 vim /etc/nginx.conf 配置负载均衡层实时连接状态展示页面,在nginx.conf上添加上 location /nginxstatus{ stub_status on; access_log /usr/local/nginx/logs/status.log; auth_basic "nginxstatus"; } 查看后端網頁的連接數,查看upstream check status,即后端web健康状况 #添加了nginx_upstream_check_module模块之后,该项生效 #主要为了测试nginx_upstream_check_module模块是否好使 location /zstatus{ check_status; access_log off; #allow IP; #deny all; } 10.配置完畢,需要重啟nginx服务 先檢查配置信息是否無誤 [root@z nginx-1.10.1]#/usr/local/nginx/sbin/nginx -t 平滑重啟nginx服務 [root@z nginx-1.10.1]#/usr/local/nginx/sbin/nignx -s reload 可以在網頁上瀏覽訪問http://172.16.22.2/nginxstatus ,查看nginx的连接状态Visit http://172.16.22.2/informationstatus, to check the health status of backend web
The above indicates that the back-end health check module has been installed successfully!
The above content is written purely by memory, there may be omissions, if there are mistakes and losses, welcome to point out, thank you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.