测试磁盘读写性能:
dd命令
# 101服务器实测
[root@localhost vendor]# dd bs=24k count=5000 if=/dev/zero of=test oflag=dsync
记录了5000+0 的读入
记录了5000+0 的写出
122880000字节(123 MB)已复制,146.335 秒,840 kB/秒
#腾讯云最入门服务器实测
[root@VM-0-11-centos ~]# dd bs=24k count=5000 if=/dev/zero of=test oflag=dsync
5000+0 records in
5000+0 records out
122880000 bytes (123 MB) copied, 32.389 s, 3.8 MB/s
#阿里云入门服务器实测
[root@iZm5eabdjz6t0fdix91heoZ ~]# dd bs=64k count=4k if=/dev/zero of=test oflag=dsync
4096+0 records in
4096+0 records out
268435456 bytes (268 MB) copied, 11.9519 s, 22.5 MB/s
time有计时作用,dd用于复制,从if读出,写到of。if=/dev/zero不产生IO,因此可以用来测试纯写速度。同理of=/dev/null不产生IO,可以用来测试纯读速度。bs是每次读或写的大小,即一个块的大小,count是读写块的数量。
这条命令每次读取24k后就要先把这24k写入磁盘,然后再读取下面这24k,一共重复5000次。没有用到写缓存。
这种方法可以模拟数据库的插入操作,所以很慢,也是用来测试vps硬盘性能标准的一条标杆,一般来说测试结果,
如果超过10M,对正常建站就无影响。超过50M,就是非常给力状态。
注意 if参数 读取文本 /dev/zero是系统存在的测试文件,只生产字节,不进行磁盘操作。测读的速度时,需要事先准备一个文本文件。
查看物理硬盘
yum install smartmontools
smartctl -a -d megaraid,0 /dev/sda
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-4.4.214-1.el7.elrepo.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Vendor: TOSHIBA
Product: MG04SCA20ENY
Revision: EG03
Compliance: SPC-4
User Capacity: 2,000,398,934,016 bytes [2.00 TB]
Logical block size: 512 bytes
Formatted with type 2 protection
8 bytes of protection information per logical block
Rotation Rate: 7200 rpm
Form Factor: 3.5 inches
Logical Unit id: 0x5000039958433f9d
Serial number: 49E0A19GF75E
Device type: disk
Transport protocol: SAS (SPL-3)
Local Time is: Fri Aug 27 11:44:26 2021 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Temperature Warning: Disabled or Not Supported
=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK
Current Drive Temperature: 31 C
Drive Trip Temperature: 65 C
Manufactured in week 15 of year 2019
Specified cycle count over device lifetime: 50000
Accumulated start-stop cycles: 22
Specified load-unload count over device lifetime: 600000
Accumulated load-unload cycles: 54
Elements in grown defect list: 0
Error counter log:
Errors Corrected by Total Correction Gigabytes Total
ECC rereads/ errors algorithm processed uncorrected
fast | delayed rewrites corrected invocations [10^9 bytes] errors
read: 0 5 5 5 7 744977.409 0
write: 0 0 0 0 0 12577.443 0
verify: 0 0 0 0 0 150075.761 0
Non-medium error count: 17
SMART Self-test log
Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ]
Description number (hours)
# 1 Background long Aborted (by user command) 80 11 - [- - -]
# 2 Background short Completed 80 10 - [- - -]
# 3 Reserved(7) Completed 64 3 - [- - -]
# 4 Background short Completed 80 1 - [- - -]