1. 概述
常言道:有数据,有真相。数据库的性能瓶颈分析也是需要拿出具体的数据来的,否则单纯的说谁比谁性能强弱,都是没有说服力和根据的。关于内存数据库和磁盘数据库的性能对比也是如此。内存数据库通过读取内存中的数据来实现读写加速,磁盘数据库通过硬盘IO实现数据读写。Linux平台提供了专门的工具来时先磁盘IO性能的获取,该工具为hdparm,本文就该工具的使用做一个详细的介绍。
2.命令格式
Usage: hdparm [options] [device] ..
3.示例结果
[root@localhost zhangzl]# hdparm -Tt /dev/sda
/dev/sda:
Timing cached reads: 3820 MB in 2.00 seconds = 1910.72 MB/sec
Timing buffered disk reads: 42 MB in 3.05 seconds = 13.78 MB/sec
在这里我们就能看到差距来了,1910.72/13.78=138.66,一百多倍的读取差距,还是相当可观的。以上数据是我在虚拟机环境下测试的结果,具体的性能指标因机器配置、性能不同,会有不同,需要自行测试。
4.参数详解
Options:
-a get/set fs readahead
-A set drive read-lookahead flag (0/1)
-b get/set bus state (0 == off, 1 == on, 2 == tristate)
-B set Advanced Power Management setting (1-255)
-c get/set IDE 32-bit IO setting
-C check IDE power mode status
-d get/set using_dma flag
--direct use O_DIRECT to bypass page cache for timings
-D enable/disable drive defect management
-E set cd-rom drive speed
-f flush buffer cache for device on exit
-g display drive geometry
-h display terse usage information
-i display drive identification
-I detailed/current information directly from drive
--Istdin read identify data from stdin as ASCII hex
--Istdout write identify data to stdout as ASCII hex
-k get/set keep_settings_over_reset flag (0/1)
-K set drive keep_features_over_reset flag (0/1)
-L set drive doorlock (0/1) (removable harddisks only)
-M get/set acoustic management (0-254, 128: quiet, 254: fast) (EXPERIMENTAL)
-m get/set multiple sector count
-n get/set ignore-write-errors flag (0/1)
-p set PIO mode on IDE interface chipset (0,1,2,3,4,...)
-P set drive prefetch count
-q change next setting quietly
-Q get/set DMA tagged-queuing depth (if supported)
-r get/set device readonly flag (DANGEROUS to set)
-R register an IDE interface (DANGEROUS)
-S set standby (spindown) timeout
-t perform device read timings
-T perform cache read timings
-u get/set unmaskirq flag (0/1)
-U un-register an IDE interface (DANGEROUS)
-v defaults; same as -mcudkrag for IDE drives
-V display program version and exit immediately
-w perform device reset (DANGEROUS)
-W set drive write-caching flag (0/1) (DANGEROUS)
-x tristate device for hotswap (0/1) (DANGEROUS)
-X set IDE xfer mode (DANGEROUS)
-y put IDE drive in standby mode
-Y put IDE drive to sleep
-Z disable Seagate auto-powersaving mode
-z re-read partition table
--security-help display help for ATA security commands