当前位置: 首页 > 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,高压脉冲引出...

系统设计 --- MongoDB亿级数据查询优化策略

系统设计 --- MongoDB亿级数据查询分表策略 背景Solution --- 分表 背景 使用audit log实现Audi Trail功能 Audit Trail范围: 六个月数据量: 每秒5-7条audi log&#xff0c;共计7千万 – 1亿条数据需要实现全文检索按照时间倒序因为license问题&#xff0c;不能使用ELK只能使用…...

什么是EULA和DPA

文章目录 EULA&#xff08;End User License Agreement&#xff09;DPA&#xff08;Data Protection Agreement&#xff09;一、定义与背景二、核心内容三、法律效力与责任四、实际应用与意义 EULA&#xff08;End User License Agreement&#xff09; 定义&#xff1a; EULA即…...

Rust 异步编程

Rust 异步编程 引言 Rust 是一种系统编程语言,以其高性能、安全性以及零成本抽象而著称。在多核处理器成为主流的今天,异步编程成为了一种提高应用性能、优化资源利用的有效手段。本文将深入探讨 Rust 异步编程的核心概念、常用库以及最佳实践。 异步编程基础 什么是异步…...

Python如何给视频添加音频和字幕

在Python中&#xff0c;给视频添加音频和字幕可以使用电影文件处理库MoviePy和字幕处理库Subtitles。下面将详细介绍如何使用这些库来实现视频的音频和字幕添加&#xff0c;包括必要的代码示例和详细解释。 环境准备 在开始之前&#xff0c;需要安装以下Python库&#xff1a;…...

Java数值运算常见陷阱与规避方法

整数除法中的舍入问题 问题现象 当开发者预期进行浮点除法却误用整数除法时,会出现小数部分被截断的情况。典型错误模式如下: void process(int value) {double half = value / 2; // 整数除法导致截断// 使用half变量 }此时...

[免费]微信小程序问卷调查系统(SpringBoot后端+Vue管理端)【论文+源码+SQL脚本】

大家好&#xff0c;我是java1234_小锋老师&#xff0c;看到一个不错的微信小程序问卷调查系统(SpringBoot后端Vue管理端)【论文源码SQL脚本】&#xff0c;分享下哈。 项目视频演示 【免费】微信小程序问卷调查系统(SpringBoot后端Vue管理端) Java毕业设计_哔哩哔哩_bilibili 项…...

关于easyexcel动态下拉选问题处理

前些日子突然碰到一个问题&#xff0c;说是客户的导入文件模版想支持部分导入内容的下拉选&#xff0c;于是我就找了easyexcel官网寻找解决方案&#xff0c;并没有找到合适的方案&#xff0c;没办法只能自己动手并分享出来&#xff0c;针对Java生成Excel下拉菜单时因选项过多导…...

elementUI点击浏览table所选行数据查看文档

项目场景&#xff1a; table按照要求特定的数据变成按钮可以点击 解决方案&#xff1a; <el-table-columnprop"mlname"label"名称"align"center"width"180"><template slot-scope"scope"><el-buttonv-if&qu…...

【LeetCode】算法详解#6 ---除自身以外数组的乘积

1.题目介绍 给定一个整数数组 nums&#xff0c;返回 数组 answer &#xff0c;其中 answer[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积 。 题目数据 保证 数组 nums之中任意元素的全部前缀元素和后缀的乘积都在 32 位 整数范围内。 请 不要使用除法&#xff0c;且在 O…...

Ubuntu系统多网卡多相机IP设置方法

目录 1、硬件情况 2、如何设置网卡和相机IP 2.1 万兆网卡连接交换机&#xff0c;交换机再连相机 2.1.1 网卡设置 2.1.2 相机设置 2.3 万兆网卡直连相机 1、硬件情况 2个网卡n个相机 电脑系统信息&#xff0c;系统版本&#xff1a;Ubuntu22.04.5 LTS&#xff1b;内核版本…...