做网站后期要收维护费吗,wordpress动漫视频网站,做网站要会哪些知识,计算机是学什么内容的nginx的热部署#xff08;方案二#xff09;
方案一的缺点就是直接升级完成了#xff1b;
那么问题来了#xff1a;
如果说出现问题了#xff0c;想要回退 那么应该怎么处理#xff1f;所以最好就是有一段的缓冲期限#xff1b;
那么久可以直接 从升级的方案来进行 …nginx的热部署方案二
方案一的缺点就是直接升级完成了
那么问题来了
如果说出现问题了想要回退 那么应该怎么处理所以最好就是有一段的缓冲期限
那么久可以直接 从升级的方案来进行 拆分
1、查看原来的编译参数
#这个是一样的可以优先查看编译参数
[rootLinux2 ~]# nginx -V
nginx version: LJW/WEB
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix/usr/local/nginx这里只是指定了一个编译参数其余都是默认的那么我们现在尝试多增加一个编译参数
2、准备nginx的源码包
#准备好源码包#上面的是nginx的 1.27版本目前这个是1.26版本
[rootLinux2 ~]# cd nginx-1.26.23、预编译、编译、安装
#预编译 --这里再加一个status的状态模块
[rootLinux2 nginx-1.26.2]# ./configure --prefix/usr/local/nginx --with-http_stub_status_module#编译、安装
[rootLinux2 nginx-1.26.2]# make make install4、生成新的master进程
首先查看原来的nginx的pid 给它发信号
#升级的过程是把make upgrade的步骤拆开
[rootLinux2 nginx-1.26.2]# tail -10 Makefile
upgrade:/usr/local/nginx/sbin/nginx -t #测试一下配置文件kill -USR2 cat /usr/local/nginx/logs/nginx.pid #然后发送信号给pidsleep 1test -f /usr/local/nginx/logs/nginx.pid.oldbin #然后备份一个pid文件kill -QUIT cat /usr/local/nginx/logs/nginx.pid.oldbin #然后退出老的进程.PHONY: build install modules upgrade#优先查看一下pid号#这里可以蛋刀master的进程号是9359
[rootLinux2 nginx-1.26.2]# ps -ef | grep nginx
root 9359 1 0 11:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
nobody 9361 9359 0 11:44 ? 00:00:00 nginx: worker process
root 12052 1157 0 12:11 pts/0 00:00:00 grep --colorauto nginx#然后给到这个进程发送一个信号
[rootLinux2 nginx-1.26.2]# kill -USR2 9359#这里明显看到多了一个master进程#多出来的master进程号是12053
[rootLinux2 nginx-1.26.2]# ps -ef | grep nginx
root 9359 1 0 11:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
nobody 9361 9359 0 11:44 ? 00:00:00 nginx: worker process
root 12053 9359 0 12:12 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
nobody 12054 12053 0 12:12 ? 00:00:00 nginx: worker process
root 12056 1157 0 12:12 pts/0 00:00:00 grep --colorauto nginx5、退出老master进程
接上述实验老的master进程号是9359
#向老的master进程发信号
[rootLinux2 nginx-1.26.2]# kill -WINCH 9359
[rootLinux2 nginx-1.26.2]# ps -ef | grep [n]ginx
root 9359 1 0 11:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
root 12053 9359 0 12:12 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
nobody 12054 12053 0 12:12 ? 00:00:00 nginx: worker process这时候检查一下nginx的版本是否回退了 这里需要注意、老进程并没有退出的只是测试一段时间没问题才推出
#到这里为止我们能够看到版本号已经回到1.26版本了
[rootLinux2 nginx-1.26.2]# nginx -V
nginx version: nginx/1.26.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix/usr/local/nginx --with-http_stub_status_module6、抉择
这里的抉择指的是
可以回退到原来1.27版本也可以直接回到目前的1.26版本
#这里回滚#重新拉起老的worker进程
[rootLinux2 nginx-1.26.2]# kill -HUP 9359#再次查看没有问题
[rootLinux2 nginx-1.26.2]# ps -ef | grep [n]ginx
root 9359 1 0 11:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
root 12053 9359 0 12:12 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
nobody 12054 12053 0 12:12 ? 00:00:00 nginx: worker process
nobody 12063 9359 0 12:20 ? 00:00:00 nginx: worker process#回滚就得退出目前的新的nginx的master号
[rootLinux2 nginx-1.26.2]# kill -QUIT 12053
[rootLinux2 nginx-1.26.2]# ps -ef | grep [n]ginx
root 9359 1 0 11:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
nobody 12063 9359 0 12:20 ? 00:00:00 nginx: worker process#然后把升级的旧文件重新换回来
[rootLinux2 nginx-1.26.2]# mv /usr/local/nginx/sbin/nginx.old /usr/local/nginx/sbin/nginx如果是决定使用了nginx的最新版本
nginx的最新版本
#直接退出老worker的进程即可
[rootLinux2 nginx-1.26.2]# kill -QUIT 9359
[rootLinux2 nginx-1.26.2]# ps -ef | grep [n]ginx
root 12073 1 0 12:24 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/ngin
nobody 12074 12073 0 12:24 ? 00:00:00 nginx: worker process分享环节
hi亲爱的朋友们
感谢你们耐心完这个笔记如果笔记中出现的一些软件包、资源找不到的可以直接留言私聊我看见了就回复资源免费共享有需要滴滴仅仅是我有的
我的坚持初衷立志要成为一名架构师
不断地去坚持学其中的各种各样的难度不言而喻~坚持不是一件容易的事情但它却是成功的关键。做起来吧~
如果你也想要坚持那么组团吧咋们一块互相监督一天一点分享也是进步最怕就是孤军奋战加油吧追梦人~