til
sda 0.82 0.43 0.76 0.52 0.02 0.00 38.49 0.01 6.27 4.82 0.62
sda1 0.80 0.42 0.53 0.51 0.02 0.00 45.09 0.01 6.92 5.50 0.57
sda2 0.01 0.02 0.12 0.01 0.00 0.00 9.70 0.00 2.95 2.79 0.04
sda3 0.01 0.00 0.07 0.00 0.00 0.00 8.67 0.00 3.72 3.65 0.03
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
[root@localhost ~]# iostat -d -m -p sda 2 3
Linux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)
Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn
sda 1.25 0.02 0.00 97 18
sda1 1.02 0.02 0.00 92 17
sda2 0.13 0.00 0.00 2 0
sda3 0.07 0.00 0.00 1 0
Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn
sda 0.00 0.00 0.00 0 0
sda1 0.00 0.00 0.00 0 0
sda2 0.00 0.00 0.00 0 0
sda3 0.00 0.00 0.00 0 0
Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn
sda 0.00 0.00 0.00 0 0
sda1 0.00 0.00 0.00 0 0
sda2 0.00 0.00 0.00 0 0
sda3 0.00 0.00 0.00 0 0
?
2.3 使用 vmstat 查看磁盘IO
?
[root@localhost ~]# vmstat 2 4
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 454900 21808 76776 0 0 20 4 97 81 0 5 95 0 0
0 0 0 454892 21808 76772 0 0 0 8 83 106 0 3 97 0 0
1 0 0 454760 21816 76772 0 0 0 44 101 153 1 5 94 0 0
0 0 0 454760 21816 76784 0 0 0 0 57 68 0 1 99 0 0
?
?
?bi: Blocks received from a block device (blocks/s). 每秒读取多少个block到内存
?bo: Blocks sent to a block device (blocks/s). 每秒内存写出多少个block到磁盘
?
2.4 使用 sar -b 查看磁盘IO
?
[root@localhost ~]# sar -b 2 4
Linux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)
03:53:21 PM tps rtps wtps bread/s bwrtn/s
03:53:23 PM 0.00 0.00 0.00 0.00 0.00
03:53:25 PM 0.00 0.00 0.00 0.00 0.00
03:53:27 PM 0.00 0.00 0.00 0.00 0.00
03:53:29 PM 0.00 0.00 0.00 0.00 0.00
Average: 0.00 0.00 0.00 0.00 0.00
?
?
tps: 上面有介绍;rtps: 表示读的tps;wtps: 表示写的tps;
?
bread/s: 每秒读多少个block;bwrtn/s: 每秒写多少个block;
?
2.5 使用 iotop 找到IO最多的进程/线程
?
iotop类似于top命令,默认按照IO排序:
?
iotop :
?
?
iotop 是可以交互的:
?
? ? ? ?Use ?the ?left ?and ?right arrows to change the sorting, r to reverse the sorting order, o to toggle the --only
? ? ? ?option, p to toggle the --processes option, a to toggle the --accumulated option, q to quit or i to change ?the
? ? ? ?priority of a thread or a process’ thread(s). Any other key will force a refresh.
1)利用左右键 可以选择排序的字段,默认按照IO>倒序,可以按照SWAPIN,DISK WRITE 等等字段排序,使用左右方向键即可;
?
2)利用 p键 可以在按照 进程显示 和按照 线程显示之间切换;
?
3)r 键可以改变排序的方向:倒序 和 顺序
?
查看mysqld的IO:
?
iotop -k -u mysql (-k 表示KB,-u mysql表示显示mysql用户的所有进程的IO):
3. 实例分析
$$iostat -d -k 1 |grep sda10
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda10 60.72 18.95 71.53 395637647 1493241908
sda10 299.02 4266.67 129.41 4352 132
sda10 483.84 4589.90 4117.17 4544 4076
sda10 218.00 3360.00 100.00 3360 100
sda10 546.00 8784.00 124.00 8784 124
sda10 827.00 13232.00 136.00 13232 136
?
?
上面看到,磁盘每秒传输次数平均约400;每秒