赞
踩
我们的工作环境中,经常会出现各种各样的进程问题,而我们要做的就是快速发现问题、解决问题。
top:实时显示系统中各个进程的资源占用状态
ps:显示瞬间进程的状态
strace:跟踪进程的系统调用
lsof:列出某个程序进程所打开的文件信息
free:用来查看系统可用内存
iostat:动态监视系统磁盘操作活动
vmstat:实时动态监控操作系统的虚拟内存、进程、cpu活动
ldd:用来查看程序运行所需的共享库
问题进程排查方式
针对CPU资源使用情况排查
top
命令可以列出进程的资源使用情况,按住shift+p
就可以按照CPU使用率的大小排序,可以直观的看到每个进程占用的CPU使用率top
把瞬间的系统进程状态提取出来
ps -aux --sort=-%cpu|head -n 10
[root@centos7 ~]# ps -aux --sort=-%cpu|head -n 10
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 953 0.2 0.2 273196 4876 ? Ssl 3月05 0:14 /usr/bin/vmtoolsd
root 1959 0.2 0.0 0 0 ? S 00:08 0:00 [kworker/0:3]
root 415 0.1 0.0 0 0 ? S 3月05 0:07 [xfsaild/dm-0]
root 1910 0.1 0.0 0 0 ? S 3月05 0:01 [kworker/0:1]
root 1937 0.1 0.0 0 0 ? S 00:00 0:01 [kworker/0:2]
root 1 0.0 0.2 125768 4260 ? Ss 3月05 0:03 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 2 0.0 0.0 0 0 ? S 3月05 0:00 [kthreadd]
root 4 0.0 0.0 0 0 ? S< 3月05 0:00 [kworker/0:0H]
root 6 0.0 0.0 0 0 ? S 3月05 0:00 [ksoftirqd/0]
查找进程使用内存资源过多
top
命令,按Shift+m
就是按照内存的方式排序ps
命令也是一样,把-%cpu换成-%MEM即可iostat
命令查看yum -y install sysstat
命令安装iostat 2 1
[root@centos7 ~]# iostat 2 1
Linux 3.10.0-1160.el7.x86_64 (centos7) 2021年03月06日 _x86_64_ (2 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.10 0.00 0.25 0.02 0.00 99.63
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 1.00 19.20 2.40 106015 13243
scd0 0.00 0.19 0.00 1028 0
dm-0 0.67 17.03 2.03 94054 11195
dm-1 0.02 0.40 0.00 2204 0
iotop
命令[root@centos7 ~]# cat /proc/sys/fs/file-max
190603
[root@centos7 fs]# cat /proc/sys/fs/file-nr
1152 0 190603
[root@centos7 ~]# ulimit -n
1024
ll /rpoc/{pid}/fd
wc
进行统计僵尸进程
top
来查看当前系统的僵尸进程ps -e -o ppid,stat | grep Z
ps -e -o ppid,stat | grep Z | cut -d "" -f2 | xargs kill -9
进程不可中断睡眠状态
以上内容都是我买的一个小课里的,只有命令总结,没写描述性的文字,所有可能有的地方不是很清晰,见谅。
嘿嘿。应该不会有什么侵权什么的吧?是吧?是吧?
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。