今天发现 Web 页面响应十分缓慢,卡顿严重。上去使用top
命令发现有个进程CPU占用过高,负载已经接近临界值了。(16核的机器)
load average: 15.70, 14.27, 13.87
top - 19:05:49 up 35 days, 17:16, 1 user, load average: 15.70, 14.27, 13.87
Tasks: 378 total, 2 running, 376 sleeping, 0 stopped, 0 zombie
Cpu(s): 99.8%us, 0.2%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 15428940k total, 2491332k used, 12937608k free, 10944k buffers
Swap: 4194300k total, 403108k used, 3791192k free, 149312k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
31755 apache 20 0 86408 40m 8 S 1598.2 0.3 16:43.45 spopqrs
31854 root 20 0 162m 2248 1792 R 1.0 0.0 0:00.76 rrdtool
1308 root 20 0 0 0 0 S 0.7 0.0 71:01.14 flush-8:0
32052 root 20 0 15304 1572 1008 R 0.3 0.0 0:00.02 top
1 root 20 0 19232 464 280 S 0.0 0.0 3:02.23 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:07.21 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:25.39 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 stopper/0
6 root RT 0 0 0 0 S 0.0 0.0 0:03.06 watchdog/0
7 root RT 0 0 0 0 S 0.0 0.0 0:06.46 migration/1
8 root RT 0 0 0 0 S 0.0 0.0 0:00.00 stopper/1
9 root 20 0 0 0 0 S 0.0 0.0 0:10.43 ksoftirqd/1
10 root RT 0 0 0 0 S 0.0 0.0 0:05.04 watchdog/1
根据上面获得的PID,查下看看该进程使用的相关文件,没有用的话就删掉。
[root@livejq ~]# lsof | grep 31755
spopqrs 31755 apache cwd DIR 8,3 12288 3933657 /var/www/html/plugins/weathermap/configs
spopqrs 31755 apache rtd DIR 8,3 4096 2 /
spopqrs 31755 apache txt unknown /proc/31755/exe (readlink: No such file or directory)
spopqrs 31755 apache mem REG 8,3 2318020 3408133 /tmp/spopqrs
spopqrs 31755 apache mem REG 8,3 528 132315 /etc/localtime
spopqrs 31755 apache 0u CHR 1,3 0t0 3929 /dev/null
spopqrs 31755 apache 1u CHR 1,3 0t0 3929 /dev/null
spopqrs 31755 apache 2u CHR 1,3 0t0 3929 /dev/null
spopqrs 31755 apache 3u sock 0,6 0t0 19097231 can't identify protocol
spopqrs 31755 apache 4r REG 0,3 0 4026532035 /proc/stat
spopqrs 31755 apache 5u IPv4 117412003 0t0 TCP hkhdc.laws.ms:42924->no-data:terabase (ESTABLISHED)
spopqrs 31755 apache 6u REG 0,9 0 3925 [eventpoll]
spopqrs 31755 apache 7r FIFO 0,8 0t0 117462586 pipe
spopqrs 31755 apache 8w FIFO 0,8 0t0 117462586 pipe
spopqrs 31755 apache 9r FIFO 0,8 0t0 117462587 pipe
spopqrs 31755 apache 10w FIFO 0,8 0t0 117462587 pipe
spopqrs 31755 apache 11u REG 0,9 0 3925 [eventfd]
spopqrs 31755 apache 12w REG 8,3 0 3408134 /tmp/spopqrs.txt
spopqrs 31755 apache 13u REG 0,9 0 3925 [eventfd]
spopqrs 31755 apache 14u REG 0,9 0 3925 [eventfd]
spopqrs 31755 apache 15u REG 0,9 0 3925 [eventfd]
spopqrs 31755 apache 17u unix 0xffff880075c431c0 0t0 17227580 socket
很明显,上面这个临时文件/tmp/spopqrs
跟占用进程的一致,删除后杀掉该进程,这边就恢复正常了。
评论区