华子目录
- 升级
-
- 实验环境准备
- 测试内容准备
- 实验要求
- 实验步骤
-
- 1.解压包
- 2.检测1.26版本的环境
- 3.make编译
- 4.备份之前的`nginx`启动脚本
- 5.将1.26中的nginx启动脚本覆盖掉1.24中的
- 6.`kill -USR2 旧主进程pid`
- 7.`kill -WINCH 旧主进程pid`
- 实验测试
- 回滚
-
- 1.`kill -HUP 旧主进程pid`
- 2.`kill -WINCH 新主进程pid`
- 3.备份`nginx`启动脚本
- 4.`nginx.old`覆盖`nginx`
- 5.`kill -9 新主进程pid`
- 回滚测试
升级
实验环境准备
- 原
nginx
版本:1.24
- 需要
升级到
的版本:1.26
- 需要的包:
echo-nginx-module-0.63.tar.gz
,nginx-1.24.0.tar.gz
,nginx-1.26.2.tar.gz
[root@nginx ~]
公共 视频 文档 音乐 anaconda-ks.cfg nginx-1.24.0 nginx-1.26.2.tar.gz
模板 图片 下载 桌面 echo-nginx-module-0.63.tar.gz nginx-1.24.0.tar.gz vmset-rhel9-mountYum.sh
测试内容准备
[root@nginx ~]
[root@nginx html]
[root@nginx html]
hello world
while true; do curl 172.25.254.100;sleep 1; done
实验要求
在升级的过程中,原nginx提供的web服务不能中断
[root@nginx ~]
root 42795 1 0 09:31 ? 00:00:00 nginx: master process nginx
nginx 42796 42795 0 09:31 ? 00:00:00 nginx: worker process
root 42798 39792 0 09:31 pts/0 00:00:00 grep --color=auto nginx
[root@nginx ~]
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Sat, 31 Aug 2024 13:32:21 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Sat, 31 Aug 2024 13:31:18 GMT
Connection: keep-alive
ETag: "66d31b26-267"
Accept-Ranges: bytes
实验步骤
1.解压包
[root@nginx ~]
[root@nginx ~]
2.检测1.26版本的环境
[root@nginx ~]
[root@nginx nginx-1.26.2]
> --user=nginx \
> --group=nginx \
> --with-http_ssl_module \
> --with-http_v2_module \
> --with-http_realip_module \
> --with-http_stub_status_module \
> --with-http_gzip_static_module \
> --with-pcre \
> --with-stream \
> --with-stream_ssl_module
> --add-module=/root/echo-nginx-module-0.63
3.make编译
[root@nginx nginx-1.26.2]
4.备份之前的nginx
启动脚本
[root@nginx ~]
[root@nginx sbin]
nginx
[root@nginx sbin]
[root@nginx sbin]
nginx nginx.old
5.将1.26中的nginx启动脚本覆盖掉1.24中的
[root@nginx sbin]
6.kill -USR2 旧主进程pid
- 使用
kill -USR2
启动一个新的
,只启动,不监听端口
[root@nginx sbin]
root 52797 0.0 0.0 9832 928 ? Ss 10:56 0:00 nginx: master process nginx
nginx 52798 0.0 0.1 13720 5348 ? S 10:56 0:00 nginx: worker process
root 52800 0.0 0.0 221680 2252 pts/0 S+ 10:57 0:00 grep --color=auto nginx
[root@nginx sbin]
52798 52797
[root@nginx sbin]
[root@nginx sbin]
root 52797 0.0 0.0 9832 2396 ? Ss 10:56 0:00 nginx: master process nginx
nginx 52798 0.0 0.1 13720 5348 ? S 10:56 0:00 nginx: worker process
root 52823 0.0 0.1 9864 5912 ? S 10:58 0:00 nginx: master process nginx
nginx 52824 0.0 0.1 13752 5308 ? S 10:58 0:00 nginx: worker process
root 52826 0.0 0.0 221680 2324 pts/0 S+ 10:58 0:00 grep --color=auto nginx
7.kill -WINCH 旧主进程pid
[root@nginx sbin]
[root@nginx sbin]
root 52797 0.0 0.0 9832 2396 ? Ss 10:56 0:00 nginx: master process nginx
root 52823 0.0 0.1 9864 5912 ? S 10:58 0:00 nginx: master process nginx
nginx 52824 0.0 0.1 13752 5308 ? S 10:58 0:00 nginx: worker process
root 52842 0.0 0.0 221680 2316 pts/0 S+ 11:03 0:00 grep --color=auto nginx
实验测试
[root@nginx sbin]
HTTP/1.1 200 OK
Server: nginx/1.26.2
Date: Sat, 31 Aug 2024 15:04:16 GMT
Content-Type: text/html
Content-Length: 12
Last-Modified: Sat, 31 Aug 2024 14:43:41 GMT
Connection: keep-alive
ETag: "66d32c1d-c"
Accept-Ranges: bytes
回滚
1.kill -HUP 旧主进程pid
[root@nginx sbin]
root 52797 0.0 0.0 9832 2396 ? Ss 10:56 0:00 nginx: master process nginx
root 52823 0.0 0.1 9864 5912 ? S 10:58 0:00 nginx: master process nginx
nginx 52824 0.0 0.1 13752 5308 ? S 10:58 0:00 nginx: worker process
root 52848 0.0 0.0 221680 2344 pts/0 S+ 11:06 0:00 grep --color=auto nginx
[root@nginx sbin]
[root@nginx sbin]
root 52797 0.0 0.0 9832 2396 ? Ss 10:56 0:00 nginx: master process nginx
root 52823 0.0 0.1 9864 5912 ? S 10:58 0:00 nginx: master process nginx
nginx 52824 0.0 0.1 13752 5308 ? S 10:58 0:00 nginx: worker process
nginx 52849 0.0 0.1 13720 5348 ? S 11:08 0:00 nginx: worker process
root 52851 0.0 0.0 221680 2356 pts/0 S+ 11:08 0:00 grep --color=auto nginx
2.kill -WINCH 新主进程pid
[root@nginx sbin]
[root@nginx sbin]
root 52797 0.0 0.0 9832 2396 ? Ss 10:56 0:00 nginx: master process nginx
root 52823 0.0 0.1 9864 6416 ? S 10:58 0:00 nginx: master process nginx
nginx 52849 0.0 0.1 13720 5348 ? S 11:08 0:00 nginx: worker process
root 52858 0.0 0.0 221680 2352 pts/0 S+ 11:10 0:00 grep --color=auto nginx
3.备份nginx
启动脚本
[root@nginx sbin]
nginx nginx.old
[root@nginx sbin]
[root@nginx sbin]
nginx nginx.new nginx.old
4.nginx.old
覆盖nginx
[root@nginx sbin]
[root@nginx sbin]
nginx nginx.new nginx.old
5.kill -9 新主进程pid
[root@nginx sbin]
root 52797 0.0 0.0 9832 2396 ? Ss 10:56 0:00 nginx: master process nginx
root 52823 0.0 0.1 9864 6416 ? S 10:58 0:00 nginx: master process nginx
nginx 52849 0.0 0.1 13720 5348 ? S 11:08 0:00 nginx: worker process
root 52880 0.0 0.0 221680 2240 pts/0 S+ 11:15 0:00 grep --color=auto nginx
[root@nginx sbin]
[root@nginx sbin]
root 52797 0.0 0.0 9832 2396 ? Ss 10:56 0:00 nginx: master process nginx
nginx 52849 0.0 0.1 13720 5348 ? S 11:08 0:00 nginx: worker process
root 52883 0.0 0.0 221680 2352 pts/0 S+ 11:15 0:00 grep --color=auto nginx
回滚测试
[root@nginx sbin]
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Sat, 31 Aug 2024 15:12:01 GMT
Content-Type: text/html
Content-Length: 12
Last-Modified: Sat, 31 Aug 2024 14:43:41 GMT
Connection: keep-alive
ETag: "66d32c1d-c"
Accept-Ranges: bytes