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

news2024/9/22 3:45:04

目录

  一、实验

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 -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) 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进程

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1543544.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

电路笔记 :嘉立创EDA常用功能

原理图 翻转和旋转 嘉立创连线快捷键:Alt W 原理图转PCB 交叉选择(切换至PCB并高亮选中的部分)快捷键:“SHIFT X” PCB pcb边框 画pcb边框:放置-》板框-》矩形 挖槽 布线 pcB检查 出错的地方会有小叉子 等长调节…

NKCTF--pwn--Maimai查分器

NKCTF–pwn–Maimai查分器 Maimai查分器 保护全开 存在格式化字符串漏洞 第一步:先测速率,输入15.0 SSS 50次获得最高速率 ​ sl(b1) #debug() for i in range(50):sl(b15.0 SSS)然后利用格式化字符串去泄露,本来想一口气全部泄露的&…

继承和多态(2)(多态部分)

提前讲的重要知识点 一个类在没有父类的情况下默认有一个父类为Object类。 而当在有父类情况下,如果你那父类没有父类,则其父类的父类默认为object类,所以即使一个类有父类,其内部还是有object类。 object类都是隐藏起来的&…

浅谈C++引用的使用以及底层原理

文章目录 1、引用概念2、引用特性3、常引用4、引用的使用场景(1)做参数(2)做返回值 1、引用概念 引用不是新定义一个变量,而是给已存在变量取了一个别名,编译器不会为引用变量开辟内存空间,它和…

链式二叉树经典OJ题目(一)

目录 结构体声明: 1.单值二叉树 题目描述: 思路分析: 源码: 2.二叉树最大深度 题目描述: 思路分析: 源码: 3.检查两棵树是否相同 题目描述: 思路分析: 源码…

EMC | 浪涌保护电路NTC

NTC(5D-11)负温度系数热敏电阻。 NTC是过流器件。 抑制开机的浪涌电流,NTC温度越高,电阻越低。 如果没有NTC,220VAC开机对电容CE3充电,此时电容中没有电荷,CE3相当于短路,回路电流会很大。 选型注意 1、R25温度下电阻…

Negative Sampling with Adaptive DenoisingMixup for Knowledge Graph Embedding

摘要 知识图嵌入(Knowledge graph embedding, KGE)的目的是通过对比正负三元组,将知识图中的实体和关系映射到一个低维、密集的向量空间中。在kge的训练过程中,由于kge只包含正三元组,因此负采样对于找到高质量的负三元组至关重要。大多数现…

鸿蒙NXET实战:高德地图定位SDK【获取Key+获取定位数据】(二)

如何申请key 1、创建新应用 进入[控制台],创建一个新应用。如果您之前已经创建过应用,可直接跳过这个步骤。 2、添加新Key 在创建的应用上点击"添加新Key"按钮,在弹出的对话框中,依次:输入应用名名称&…

04、JS实现:用⼆分法思想实现搜索旋转排序数组(一步一步剖析,很详细)

搜索旋转排序数组 Ⅰ、搜索旋转排序数组:1、题目描述:2、解题思路:3、实现代码: Ⅱ、小结: Ⅰ、搜索旋转排序数组: 1、题目描述: 给你⼀个升序排列的整数数组 nums ,和⼀个整数 tar…

【刷题】滑动窗口精通 — Leetcode 30. 串联所有单词的子串 | Leetcode 76. 最小覆盖子串

送给大家一句话: 充满着欢乐与斗争精神的人们,永远带着欢乐,欢迎雷霆与阳光。 —— 赫胥黎 滑动窗口精通 前言Leetcode 30. 串联所有单词的子串题目描述算法思路 Leetcode 76. 最小覆盖子串题目描述算法思路 Thanks♪(・ω&#xf…

产品推荐 | 基于 Zynq UltraScale+ XCZU27DR的 FACE-RFSoC-C高性能自适应射频开发平台

一、产品概述 FACE-RFSOC-C自适应射频开发平台,是FACE系列新一代的产品。 平台搭载有16nm工艺的Zynq UltraScale™ RFSoC系列主器件。该器件集成数千兆采样RF数据转换器和ARM Cortex-A53处理子系统和UltraScale可编程逻辑,是一款单芯片自适应射频平台。…

风力发电模型Windpowerlib概述与入门

Windpowerlib 是一个提供了一系列函数和类的库,用于计算风力涡轮机的功率输出。它最初是 feedinlib(风能和光伏)的一部分,但后来被分离出来,以建立一个专注于风能模型的社区。 这个库的主要目的是简化风力涡轮机的能量…

Vue3 + Vite + TS + Element-Plus + Pinia项目(3)--新建路由

1、在src文件夹下新建router文件夹后,创建index.ts文件 2、具体如下 import { createRouter, createWebHashHistory } from vue-routerconst router createRouter({history: createWebHashHistory(),routes: [{path: "/index",component: () > impor…

红黑树进阶:正向与反向迭代器的实现及map、set的封装实践

文章目录 一、引言二、红黑树迭代器设计1、迭代器的基本概念和分类2、正向迭代器设计a.迭代器结构定义b.迭代器的 与 -- 3、反向迭代器设计a.反向迭代器的必要性b.反向迭代器的实现要点 4、红黑树封装迭代器 三、使用红黑树实现Map四、红黑树实现Set五、细节理解1、 typname的使…

JAVA学习笔记19(面向对象编程)

1.面向对象编程 1.1 类与对象 1.类与对象的概念 ​ *对象[属性]/[行为] ​ *语法 class cat {String name;int age; }main() {//cat1就是一个对象//创建一只猫Cat cat1 new Cat();//给猫的属性赋值cat1.name "123";cat1.age 10; }​ *类是抽象的,…

【Redis系列】那有序集合为什么要同时使用字典和跳跃表

面试官:听说你精通Redis,那我就考考你吧 面试官:不用慌尽管说,错了也没关系😊。。。 以【面试官面试】的形式来分享技术,本期是《Redis系列》,感兴趣就关注我吧❤️ 面试官:你说说Re…

个人可以做知识付费网站吗

个人可以做知识付费网站吗 个人能够做学问付费网站吗?答案是肯定的!如今个人做学问付费网站并不需求太多的资金和技术支持,我们只需求购置一台效劳器或虚拟主机,然后在该主机空间上搭建一个WordPress网站,最后运用带有…

商家如何自己零成本免费制作点餐小程序项目完整源码

现在点餐小程序成为餐饮店的标配,顾客只要扫码,即可进入小程序点餐。顾客付款后,后厨自动打印出订单并开始制作。整个过程非常方便流畅,甚至还可以免去收银(或服务)人员。那么,这种餐饮小程序要…

类和对象三部曲(one)

都说C语言是面向过程,分析出求解问题的步骤,通过函数调用来逐步解决问题。 拿洗衣服来举例,C关注的是一个过程: 那么C是什么呢? 面向对象的编程语言。 面向对象对象指什么? 象棋里的对象么?…

JavaScript学习第二天

1.学习JavaScript高级语法目的 降低后续对于前端框架学习难度 1.局部变量与全局变量 1.局部变量: 在函数体内部通过var声明的变量 1.局部变量特点: 局部变量只能在当前函数体内使用,不能 在函数体外使用 2.全局变量 在script标签下直接…