当前位置: 首页 > news >正文

Linux 服务升级:Nginx 热升级 与 平滑回退

目录

  一、实验

1.环境

2.Kali Linux 使用nmap扫描CentOS

3.Kali Linux 远程CentOS

4.Kali Linux 使用openvas 扫描 CentOS

5.Nginx 热升级

6.Nginx 平滑回退

二、问题

1.kill命令的信号有哪些

2.平滑升级与回退的信号


  一、实验

1.环境

(1)主机

表1  主机

系统版本IP备注
CentOS7.9192.168.204.200nginx升级主机
Kali Linux2024.1

192.168.204.146(动态)

192.168.204.100(静态)

已部署openvas

(2)查看Kali Linux (2024.1)系统版本

cat /etc/os-release

(3)查看Kali Linux (2024.1)系统IP地址

ip addr

2.Kali Linux 使用nmap扫描CentOS

(1)扫描网段存活主机

nmap -sP 192.168.204.0/24

(2)扫描主机

nmap 192.168.204.200

(3)扫描主机系统

nmap -O 192.168.204.200

(4)扫描22端口开放情况

nmap -sS -p 22 192.168.204.200

(5)hydra 破解密码

hydra -l root -P test.txt 192.168.204.200 ssh

3.Kali Linux 远程CentOS

(1)远程

ssh root@192.168.204.200

(2)查看nginx版本

系统做了版本隐藏与修改

[root@www ~]# nginx -v

(3)查看进程

nginx未启动

[root@www ~]# ps axuw | head -1;ps axuw | grep nginx
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       3061  0.0  0.0 112676   984 pts/1    R+   12:32   0:00 grep --color=auto nginx
[root@www ~]#
[root@www ~]# ps -ef | grep  -E "CMD|nginx"
UID         PID   PPID  C STIME TTY          TIME CMD
root       3063   3006  0 12:32 pts/1    00:00:00 grep --color=auto -E CMD|nginx

测试


[root@www ~]# curl -I 127.0.0.1
curl: (7) Failed connect to 127.0.0.1:80; 拒绝连接[root@www ~]# curl -I 192.168.204.200
curl: (7) Failed connect to 192.168.204.200:80; 拒绝连接

(4)查看nginx安装位置

[root@www ~]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/local/sbin/nginx /usr/local/nginx /usr/share/nginx /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx.8.gz

(5)重启服务

[root@www ~]# systemctl restart nginx

测试

[root@www ~]# curl -I 192.168.204.200
HTTP/1.1 200 OK
Server: IIS777
Date: Tue, 19 Mar 2024 04:34:59 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 59
Last-Modified: Tue, 04 Jul 2023 13:39:01 GMT
Connection: keep-alive
ETag: "64a420f5-3b"
Accept-Ranges: bytes[root@www ~]# curl -I 192.168.204.200
HTTP/1.1 200 OK
Server: IIS777
Date: Tue, 19 Mar 2024 04:35:01 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 59
Last-Modified: Tue, 04 Jul 2023 13:39:01 GMT
Connection: keep-alive
ETag: "64a420f5-3b"
Accept-Ranges: bytes

(6)查看进程

nginx已启动

[root@www ~]# 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.2  0.1  24292  2724 ?        S    12:34   0:00 nginx: worker process
nginx      3144  0.0  0.1  24292  2724 ?        S    12:34   0:00 nginx: worker process
nginx      3145  0.0  0.1  24292  2724 ?        S    12:34   0:00 nginx: worker process
nginx      3146  0.0  0.1  24292  2724 ?        S    12:34   0:00 nginx: worker process
nginx      3147  0.0  0.1  24292  2724 ?        S    12:34   0:00 nginx: worker process
nginx      3148  0.0  0.1  24292  2724 ?        S    12:34   0:00 nginx: worker process
nginx      3149  0.0  0.1  24292  2724 ?        S    12:34   0:00 nginx: worker process
nginx      3150  0.2  0.1  24292  2972 ?        S    12:34   0:00 nginx: worker process
root       3158  0.0  0.0 112676   984 pts/1    S+   12:35   0:00 grep --color=auto nginx
[root@www ~]# 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:00 nginx: worker process
root       3160   3006  0 12:35 pts/1    00:00:00 grep --color=auto -E CMD|nginx

(7)继续查看版本

[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。

[root@www logs]# ll | head -1 ;ll |grep nginx.pid
总用量 5904
-rw-r--r--. 1 root  root       6 3月  19 14:32 nginx.pid
-rw-r--r--. 1 root  root       5 3月  19 12:34 nginx.pid.oldbin

[root@www logs]# ll /usr/local/nginx/logs/nginx.pid.oldbin
-rw-r--r--. 1 root root 5 3月  19 12:34 /usr/local/nginx/logs/nginx.pid.oldbin

查看PID

[root@www logs]# cat nginx.pid
12211
[root@www logs]# cat nginx.pid.oldbin
3142

(12)向旧master发送winch信号

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

[root@www logs]# 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
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      12887   3006  0 14:43 pts/1    00:00:00 grep --color=auto -E CMD|nginx
[root@www logs]# 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
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  2968 ?        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      12899  0.0  0.0 112676   984 pts/1    R+   14:43   0:00 grep --color=auto nginx

平滑关闭旧master的worker进程

(13)向旧master发送QUIT信号

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


 

[root@www logs]# ps -ef | grep  -E "CMD|nginx"
UID         PID   PPID  C STIME TTY          TIME CMD
root      12211      1  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      13069   3006  0 14:46 pts/1    00:00:00 grep --color=auto -E CMD|nginx
[root@www logs]# ps axuw | head -1;ps axuw | grep nginx
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
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  2968 ?        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      13084  0.0  0.0 112676   984 pts/1    R+   14:46   0:00 grep --color=auto nginx

(14)创建软连接

[root@www logs]# ln -s /usr/local/nginx/sbin/nginx /bin/

(15)验证

[root@www logs]# nginx -V
nginx version: nginx/1.25.4
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

6.Nginx 平滑回退

(1)替换nginx二进制文件

查看

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

替换

[root@www sbin]# mv nginx nginx_1.25.4
[root@www sbin]# ls
nginx_1.22.0  nginx_1.25.4  php-fpm
[root@www sbin]# mv nginx_1.22.0 nginx
[root@www sbin]# ls
nginx  nginx_1.25.4  php-fpm

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

查看PID

[root@www logs]# cat /usr/local/nginx/logs/nginx.pid
12211

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

查看进程


[root@www logs]# ps -ef | grep  -E "CMD|nginx"
UID         PID   PPID  C STIME TTY          TIME CMD
root      12211      1  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      14055  12211  0 15:02 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     14056  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14057  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14058  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14059  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14060  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14061  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14062  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14063  14055  0 15:02 ?        00:00:00 nginx: worker process
root      14077   3006  0 15:02 pts/1    00:00:00 grep --color=auto -E CMD|nginx
[root@www logs]# ps axuw | head -1;ps axuw | grep nginx
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
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  2968 ?        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      14055  0.0  0.0  20536  1696 ?        S    15:02   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     14056  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14057  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14058  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14059  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14060  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14061  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14062  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14063  0.0  0.1  24296  2456 ?        S    15:02   0:00 nginx: worker process
root      14087  0.0  0.0 112676   984 pts/1    R+   15:03   0:00 grep --color=auto nginx

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

[root@www logs]# ll | head -1 ;ll |grep nginx.pid
总用量 5908
-rw-r--r--. 1 root  root       6 3月  19 15:02 nginx.pid
-rw-r--r--. 1 root  root       6 3月  19 14:32 nginx.pid.oldbin

查看PID

[root@www logs]# cat nginx.pid
14055
[root@www logs]# cat nginx.pid.oldbin
12211

(3)向旧的master发送WINCH信号

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

查看进程

[root@www logs]# ps -ef | grep  -E "CMD|nginx"
UID         PID   PPID  C STIME TTY          TIME CMD
root      12211      1  0 14:32 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
root      14055  12211  0 15:02 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     14056  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14057  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14058  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14059  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14060  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14061  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14062  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14063  14055  0 15:02 ?        00:00:00 nginx: worker process
root      14290   3006  0 15:06 pts/1    00:00:00 grep --color=auto -E CMD|nginx
[root@www logs]# ps axuw | head -1;ps axuw | grep nginx
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      12211  0.0  0.0  20536  1692 ?        S    14:32   0:00 nginx: master process /usr/local/nginx/sbin/nginx
root      14055  0.0  0.0  20536  1696 ?        S    15:02   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     14056  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14057  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14058  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14059  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14060  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14061  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14062  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14063  0.0  0.1  24296  2456 ?        S    15:02   0:00 nginx: worker process
root      14305  0.0  0.0 112676   984 pts/1    R+   15:06   0:00 grep --color=auto nginx

(4)向旧的master发送QUIT信号

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

查看进程

[root@www logs]# ps -ef | grep  -E "CMD|nginx"
UID         PID   PPID  C STIME TTY          TIME CMD
root      14055      1  0 15:02 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     14056  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14057  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14058  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14059  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14060  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14061  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14062  14055  0 15:02 ?        00:00:00 nginx: worker process
nginx     14063  14055  0 15:02 ?        00:00:00 nginx: worker process
root      14371   3006  0 15:07 pts/1    00:00:00 grep --color=auto -E CMD|nginx
[root@www logs]# ps axuw | head -1;ps axuw | grep nginx
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      14055  0.0  0.0  20536  1696 ?        S    15:02   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     14056  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14057  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14058  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14059  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14060  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14061  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14062  0.0  0.1  24296  2716 ?        S    15:02   0:00 nginx: worker process
nginx     14063  0.0  0.1  24296  2456 ?        S    15:02   0:00 nginx: worker process
root      14377  0.0  0.0 112676   984 pts/1    R+   15:07   0:00 grep --color=auto nginx

(5)验证

已恢复之前版本

[root@www logs]# 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

二、问题

1.kill命令的信号有哪些

(1)查看信号

[root@www ~]# kill -l1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX

2.平滑升级与回退的信号

(1)信号

信号

数字

含义

QUIT

3

关闭

HUP

1

重启

USR1

10

重新打开日志文件,repon

USR2

12

平滑升级可执行的二进制程序

WINCH

28

平滑关闭worker进程

相关文章:

Linux 服务升级:Nginx 热升级 与 平滑回退

目录 一、实验 1.环境 2.Kali Linux 使用nmap扫描CentOS 3.Kali Linux 远程CentOS 4.Kali Linux 使用openvas 扫描 CentOS 5.Nginx 热升级 6.Nginx 平滑回退 二、问题 1.kill命令的信号有哪些 2.平滑升级与回退的信号 一、实验 1.环境 (1)主机…...

能降低嵌入式系统功耗的三个技术

为电池寿命设计嵌入式系统已经成为许多团队重要的设计考虑因素。优化电池寿命的能力有助于降低现场维护成本,并确保客户不需要不断更换或充电电池,从而获得良好的产品体验。 团队通常使用一些标准技术来提高电池寿命,例如将处理器置于低功耗…...

暴力快速入门强化学习

强化学习算法的基本思想(直觉) 众所周知,强化学习是能让智能体实现某个具体任务的强大算法。 强化学习的基本思想是让智能体跟环境交互,通过环境的反馈让智能体调整自己的策略,从反馈中学习,不断学习来得到…...

vue中v-if和v-show的区别

手段:v-if是动态的向DOM树内添加或者删除DOM元素;v-show是通过设置DOM元素的display样式属性控制显隐;编译过程:v-if切换有一个局部编译/卸载的过程,切换过程中合适地销毁和重建内部的事件监听和子组件;v-s…...

MATLAB绘图

现学现用,用时再学。 plot函数:有两个向量被指定为参数,plot(x,y) 会生成 y 对 x 的图形 添加轴标签和标题: 通过调用一次 plot,多个 x-y 对组参数会创建多幅图形: 在每十个数据点处放置标记: 一个窗口绘制多个图形; 可在弹窗的插入选项上添加…...

嵌入式学习-ARM-Day4

嵌入式学习-ARM-Day4 实现三个LED灯亮灭 .text .global _start _start: 使能GPIOE的外设时钟 RCC_MP_AHB4ENSETR的第[4]设置为1即可使能GPIOE时钟 LED1 LDR R0,0X50000A28 指定寄存器地址 LDR R1,[R0] 将寄存器原来的数值读取出来,保存到R1中 ORR R1,R1,#(0x…...

MySQL 中的事务和存储引擎

目录 事务的 ACID 特性 MySQL 的四种隔离机制和问题 MySQL 的四种隔离机制: MySQL 的存储引擎 InnoDB 存储引擎 MyISAM 存储引擎 Memory 存储引擎 通过 ALTER TABLE 语句更改存储引擎 在创建表时指定存储引擎 通过修改配置文件设置默认存储引擎 在数据库系…...

echarts多个折线图共用一个x轴和tooltip组件

实现效果 根据接口传来的数据&#xff0c;使用echarts绘制出&#xff0c;共用一个x轴的图表 功能&#xff1a;后端将所有数据传送过来&#xff0c;前端通过监听选中值来展示对应的图表数据 数据格式&#xff1a; 代码&#xff1a; <template><div><div clas…...

wireshark数据捕获实验简述

Wireshark是一款开源的网络协议分析工具&#xff0c;它可以用于捕获和分析网络数据包。是一款很受欢迎的“网络显微镜”。 实验拓扑图&#xff1a; 实验基础配置&#xff1a; 服务器&#xff1a; ip:172.16.1.88 mask:255.255.255.0 r1: sys sysname r1 undo info enable in…...

如何利用RunnerGo简化性能测试流程

在软件开发过程中&#xff0c;测试是一个重要的环节&#xff0c;需要投入大量时间和精力来确保应用程序或网站的质量和稳定性。但是&#xff0c;随着应用程序变得更加复杂和庞大&#xff0c;传统的测试工具在面对比较繁琐的项目时非常费时费力。这时&#xff0c;一些自动化测试…...

继承和深拷贝封装

继承和深拷贝封装 今日目标&#xff1a; 1.es5寄生组合式继承 2.es6类的继承 3.深拷贝函数封装 00-回顾 # 不同数据类型赋值时的区别&#xff1a; 基本数据类型&#xff0c;赋的就是值&#xff0c;相互之间不再有任何影响 引用数据类型&#xff0c;赋的是地址&#xff0c…...

《定时执行专家》:Nircmd 的超级搭档,解锁自动化新境界

目录 Nircmd 简介 《定时执行专家》与 Nircmd 的结合 示例&#xff1a; 自动清理电脑垃圾: 定时发送邮件: 定时关闭电脑: 《定时执行专家》的优势: 总结: 以下是一些其他使用示例&#xff1a; 立即下载《定时执行专家》&#xff1a; Nircmd 官方网站&#xff1a; 更…...

Android 封装的工具类

文章目录 日志封装类-MyLog线程封装类-LocalThreadPools自定义进度条-LoadProgressbar解压缩类-ZipUtils本地数据库类-MySQLiteHelper访问webservice封装-HttpUtilsToolbar封装类-MaterialToolbar网络请求框架-OkGo网络请求框架-OkHttp 日志封装类-MyLog 是对android log的封装…...

linux下线程分离属性

linux下线程分离属性 一、线程的属性---分离属性二、线程属性设置2.1 线程创建前设置分离属性2.2 线程创建后设置分离属性 一、线程的属性—分离属性 什么是分离属性&#xff1f; 首先分离属性是线程的一个属性&#xff0c;有了分离属性的线程&#xff0c;不需要别的线程去接合…...

Leetcode 208. 实现 Trie (前缀树)

心路历程&#xff1a; 一道题干进去了一个下午&#xff0c;单纯从解题角度可以直接用python的集合就很简单地解决&#xff08;不知道是不是因为python底层的set()类&#xff09;。后来从网上看到这道题应该从前缀树的角度去做&#xff0c;于是花了半个多小时基于字典做了前缀树…...

蓝桥杯练习题——健身大调查

在浏览器中预览 index.html 页面效果如下&#xff1a; 目标 完成 js/index.js 中的 formSubmit 函数&#xff0c;用户填写表单信息后&#xff0c;点击蓝色提交按钮&#xff0c;表单项隐藏&#xff0c;页面显示用户提交的表单信息&#xff08;在 id 为 result 的元素显示&#…...

React——组件通讯

组件通讯介绍 组件中的状态是私有的&#xff0c;组件的状态只能在组件内部使用&#xff0c;无法直接在组件外使用&#xff0c;但是我们在日常开发中&#xff0c;通常会把相似、功能完整的应用才分成组件&#xff08;工厂模式&#xff09;利于我们的开发&#xff0c;而不同组件直…...

php闭包应用

laravel 路由 bingTo 把路由URL映射到匿名回调函数上&#xff0c;框架会把匿名回调函数绑定到应用对象上&#xff0c;这样在匿名函数中就可以使用$this关键字引用重要的应用对象。Illuminate\Support\Traits\Macroable的__call方法。 自己写一个简单的demo: <?php <?…...

基于python+vue的OA公文发文管理系统flask-django-php-nodejs

系统根据现有的管理模块进行开发和扩展&#xff0c;采用面向对象的开发的思想和结构化的开发方法对OA公文发文管理的现状进行系统调查。采用结构化的分析设计&#xff0c;该方法要求结合一定的图表&#xff0c;在模块化的基础上进行系统的开发工作。在设计中采用“自下而上”的…...

脉冲变压器电感的工艺结构原理及选型参数总结

🏡《总目录》 目录 1,概述2,工作原理3,结构特点3.1,铁心结构3.2,铁心材料3.3,绕组4,工艺流程4.1,准备铁芯4.2,绕制线圈4.3,安装线圈4.4,固定线圈4.5,绝缘处理4.6,高压脉冲引出...

大数据学习栈记——Neo4j的安装与使用

本文介绍图数据库Neofj的安装与使用&#xff0c;操作系统&#xff1a;Ubuntu24.04&#xff0c;Neofj版本&#xff1a;2025.04.0。 Apt安装 Neofj可以进行官网安装&#xff1a;Neo4j Deployment Center - Graph Database & Analytics 我这里安装是添加软件源的方法 最新版…...

聊聊 Pulsar:Producer 源码解析

一、前言 Apache Pulsar 是一个企业级的开源分布式消息传递平台&#xff0c;以其高性能、可扩展性和存储计算分离架构在消息队列和流处理领域独树一帜。在 Pulsar 的核心架构中&#xff0c;Producer&#xff08;生产者&#xff09; 是连接客户端应用与消息队列的第一步。生产者…...

MVC 数据库

MVC 数据库 引言 在软件开发领域,Model-View-Controller(MVC)是一种流行的软件架构模式,它将应用程序分为三个核心组件:模型(Model)、视图(View)和控制器(Controller)。这种模式有助于提高代码的可维护性和可扩展性。本文将深入探讨MVC架构与数据库之间的关系,以…...

React19源码系列之 事件插件系统

事件类别 事件类型 定义 文档 Event Event 接口表示在 EventTarget 上出现的事件。 Event - Web API | MDN UIEvent UIEvent 接口表示简单的用户界面事件。 UIEvent - Web API | MDN KeyboardEvent KeyboardEvent 对象描述了用户与键盘的交互。 KeyboardEvent - Web…...

Keil 中设置 STM32 Flash 和 RAM 地址详解

文章目录 Keil 中设置 STM32 Flash 和 RAM 地址详解一、Flash 和 RAM 配置界面(Target 选项卡)1. IROM1(用于配置 Flash)2. IRAM1(用于配置 RAM)二、链接器设置界面(Linker 选项卡)1. 勾选“Use Memory Layout from Target Dialog”2. 查看链接器参数(如果没有勾选上面…...

AI编程--插件对比分析:CodeRider、GitHub Copilot及其他

AI编程插件对比分析&#xff1a;CodeRider、GitHub Copilot及其他 随着人工智能技术的快速发展&#xff0c;AI编程插件已成为提升开发者生产力的重要工具。CodeRider和GitHub Copilot作为市场上的领先者&#xff0c;分别以其独特的特性和生态系统吸引了大量开发者。本文将从功…...

网络编程(UDP编程)

思维导图 UDP基础编程&#xff08;单播&#xff09; 1.流程图 服务器&#xff1a;短信的接收方 创建套接字 (socket)-----------------------------------------》有手机指定网络信息-----------------------------------------------》有号码绑定套接字 (bind)--------------…...

2025季度云服务器排行榜

在全球云服务器市场&#xff0c;各厂商的排名和地位并非一成不变&#xff0c;而是由其独特的优势、战略布局和市场适应性共同决定的。以下是根据2025年市场趋势&#xff0c;对主要云服务器厂商在排行榜中占据重要位置的原因和优势进行深度分析&#xff1a; 一、全球“三巨头”…...

动态 Web 开发技术入门篇

一、HTTP 协议核心 1.1 HTTP 基础 协议全称 &#xff1a;HyperText Transfer Protocol&#xff08;超文本传输协议&#xff09; 默认端口 &#xff1a;HTTP 使用 80 端口&#xff0c;HTTPS 使用 443 端口。 请求方法 &#xff1a; GET &#xff1a;用于获取资源&#xff0c;…...

MFC 抛体运动模拟:常见问题解决与界面美化

在 MFC 中开发抛体运动模拟程序时,我们常遇到 轨迹残留、无效刷新、视觉单调、物理逻辑瑕疵 等问题。本文将针对这些痛点,详细解析原因并提供解决方案,同时兼顾界面美化,让模拟效果更专业、更高效。 问题一:历史轨迹与小球残影残留 现象 小球运动后,历史位置的 “残影”…...