定位I/O Wait问题需要组合一些命令。
1. 首先判定系统变慢是不是I/O引起的?
使用命令:top,查看CPU一行中的%wa数据,该数据是CPU用于I/O Wait的百分比,比如:
Cpu(s): 2.3%us, 1.7%sy, 0.0%ni, 0.0%id, 96.0%wa, 0.0%hi, 0.0%si, 0.0%st
2. 如果确实是I/O Wait引起的问题,查找是哪个磁盘在做频繁的写入操作?
使用命令:iostat -x 2 5,查看磁盘的%util数据,比如:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 44.50 39.27 117.28 29.32 11220.94 13126.70 332.17 65.77 462.79 9.80 2274.71 7.60 111.41
3. 查找哪个进程引起的High I/O?
使用 ps 命令查看进程的状态码,进程状态码说明如下:
(1)D uninterruptible sleep (usually IO)
(2)R running or runnable (on run queue)
(3)S interruptible sleep (waiting for an event to complete)
(4)T stopped, either by a job control signal or because it is being traced.
(5)W paging (not valid since the 2.6.xx kernel)
(6)X dead (should never be seen)
(7)Z defunct ("zombie") process, terminated but not reaped by its parent.
使用如下脚本,打印状态为D的进程,每隔5秒打印一次,打印10次:
for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; done
比如输出如下:
D 16528 bonnie++ -n 0 -u 0 -r 239 -s 478 -f -b -d /tmp
----
D 16528 bonnie++ -n 0 -u 0 -r 239 -s 478 -f -b -d /tmp
----
1. http://www.360doc.com/content/14/0109/14/13876790_343856081.shtml
2. http://bencane.com/2012/08/06/troubleshooting-high-io-wait-in-linux/
3. http://www.360doc.com/content/14/0109/14/13876790_343856953.shtml
1. 首先判定系统变慢是不是I/O引起的?
使用命令:top,查看CPU一行中的%wa数据,该数据是CPU用于I/O Wait的百分比,比如:
Cpu(s): 2.3%us, 1.7%sy, 0.0%ni, 0.0%id, 96.0%wa, 0.0%hi, 0.0%si, 0.0%st
2. 如果确实是I/O Wait引起的问题,查找是哪个磁盘在做频繁的写入操作?
使用命令:iostat -x 2 5,查看磁盘的%util数据,比如:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 44.50 39.27 117.28 29.32 11220.94 13126.70 332.17 65.77 462.79 9.80 2274.71 7.60 111.41
3. 查找哪个进程引起的High I/O?
使用 ps 命令查看进程的状态码,进程状态码说明如下:
(1)D uninterruptible sleep (usually IO)
(2)R running or runnable (on run queue)
(3)S interruptible sleep (waiting for an event to complete)
(4)T stopped, either by a job control signal or because it is being traced.
(5)W paging (not valid since the 2.6.xx kernel)
(6)X dead (should never be seen)
(7)Z defunct ("zombie") process, terminated but not reaped by its parent.
使用如下脚本,打印状态为D的进程,每隔5秒打印一次,打印10次:
for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; done
比如输出如下:
D 16528 bonnie++ -n 0 -u 0 -r 239 -s 478 -f -b -d /tmp
----
D 16528 bonnie++ -n 0 -u 0 -r 239 -s 478 -f -b -d /tmp
----
可以看出,进程16528是引起High I/O的罪魁祸首,找到进程ID,后面的事就好办了。
4. 根据找到的进程ID,查看该进程的I/O统计数据
使用命令:cat /proc/16528/io,比如输出如下:
rchar: 48752567
wchar: 549961789
syscr: 5967
syscw: 67138
read_bytes: 49020928
write_bytes: 549961728
cancelled_write_bytes: 0
5. 根据找到的进程ID,查看该进程都在读写哪些文件?
使用命令:lsof -p 16528,比如输出如下:
bonnie++ 16528 root 8u REG 252,0 501219328 131869 /tmp/Bonnie.16528
bonnie++ 16528 root 9u REG 252,0 501219328 131869 /tmp/Bonnie.16528
bonnie++ 16528 root 10u REG 252,0 501219328 131869 /tmp/Bonnie.16528
bonnie++ 16528 root 11u REG 252,0 501219328 131869 /tmp/Bonnie.16528
6. 使用命令:df /tmp,查看该文件的文件系统
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/workstation-root 7667140 2628608 4653920 37% /
可以看出,/tmp所在的文件系统是workstation-root。
7. 使用命令:pvdisplay,查看物理卷在哪个磁盘上?
--- Physical volume ---
PV Name /dev/sda5
VG Name workstation
PV Size 7.76 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1986
Free PE 8
Allocated PE 1978
PV UUID CLbABb-GcLB-l5z3-TCj3-IOK3-SQ2p-RDPW5S
可以看出,文件系统的名称是workstation,说明/tmp所在的文件系统:workstation-root,是其的一部分。
因此,可以断定,High I/O的问题是由进程16528频繁在/tmp目录进行写操作导致的,
而且/tmp就位于磁盘sda。
参考文献:
2. http://bencane.com/2012/08/06/troubleshooting-high-io-wait-in-linux/
3. http://www.360doc.com/content/14/0109/14/13876790_343856953.shtml
没有评论:
发表评论