Linux 服务升级:Nginx 热升级 与 平滑回退,这是一份用心整理的Linux运维面试总结

[root@www ~]# nginx -v
nginx version: IIS777
[root@www ~]#
[root@www ~]# rpm -qa | grep nginx
nginx-filesystem-1.20.1-10.el7.noarch
nginx-1.20.1-10.el7.x86_64
[root@www ~]# /usr/local/sbin/nginx -V
nginx version: IIS777
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module

(8)查看nginx文件

本机存在2个版本的安装包

[root@www nginx]# find / -name nginx*

(9)查看配置文件

确定本机安装版本为1.22.0

[root@www nginx]# vim /usr/local/nginx/conf/nginx.conf



[root@www nginx]# vim /opt/nginx-1.22.0/src/core/nginx.h

4.Kali Linux 使用openvas 扫描 CentOS

(1)端口列表(Port Lists)

Configuration - Port Lists

(2)创建端口

选择带星号图标

(3)弹出界面

(4)扫描80端口

(5)新增http

(5)目标主机(Targets)

Configuration - Targets

(6) 创建扫描目标

选择带星号图标

(7)弹出界面

(8)扫描目标

(9)扫描任务

Scans -Tasks

(10) 创建扫描任务

选择带星号图标

(11)弹出界面

(12)设置

查看扫描方式

(14)查看,点击底部播放按钮

(15)开始扫描

观察变化

(16)查看扫描结果

Scans -Reports

点击左下角时间查看信息

(17)下载报告

点击左上角下载图标

(18)弹出界面

查看下载类型

选择PDF

5.Nginx 热升级

(1)查看版本

最新版本为1.25.4

https://nginx.org/download/

(2)下载

[root@www opt]# wget no-check-certificate https://nginx.org/download/nginx-1.25.4.tar.gz

(3)备份

[root@www nginx-1.25.4]# cd ~
[root@www ~]# cd /usr/local/nginx
[root@www nginx]# ls
client_body_temp  conf  fastcgi_temp  html  logs  passwd.db  proxy_temp  sbin  scgi_temp  uwsgi_temp
[root@www nginx]# cd ..
[root@www local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql  nginx  php  sbin  share  src  stress
[root@www local]# cp -pr ./nginx ./nginx_20240319_1.22.0
[root@www local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql  nginx  nginx_20240319_1.22.0  php  sbin  share  src  stress

(4)解压

[root@www opt]# tar xf nginx-1.25.4.tar.gz

(5)编译

[root@www local]# cd /opt/nginx-1.25.4/
[root@www nginx-1.25.4]# ls

#这里指定的安装路径前缀和老的nginx保持一致
[root@www nginx-1.25.4]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module

[root@www nginx-1.25.4]# make

(6)验证

[root@www nginx-1.25.4]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src
[root@www nginx-1.25.4]# cd objs
[root@www objs]# ls
autoconf.err  Makefile  nginx  nginx.8  ngx_auto_config.h  ngx_auto_headers.h  ngx_modules.c  ngx_modules.o  src

(7)备份旧的Nginx二进制

[root@www objs]# cd /usr/local/sbin
[root@www sbin]# ls
nginx  php-fpm
[root@www sbin]# mv ./nginx ./nginx_1.22.0
[root@www sbin]# ls
nginx_1.22.0  php-fpm

(8)拷贝新的Nginx二进制

[root@www sbin]# cd ..
[root@www local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql  nginx  nginx_20240319_1.22.0  php  sbin  share  src  stress
[root@www local]# cp -pr /opt/nginx-1.25.4/objs/nginx ./sbin

查看

[root@www local]# cd sbin
[root@www sbin]# ls
nginx  nginx_1.22.0  php-fpm

(9)向旧的master发送USR2信号

查看旧的master进程PID为3142

[root@www sbin]# ps -ef | grep  -E "CMD|nginx"
UID         PID   PPID  C STIME TTY          TIME CMD
root       3142      1  0 12:34 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx      3143   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3144   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3145   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3146   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3147   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3148   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3149   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3150   3142  0 12:34 ?        00:00:01 nginx: worker process
root      10884   3006  0 14:09 pts/1    00:00:00 grep --color=auto -E CMD|nginx
[root@www sbin]# ps axuw | head -1;ps axuw | grep nginx
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       3142  0.0  0.0  20532   688 ?        Ss   12:34   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx      3143  0.0  0.1  24292  2964 ?        S    12:34   0:00 nginx: worker process
nginx      3144  0.0  0.1  24292  2972 ?        S    12:34   0:00 nginx: worker process
nginx      3145  0.0  0.1  24292  2968 ?        S    12:34   0:00 nginx: worker process
nginx      3146  0.0  0.1  24292  2972 ?        S    12:34   0:00 nginx: worker process
nginx      3147  0.0  0.1  24292  2968 ?        S    12:34   0:00 nginx: worker process
nginx      3148  0.0  0.1  24292  2968 ?        S    12:34   0:00 nginx: worker process
nginx      3149  0.0  0.1  24292  2972 ?        S    12:34   0:00 nginx: worker process
nginx      3150  0.0  0.1  24292  2972 ?        S    12:34   0:01 nginx: worker process
root      10922  0.0  0.0 112676   984 pts/1    S+   14:10   0:00 grep --color=auto nginx

(10)确认nginx.pid位置

[root@www run]# cd /usr/local/nginx

[root@www nginx]# find ./ -name nginx.pid
./logs/nginx.pid
[root@www nginx]# cat ./logs/nginx.pid
3142

(11) 热升级

[root@www nginx]# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid `

查看进程


[root@www nginx]# ps -ef | grep  -E "CMD|nginx"
UID         PID   PPID  C STIME TTY          TIME CMD
root       3142      1  0 12:34 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx      3143   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3144   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3145   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3146   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3147   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3148   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3149   3142  0 12:34 ?        00:00:00 nginx: worker process
nginx      3150   3142  0 12:34 ?        00:00:01 nginx: worker process
root      12211   3142  0 14:32 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     12212  12211  0 14:32 ?        00:00:00 nginx: worker process
nginx     12213  12211  0 14:32 ?        00:00:00 nginx: worker process
nginx     12214  12211  0 14:32 ?        00:00:00 nginx: worker process
nginx     12215  12211  0 14:32 ?        00:00:00 nginx: worker process
nginx     12216  12211  0 14:32 ?        00:00:00 nginx: worker process
nginx     12217  12211  0 14:32 ?        00:00:00 nginx: worker process
nginx     12218  12211  0 14:32 ?        00:00:00 nginx: worker process
nginx     12219  12211  0 14:32 ?        00:00:00 nginx: worker process
root      12238   3006  0 14:32 pts/1    00:00:00 grep --color=auto -E CMD|nginx
[root@www nginx]# ps axuw | head -1;ps axuw | grep nginx
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       3142  0.0  0.0  20532   844 ?        Ss   12:34   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx      3143  0.0  0.1  24292  2964 ?        S    12:34   0:00 nginx: worker process
nginx      3144  0.0  0.1  24292  2972 ?        S    12:34   0:00 nginx: worker process
nginx      3145  0.0  0.1  24292  2968 ?        S    12:34   0:00 nginx: worker process
nginx      3146  0.0  0.1  24292  2972 ?        S    12:34   0:00 nginx: worker process
nginx      3147  0.0  0.1  24292  2968 ?        S    12:34   0:00 nginx: worker process
nginx      3148  0.0  0.1  24292  2968 ?        S    12:34   0:00 nginx: worker process
nginx      3149  0.0  0.1  24292  2972 ?        S    12:34   0:00 nginx: worker process
nginx      3150  0.0  0.1  24292  2972 ?        S    12:34   0:01 nginx: worker process
root      12211  0.0  0.0  20536  1692 ?        S    14:32   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     12212  0.0  0.1  24296  2712 ?        S    14:32   0:00 nginx: worker process
nginx     12213  0.0  0.1  24296  2712 ?        S    14:32   0:00 nginx: worker process
nginx     12214  0.0  0.1  24296  2712 ?        S    14:32   0:00 nginx: worker process
nginx     12215  0.0  0.1  24296  2712 ?        S    14:32   0:00 nginx: worker process
nginx     12216  0.0  0.1  24296  2712 ?        S    14:32   0:00 nginx: worker process
nginx     12217  0.0  0.1  24296  2712 ?        S    14:32   0:00 nginx: worker process
nginx     12218  0.0  0.1  24296  2712 ?        S    14:32   0:00 nginx: worker process
nginx     12219  0.0  0.1  24296  2452 ?        S    14:32   0:00 nginx: worker process
root      12249  0.0  0.0 112676   980 pts/1    R+   14:32   0:00 grep --color=auto nginx

发现有两个master进程,第二个master进程就是新的主进程,并且是作为老进程的子进程启动的。

并且nginx会将老的pid文件命名为nginx.pid.oldbin。

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Linux运维工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Linux运维知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip1024b (备注Linux运维获取)
img

术停滞不前!**

因此收集整理了一份《2024年Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-VvC0u0PH-1712509597771)]
[外链图片转存中…(img-5dpViQ9C-1712509597772)]
[外链图片转存中…(img-ssV4ZmI4-1712509597772)]
[外链图片转存中…(img-BH6lYKaH-1712509597773)]
[外链图片转存中…(img-hCIbQSou-1712509597773)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Linux运维知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip1024b (备注Linux运维获取)
[外链图片转存中…(img-ldGNmj84-1712509597774)]

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值