随着 nginx 越来越流行,并且 nginx 的优势也越来越明显,nginx 的版本迭代也来时加速模式,1.9.0版本的nginx更新了许多新功能,例如 stream 四层代理功能,伴随着 nginx 的广泛应用,版本升级必然越来越快,线上业务不能停,此时 nginx 的升级就是运维的工作了
nginx 方便地帮助我们实现了平滑升级。其原理简单概括,就是: (1)在不停掉老进程的情况下,启动新进程。 (2)老进程负责处理仍然没有处理完的请求,但不再接受处理请求。 (3)新进程接受新请求。 (4)老进程处理完所有请求,关闭所有连接后,停止。 这样就很方便地实现了平滑升级。一般有两种情况下需要升级 nginx,一种是确实要升级 nginx 的版本,另一种是要为 nginx 添加新的模块
2、Nginx信号简介主进程支持的信号
工作进程支持的信号
[root@nginx-server ~]# /usr/local/nginx/sbin/nginx -V
按照原来的编译参数安装 nginx 的方法进行安装,只需要到 make,千万不要 make install 。如果make install 会将原来的配置文件覆盖
[root@nginx-server ~]# cd /usr/local/nginx-1.16.0/
[root@nginx-server nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream --with-http_image_filter_module
[root@nginx-server nginx-1.16.0]# make
备份二进制文件和 nginx 的配置文件(期间nginx不会停止服务)
[root@nginx-server nginx-1.16.0]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_$(date +%F)
[root@nginx-server nginx-1.16.0]# cp /usr/local/nginx-1.16.0/objs/nginx /usr/local/nginx/sbin/
[root@nginx-server nginx-1.16.0]# /usr/local/nginx/sbin/nginx -t
[root@nginx-server ~]# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
[root@nginx-server logs]# ll nginx.pid*
-rw-r--r-- 1 root root 6 5月 7 10:58 nginx.pid
-rw-r--r-- 1 root root 6 5月 7 09:56 nginx.pid.oldbin
[root@nginx-server ~]# kill -WINCH `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@nginx-server ~]# kill -HUP `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@nginx-server ~]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@nginx-server ~]# /usr/local/nginx/sbin/nginx -V
4、升级实验
[root@localhost ~]# yum install -y gcc gcc-c++ pcre-devel openssl-devel zlib-devel
[root@localhost ~]# tar xzf nginx-1.6.3.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/nginx-1.6.3
[root@localhost nginx-1.6.3]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@localhost nginx-1.6.3]# make && make install
[root@localhost nginx-1.6.3]# useradd -M -s /sbin/nologin nginx
[root@localhost nginx-1.6.3]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost nginx-1.6.3]# /usr/local/nginx/sbin/nginx
[root@localhost nginx-1.6.3]# netstat -lntp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13989/nginx: master
[root@localhost nginx-1.6.3]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.6.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@localhost nginx-1.6.3]# echo "nginx1.6" > /usr/local/nginx/html/index.html
[root@localhost nginx-1.6.3]# yum install -y elinks
[root@localhost nginx-1.6.3]# elinks 10.0.105.189
将 nginx 版本进行升级 并在不影响业务的情况下添加 SSL 和 pcre 模块
[root@localhost ~]# tar xzf nginx-1.12.2.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/nginx-1.12.2/
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=ngiinx --with-http_stub_status_module --with-http_ssl_module --with-pcre
[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# cd
[root@localhost ~]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_lod
[root@localhost ~]# cp /usr/local/nginx-1.12.2/objs/nginx /usr/local/nginx/sbin/
[root@localhost ~]# mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
[root@localhost ~]# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
[root@localhost ~]# ls /usr/local/nginx/logs/
access.log error.log nginx.pid
[root@localhost ~]# ps aux | grep nginx
root 13989 0.0 0.0 24860 952 ? Ss 13:55 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 13990 0.0 0.1 25284 1720 ? S 13:55 0:00 nginx: worker process
root 16525 0.0 0.0 112708 976 pts/2 S+ 14:09 0:00 grep --color=auto nginx
nginx错误页面包括404 403 500 502 503 504等页面,只需要在server中增加以下配置即可:
#error_page 404 403 500 502 503 504 /404.html;location = /404.html {root /usr/local/nginx/html;}
注意:
/usr/local/nginx/html/ 路径下必须有404.html这个文件!!!
404.html上如果引用其他文件的png或css就会有问题,显示不出来,因为其他文件的访问也要做配置; 为了简单,可以将css嵌入文件中,图片用base编码嵌入;如下:
[root@localhost html]# vim 404.html
<html><head><meta charset&#61;"UTF-8" /><meta name&#61;"viewport" content&#61;"width&#61;device-width, initial-scale&#61;1, maximum-scale&#61;1" /><title>404title><style>.layout-table{display:table;height:100%;width:100%;vertical-align: middle;margin-top:150px}.layout-table-cell{display: table-cell;vertical-align: middle;text-align:center}.layout-tip{font-size:28px;color:#373737;margin: 0 auto;margin-top:16px;border-bottom: 1px solid #eee;padding-bottom: 20px;width: 360px;}#tips{font-size:18px;color:#666666;margin-top:16px;}style>head><body class&#61;"layui-layout-body"><div class&#61;"layui-layout layui-layout-admin"><div class&#61;"layui-body"><div class&#61;"layout-table"><div class&#61;"layout-table-cell"><img src&#61;"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAV4AAACMCAYAAAA0qsGKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8&#43;IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkIwRDQ0ODRFMzMyODExRThBQ0Q5Q0UyNkNCMkE4MDk0IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkIwRDQ0ODRGMzMyODExRThBQ0Q5Q0UyNkNCMkE4MDk0Ij4gPHhtcE1NOkRlcml2ZWRGcm9t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V411YEA4jI5vHNguoeHnokbLqhITqrQ7z&#43;JB3LJuUtHvEYhsTAP52yF9UNQA2Qgjkio8uazrTbSajEQ50wBUhC&#43;8HNAdgCdKa25D/9ql9Pe9FEtWY3tb0AsDVUejxAgAAAN0BVQ0AAAAQXgAAAAgvAAAAAOEFAABwF/8VYAAXRwSpGfHzmgAAAABJRU5ErkJggg&#61;&#61;" class&#61;"layout-img"><p class&#61;"layout-tip">哎呀&#xff0c;找不到该页面啦&#xff01;p><p id&#61;"tips">请检查您的网络连接是否正常或者输入的网址是否正确p>div>div>div>div>body>
html>
展示效果&#xff1b;
对于升级来说&#xff0c;最难的不是升级&#xff0c;而是回滚&#xff0c;因为在实际生产环境回滚的机率是存在&#xff0c;比如&#xff1a;新版本由于某些未知bug导致与现有应用不兼容、或出现运行不稳定的情况等等。
所以&#xff0c;对运维工程师来说&#xff0c;故障回滚是重点。
在上面的结果中&#xff0c;我们也能看到老的master进程是一直存在&#xff0c;在没有手工关闭前&#xff0c;它是不会自已关闭的&#xff0c;这种设计是有好处的&#xff0c;好处就是为了升级新版本后&#xff0c;如果出现问题能及时快速的回滚到上一个稳定版本。
[root&#64;nginx ~]# ps -ef|grep nginx
root 37140 0.0 0.3 46204 3400 ? S 10:58 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 37142 0.0 0.1 46656 1908 ? S 10:58 0:00 nginx: worker process
nginx 37188 0.0 0.2 46676 2168 ? S 11:00 0:00 nginx: worker process
root 37450 0.0 0.0 112824 976 pts/0 R&#43; 13:16 0:00 grep --color&#61;auto nginx
[root&#64;nginx ~]# cd /usr/local/nginx/sbin/
[root&#64;nginx sbin]# mv nginx nginx-1.12.2
[root&#64;nginx sbin]# mv nginx-1.16.3 nginx
[root&#64;nginx sbin]# kill -USR1 37140
[root&#64;nginx sbin]# ps -ef|grep nginx
root 37140 0.0 0.3 46340 3536 ? S 10:58 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 37188 0.0 0.2 46676 2168 ? S 11:00 0:00 nginx: worker process
nginx 37461 0.0 0.2 46776 2032 ? S 13:19 0:00 nginx: worker process
root 37471 0.0 0.0 112824 976 pts/0 R&#43; 13:19 0:00 grep --color&#61;auto nginx
[root&#64;nginx sbin]# ./nginx -v
nginx version: nginx/1.12.2
从上面的结果发现&#xff0c;已经平滑的回滚的上一个版本&#xff0c;接下来测试是否能正常访问&#xff1a;
一样可以正常访问&#xff0c;所以&#xff0c;这个回滚的操作对用户来说也是不可感知的。