赤峰项目Nginx进程异常的处理办法

#强制杀掉Nginx
ps -ef|grep nginx|grep -v grep|awk '{print $2}'|xargs kill -9
rm -rf /usr/local/openresty/nginx/logs/nginx.pid

(1)如果进程中没有NGINX存在:
[root@huanghai conf]# ps -ef|grep nginx|grep -v grep|awk '{print $2}'|xargs kill -9
usage: kill [ -s signal | -p ] [ -a ] pid ...
       kill -l [ signal ]
(2)如果进程中有NGINX存在,那么无回显


#重启Nginx
service nginx restart && ps -ef | grep nginx

kill -9 杀不掉进程的原因
http://blog.csdn.net/u012349696/article/details/52250640


ps aux | grep nginx | grep -v grep

USER    PID   %CPU %MEM VSZ   RSS TTY    STAT   START TIME COMMAND
root       9562  0.0  0.0  52664  1344 ?        Ss   22:27   0:00 nginx: master process /usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf
nobody     9566  0.0  0.0  53036  1976 ?        S    22:27   0:00 nginx: worker process                                                              
nobody     9567  0.0  0.0  53036  2044 ?        S    22:27   0:00 nginx: worker process                                                              
nobody     9568  0.0  0.0  53036  2044 ?        S    22:27   0:00 nginx: worker process                                                              
nobody     9569  0.0  0.0  53036  2016 ?        S    22:27   0:00 nginx: worker process  

D状态的进程是硬件资源不满足而处于深度休眠状态, 一般是等待磁盘. 这种进程用kill -9杀不掉, 要么继续等, 要么重启

stat 中的参数意义如下:
   D 不可中断 Uninterruptible(usually IO)
   R 正在运行,或在队列中的进程
   S 处于休眠状态
   T 停止或被追踪
   Z 僵尸进程
   W 进入内存交换(从内核2.6开始无效)
   X   死掉的进程

 < 高优先级
    n   低优先级
    s   包含子进程
    +   位于后台的进程组




#查看io情况
yum install iotop -y
yum install sysstat -y


[root@huanghai ~]# iotop
Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                                        
    1 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % init
    2 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kthreadd]
    3 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [migration/0]
    4 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [ksoftirqd/0]
    5 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [stopper/0]
    6 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [watchdog/0]
    7 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events/0]
    8 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events/0]
    9 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events_long/0]
   10 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events_power_ef]
   11 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [cgroup]
   12 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [khelper]
   13 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [netns]
   14 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [async/mgr]
   15 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [pm]
   16 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [sync_supers]
   17 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [bdi-default]
   18 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kintegrityd/0]


[root@huanghai ~]#ps -ef | grep nginx
root       1424      1  0 22:41 ?        00:00:00 nginx: master process /usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf
root       1427   1351  0 22:41 pts/0    00:00:00 grep nginx
nobody     1428   1424  0 22:41 ?        00:00:00 nginx: worker process                                                              
nobody     1429   1424  0 22:41 ?        00:00:00 nginx: worker process                                                              
nobody     1430   1424  0 22:41 ?        00:00:00 nginx: worker process                                                              
nobody     1431   1424  0 22:41 ?        00:00:00 nginx: worker process   

先对一下时间:

ntpdate cn.ntp.org.cn

http://www.ntp.org.cn/


[root@huanghai ~]# pidstat -d -p 1424
Linux 2.6.32-696.el6.x86_64 (huanghai)  2017年08月26日  _x86_64_        (1 CPU)

22时41分27秒       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
22时41分27秒      1424      0.00      0.01      0.00  nginx

由此来测算NGINX的无响应情况下它的IO使用情况如何。

还有就是赤峰还需要进一步检查系统优化情况,打开文件数等参数是否设置正确。

原文地址:https://www.cnblogs.com/littlehb/p/7450288.html