首先,用top查看下,终端下执行命令top
top - 21:39:02 up 386 days, 4:53, 4 users, load average: 0.52, 0.38, 0.33
Tasks: 192 total, 2 running, 190 sleeping, 0 stopped, 0 zombie
%Cpu(s): 6.1 us, 2.5 sy, 0.0 ni, 90.5 id, 0.0 wa, 0.0 hi, 0.8 si, 0.0 st
KiB Mem : 16266420 total, 199040 free, 1784872 used, 14282508 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 14090404 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
11309 root 20 0 476120 16568 8104 S 10.0 0.1 2:09.16 php
12591 root 20 0 476120 21348 12932 R 9.3 0.1 0:46.45 php
874 nginx 20 0 152092 32476 1336 S 1.3 0.2 299:48.78 nginx
12130 apache 20 0 567336 16116 5496 S 1.3 0.1 0:07.50 php-fpm
12134 apache 20 0 556560 12468 2952 S 1.3 0.1 0:07.26 php-fpm
然后使用vmstat 1 6
查看排队的进程队列长度,r表示运行和等待CPU时间片的进程数量;b表示等待资源的进程数量比如IO、或者内存交互等
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 197704 278940 14005812 0 0 1 61 0 0 1 0 99 0 0
0 0 0 197772 278940 14006100 0 0 0 0 12080 6796 5 2 94 0 0
1 0 0 197224 278948 14005880 0 0 0 20 13736 7562 4 3 93 0 0
0 0 0 195492 278948 14006000 0 0 0 0 14727 8175 5 2 93 0 0
0 0 0 197448 278952 14006036 0 0 0 4552 13573 7523 4 2 92 3 0
1 0 0 197212 278952 14005852 0 0 0 712 14402 8003 5 2 93 0 0
再使用ps ux
查看当前激活的进程。附带几个ps
的参数,ps是process status的缩。
ps -ux, 查看当前的激活的进程
ps -aux,查看当前所有进程,a是all的意思
ps -U vilay,查看vilay这个用户有关的进程
杀死进程的方法
kill pid #kill 进程id
kill -9 pid #-9表示强制杀死
查看某个进程的哪个线程使用率高
top -p 11309 -H #11309表示进程id
然后杀死进程,这样负载就会下来。