测试磁盘读写性能:

dd命令

  1. # 101服务器实测
  2. [root@localhost vendor]# dd bs=24k count=5000 if=/dev/zero of=test oflag=dsync
  3. 记录了5000+0 的读入
  4. 记录了5000+0 的写出
  5. 122880000字节(123 MB)已复制,146.335 秒,840 kB/秒
  1. #腾讯云最入门服务器实测
  2. [root@VM-0-11-centos ~]# dd bs=24k count=5000 if=/dev/zero of=test oflag=dsync
  3. 5000+0 records in
  4. 5000+0 records out
  5. 122880000 bytes (123 MB) copied, 32.389 s, 3.8 MB/s
  1. #阿里云入门服务器实测
  2. [root@iZm5eabdjz6t0fdix91heoZ ~]# dd bs=64k count=4k if=/dev/zero of=test oflag=dsync
  3. 4096+0 records in
  4. 4096+0 records out
  5. 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是系统存在的测试文件,只生产字节,不进行磁盘操作。测读的速度时,需要事先准备一个文本文件。

查看物理硬盘

  1. yum install smartmontools
  2. smartctl -a -d megaraid,0 /dev/sda
  3. smartctl 7.0 2018-12-30 r4883 [x86_64-linux-4.4.214-1.el7.elrepo.x86_64] (local build)
  4. Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
  5. === START OF INFORMATION SECTION ===
  6. Vendor: TOSHIBA
  7. Product: MG04SCA20ENY
  8. Revision: EG03
  9. Compliance: SPC-4
  10. User Capacity: 2,000,398,934,016 bytes [2.00 TB]
  11. Logical block size: 512 bytes
  12. Formatted with type 2 protection
  13. 8 bytes of protection information per logical block
  14. Rotation Rate: 7200 rpm
  15. Form Factor: 3.5 inches
  16. Logical Unit id: 0x5000039958433f9d
  17. Serial number: 49E0A19GF75E
  18. Device type: disk
  19. Transport protocol: SAS (SPL-3)
  20. Local Time is: Fri Aug 27 11:44:26 2021 CST
  21. SMART support is: Available - device has SMART capability.
  22. SMART support is: Enabled
  23. Temperature Warning: Disabled or Not Supported
  24. === START OF READ SMART DATA SECTION ===
  25. SMART Health Status: OK
  26. Current Drive Temperature: 31 C
  27. Drive Trip Temperature: 65 C
  28. Manufactured in week 15 of year 2019
  29. Specified cycle count over device lifetime: 50000
  30. Accumulated start-stop cycles: 22
  31. Specified load-unload count over device lifetime: 600000
  32. Accumulated load-unload cycles: 54
  33. Elements in grown defect list: 0
  34. Error counter log:
  35. Errors Corrected by Total Correction Gigabytes Total
  36. ECC rereads/ errors algorithm processed uncorrected
  37. fast | delayed rewrites corrected invocations [10^9 bytes] errors
  38. read: 0 5 5 5 7 744977.409 0
  39. write: 0 0 0 0 0 12577.443 0
  40. verify: 0 0 0 0 0 150075.761 0
  41. Non-medium error count: 17
  42. SMART Self-test log
  43. Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ]
  44. Description number (hours)
  45. # 1 Background long Aborted (by user command) 80 11 - [- - -]
  46. # 2 Background short Completed 80 10 - [- - -]
  47. # 3 Reserved(7) Completed 64 3 - [- - -]
  48. # 4 Background short Completed 80 1 - [- - -]