# top
top - 21:21:51 up 207 days, 1:30, 5 users, load average: 0.90, 0.79, 1.62 Tasks: 249 total, 1 running, 246 sleeping, 2 stopped, 0 zombie %Cpu(s): 49.2 us, 2.0 sy, 0.0 ni, 48.1 id, 0.0 wa, 0.0 hi, 0.6 si, 0.0 st
如果load average很大(参考核数),则系统负载很高,其中一种可能是由于iowait很大,具体可见%Cpu中的wa,通常wa=0.0,
iowait很大有两种可能,一种是网络,一种是磁盘,并且极有可能是磁盘,检查磁盘io,有多种命令:
1)iotop
Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s Actual DISK READ: 0.00 B/s | Actual 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 % systemd --switched-root --system --deserialize 22 2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd] 3 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0]
# iotop -b -n 5 -d 2
以非交互方式每隔2s运行5次
可以发现读写io很高的进程;
2)iostat
Linux 3.10.0-957.5.1.el7.x86_64 (002) 01/11/2019 _x86_64_ (8 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 15.42 0.00 2.19 1.06 0.00 81.33 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn vda 33.36 100.93 420.00 1805775696 7514000609 vdb 48.99 460.82 5627.92 8244424473 100686856544 vdc 3.77 91.20 262.15 1631539193 4689931576 vdd 0.74 26.14 106.88 467597777 1912213584
# iostat -x 2 5
每隔2s运行5次
avg-cpu: %user %nice %system %iowait %steal %idle 6.73 0.00 15.63 58.83 0.00 18.81 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util vda 0.00 7.00 0.50 6.00 2.00 54.00 17.23 0.00 0.54 0.00 0.58 0.38 0.25 vdb 0.00 5.00 0.00 1.50 0.00 26.00 34.67 0.00 0.67 0.00 0.67 0.67 0.10 vdc 0.00 0.00 1.00 0.00 64.00 0.00 128.00 37.88 23500.00 23500.00 0.00 619.00 61.90 vdd 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
可以发现读写io很高的磁盘;
如果发现一个磁盘读写io很高,怎么查看是哪些进程导致的?
# lsof /dev/vdc1
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 2688 hdfs 299uW REG 253,33 16 3407875 /data/dfs/dn/in_use.lock java 9982 jenkins mem REG 253,33 304183 1181098 /data/jenkins/plugins/github-branch-source/WEB-INF/lib/github-branch-source.jar
如何查看一个进程有哪些io?
# lsof -p $pid
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 19891 hdfs cwd DIR 0,38 400 1047556664 /opt/cloudera-manager/cm-5.16.1/run/cloudera-scm-agent/process/806-hdfs-DATANODE java 19891 hdfs rtd DIR 253,1 4096 2 /