Linux服务器装好系统之后,想要知道硬盘的读写是否能满足服务的需要,如果不满足硬盘的IO就是服务的一个瓶颈。所以我们需要测试硬盘的读写速度,测试的方法很多,下面是使用Linux 自带的dd命令测试硬盘的读写速度。
time有计时作用,dd用于复制,从if读出,写到of。if=/dev/zero不产生IO,因此可以用来测试纯写速度。同理of=/dev/null不产生IO,可以用来测试纯读速度。bs是每次读或写的大小,即一个块的大小,count是读写块的数量。
测/data目录所在磁盘的纯写速度:
[root@localhost ~]# time dd if=/dev/zero of=/var/test bs=8k count=1000000
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB) copied, 52.5749 seconds, 156 MB/s
real 0m55.841s
user 0m0.507s
sys 0m15.706s
1
2
3
4
5
6
7
8
[root@localhost~]# time dd if=/dev/zero of=/var/test bs=8k count=1000000
1000000+0recordsin
1000000+0recordsout
8192000000bytes(8.2GB)copied,52.5749seconds,156MB/s
real0m55.841s
user0m0.507s
sys0m15.706s
测/data目录所在磁盘的纯读速度:
[root@localhost ~]# time dd if=/var/test of=/dev/null bs=8k
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB) copied, 49.0088 seconds, 167 MB/s
real 0m49.025s
user 0m0.559s
sys 0m6.383s
1
2
3
4
5
6
7
8
[root@localhost~]# time dd if=/var/test of=/dev/null bs=8k
1000000+0recordsin
1000000+0recordsout
8192000000bytes(8.2GB)copied,49.0088seconds,167MB/s
real0m49.025s
user0m0.559s
sys0m6.383s
测读写速度:
[root@localhost ~]# time dd if=/var/test of=/tmp/test bs=64k
125000+0 records in
125000+0 records out
8192000000 bytes (8.2 GB) copied, 129.239 seconds, 63.4 MB/s
real 2m9.251s
user 0m0.114s
sys 0m21.494s
1
2
3
4
5
6
7
8
[root@localhost~]# time dd if=/var/test of=/tmp/test bs=64k
125000+0recordsin
125000+0recordsout
8192000000bytes(8.2GB)copied,129.239seconds,63.4MB/s
real2m9.251s
user0m0.114s
sys0m21.494s
看来这个测试结果还不错,嘿嘿
备注:理论上测试复制量越大测试结果越准确。
正常测试的时候可能不止测试一边,可能会需要很多遍求取平均值,这个测试结果在普通的重定向是没有效果的 之后 google 了一下 用下面的方式重定向到一个文件
dd if=/dev/zero of=/var/test bs=8k count=1000000 2>> info
1
ddif=/dev/zeroof=/var/testbs=8kcount=10000002>>info
这样测试的结果就到info文件里面了
如果您觉得本站对你有帮助,那么可以支付宝扫码捐助以帮助本站更好地发展,在此谢过。
如果觉得《linux查看磁盘读取慢日志 Linux命令:使用dd测磁盘读写速度》对你有帮助,请点赞、收藏,并留下你的观点哦!