Home | 简体中文 | 繁体中文 | 杂文 | 知乎专栏 | Github | OSChina 博客 | 云社区 | 云栖社区 | Facebook | Linkedin | 视频教程 | 打赏(Donations) | About
知乎专栏多维度架构 微信号 netkiller-ebook | QQ群:128659835 请注明“读者”

4.6. Harddisk IO

4.6.1. input/output statistics

$ sudo apt-get install sysstat
		

iostat

$ iostat
Linux 2.6.24-21-generic (netkiller)     Thursday, December 04, 2008

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.57    0.03    0.14    0.41    0.00   98.85

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               6.45       132.69        68.33     595116     306456
sda1              0.00         0.00         0.00       1606         58
sda2              0.00         0.00         0.00        820          0
sda3              2.20         1.16        17.27    1502618   22448752
		

sudo iostat -x 2

# iostat -x 1
avg-cpu: %user %nice %sys %idle
2.04 0.00 97.96 0.00
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
/dev/sda 0.00 633.67 3.06 102.31 24.49 5281.63 12.24 2640.82 288.89 73.67 113.89 27.22 50.00

从输出我们看到w/s=102,wKB/s=2640.所以2640/102=23KB per I/O.

因此对于连续I/O系统来说我们要关注系统读取大量数据的能力即KB per request.对于随机I/O系统我们注重IOPS值.
		

4.6.1.1. 5 秒监控一次

iostat -d 5
			

4.6.2. iotop - simple top-like I/O monitor

# yum install iotop
	    
$ sudo apt-get install iotop
	    

4.6.3. ionice - set or get process I/O scheduling class and priority

4.6.4. smartd - SMART Disk Monitoring Daemon

配置表示smartd以静默状态工作,当SMART中报告PASSED的时候不理睬一旦出现Failure,立刻用邮件通知用户指定的邮箱

vi /etc/smartd.conf
/dev/sdb -H -m neo@domain.com
		

修改配置后重启服务:

/etc/init.d/smartd start