码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下硬盘性能测试

时间:2018-05-24 00:08:00      阅读:450      评论:0      收藏:0      [点我收藏+]

标签:iozone   dd   

1、使用dd命令读写数据。

[root@centos7-1605 ~]# dd  --help
用法:dd [操作数] ...
 或:dd 选项
Copy a file, converting and formatting according to the operands.

  bs=BYTES        read and write up to BYTES bytes at a time
  cbs=BYTES       convert BYTES bytes at a time
  conv=CONVS      convert the file as per the comma separated symbol list
  count=N         copy only N input blocks
  ibs=BYTES       read up to BYTES bytes at a time (default: 512)
  if=FILE         read from FILE instead of stdin
  iflag=FLAGS     read as per the comma separated symbol list
  obs=BYTES       write BYTES bytes at a time (default: 512)
  of=FILE         write to FILE instead of stdout
  oflag=FLAGS     write as per the comma separated symbol list
  seek=N          skip N obs-sized blocks at start of output
  skip=N          skip N ibs-sized blocks at start of input
  status=LEVEL    The LEVEL of information to print to stderr;
                  'none' suppresses everything but error messages,
                  'noxfer' suppresses the final transfer statistics,
                  'progress' shows periodic transfer statistics

N and BYTES may be followed by the following multiplicative suffixes:
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Each CONV symbol may be:

  ascii     from EBCDIC to ASCII
  ebcdic    from ASCII to EBCDIC
  ibm       from ASCII to alternate EBCDIC
  block     pad newline-terminated records with spaces to cbs-size
  unblock   replace trailing spaces in cbs-size records with newline
  lcase     change upper case to lower case
  ucase     change lower case to upper case
  sparse    try to seek rather than write the output for NUL input blocks
  swab      swap every pair of input bytes
  sync      pad every input block with NULs to ibs-size; when used
            with block or unblock, pad with spaces rather than NULs
  excl          fail if the output file already exists
  nocreat       do not create the output file
  notrunc       不截断输出文件
  noerror       读取数据发生错误后仍然继续
  fdatasync     结束前将输出文件数据写入磁盘
  fsync 类似上面,但是元数据也一同写入

FLAG 符号可以是:

  append        追加模式(仅对输出有意义;隐含了conv=notrunc)
  direct        使用直接I/O 存取模式
  directory     除非是目录,否则 directory 失败
  dsync         使用同步I/O 存取模式
  sync          与上者类似,但同时也对元数据生效
  fullblock     为输入积累完整块(仅iflag)
  nonblock      使用无阻塞I/O 存取模式
  noatime       不更新存取时间
  nocache       丢弃缓存数据
  noctty        不根据文件指派控制终端
  nofollow      不跟随链接文件
  count_bytes  treat 'count=N' as a byte count (iflag only)
  skip_bytes  treat 'skip=N' as a byte count (iflag only)
  seek_bytes  treat 'seek=N' as a byte count (oflag only)

Sending a USR1 signal to a running 'dd' process makes it
print I/O statistics to standard error and then resume copying.

  $ dd if=/dev/zero of=/dev/null& pid=$!
  $ kill -USR1 $pid; sleep 1; kill $pid
  18335302+0 records in
  18335302+0 records out
  9387674624 bytes (9.4 GB) copied, 34.6279 seconds, 271 MB/s

示例一、
[root@centos7-1605 ~]# dd  if=/dev/zero  of=testfile  bs=20M  count=100 conv=fdatasync
记录了100+0 的读入
记录了100+0 的写出
2097152000字节(2.1 GB)已复制,19.7587 秒,106 MB/秒
注意:多次测试最后求平均值,最好每次测试前将系统缓存删除一下
echo  3> /proc/sys/vm/drop_caches

2、磁盘测试命令hdparm

1、 -t参数可以测试硬盘读写速率
[root@centos7-1605 ~]# hdparm  -t   /dev/sda2 

/dev/sda2:
 Timing buffered disk reads: 318 MB in  3.01 seconds = 105.61 MB/sec
[root@centos7-1605 ~]# 

 2、-T 参数可以测试内存缓存的速率
[root@centos7-1605 ~]# hdparm  -T  /dev/sda2

/dev/sda2:
 Timing cached reads:   12322 MB in  2.00 seconds = 6167.64 MB/sec

 不仅要测试

dmesg |grep sata 可以查看看sata硬盘的运行级别

3、测试软件bonnie++

 在默认的yum源中是没有bonnie++软件的,我们需要在额外添加一个叫RepoForge的yum源,其官网地址为http://repoforge.org/,

技术分享图片

安装CentOS7 yum源:

rpm -ivh  http://repository.it4i.cz/mirrors/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
yum install  -y bonnie++ #安装测试软件
测试
bonnie++ -u  root  #制定一个用户即可使用默认参数测试
 默认会生成8G大小的文件,会分成8份会通过写操作 读操作、随机操作等操作测试
 [root@centos7-1605 ~]# bonnie++   -u  root
Using uid:0, gid:0.
Writing a byte at a time...done
Writing intelligently...done
Rewriting...done
Reading a byte at a time...done
Reading intelligently...done
start 'em...done...done...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version  1.97       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
centos7-1605. 7576M   709  99 101811   8 59275   6  2671  99 118595   5  6809 155
Latency             17472us   46186us    2002ms   10232us    1038ms    7091us
Version  1.97       ------Sequential Create------ --------Random Create--------
centos7-1605.local  -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
Latency              1187us     111us     755us    1436us      29us   52394us
1.97,1.97,centos7-1605.local,1,1527113410,7576M,,709,99,101811,8,59275,6,2671,99,118595,5,6809,155,16,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,17472us,46186us,2002ms,10232us,1038ms,7091us,1187us,111us,755us,1436us,29us,52394us
主要有Sequential Output(顺序输出 写操作) Sequential Input(循序输入 读操作) Random Seeks(随机寻道)Sequential Create(顺序创建)
Random Create(随机创建)等部分
Per Chr 字符形式
Block  块形式
Rewrite  重写
%CP CPU的使用率
++号可能是值太小被忽略

4、 iozone测试硬盘状态

    可以通过 write, re-write, read, re-read, random read, random write, random mix, backwards read, record rewirte, strided read, fwrite, frewrite, fread, freread, mmap, async I/0 等不同的模式下的硬盘的性能。
测试的时候请注意,设置的测试文件的大小一定要大过你的内存(最佳为内存的两倍大小),不然linux会给你的读写的内容进行缓存,会使数值非常不准确。

yum install -y  iozone
测试实例
iozone  -l 1 -u 1  -r  16K  -s 128M  -F /tmp/tmpfile
-l 最小线程 
-r 最大线程
-r  读写的块
-s 制定文件 
-F 临时文件
[root@centos7-1605 var]# iozone  -l 1 -u 1  -r  16K  -s 128M  -F /tmp/tmpfile
        Iozone: Performance Test of File I/O
                Version $Revision: 3.424 $
                Compiled for 64 bit mode.
                Build: linux-AMD64 

        Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
                     Al Slater, Scott Rhine, Mike Wisner, Ken Goss
                     Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
                     Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
                     Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
                     Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
                     Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
                     Vangel Bojaxhi, Ben England, Vikentsi Lapa.

        Run began: Wed May 23 23:22:38 2018

        Record Size 16 kB
        File size set to 131072 kB
        Command line used: iozone -l 1 -u 1 -r 16K -s 128M -F /tmp/tmpfile
        Output is in kBytes/sec
        Time Resolution = 0.000001 seconds.
        Processor cache size set to 1024 kBytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
        Min process = 1 
        Max process = 1 
        Throughput test with 1 process
        Each process writes a 131072 kByte file in 16 kByte records

        Children see throughput for  1 initial writers  = 1301841.75 kB/sec
        Parent sees throughput for  1 initial writers   =  104271.16 kB/sec
        Min throughput per process                      = 1301841.75 kB/sec 
        Max throughput per process                      = 1301841.75 kB/sec
        Avg throughput per process                      = 1301841.75 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 rewriters        = 3018765.25 kB/sec
        Parent sees throughput for  1 rewriters         =  105599.76 kB/sec
        Min throughput per process                      = 3018765.25 kB/sec 
        Max throughput per process                      = 3018765.25 kB/sec
        Avg throughput per process                      = 3018765.25 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 readers          = 5413710.50 kB/sec
        Parent sees throughput for  1 readers           = 5205784.06 kB/sec
        Min throughput per process                      = 5413710.50 kB/sec 
        Max throughput per process                      = 5413710.50 kB/sec
        Avg throughput per process                      = 5413710.50 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 re-readers        = 5649890.00 kB/sec
        Parent sees throughput for 1 re-readers         = 5533982.50 kB/sec
        Min throughput per process                      = 5649890.00 kB/sec 
        Max throughput per process                      = 5649890.00 kB/sec
        Avg throughput per process                      = 5649890.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 reverse readers   = 5126607.00 kB/sec
        Parent sees throughput for 1 reverse readers    = 5018455.90 kB/sec
        Min throughput per process                      = 5126607.00 kB/sec 
        Max throughput per process                      = 5126607.00 kB/sec
        Avg throughput per process                      = 5126607.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 stride readers    = 5201499.00 kB/sec
        Parent sees throughput for 1 stride readers     = 5104425.23 kB/sec
        Min throughput per process                      = 5201499.00 kB/sec 
        Max throughput per process                      = 5201499.00 kB/sec
        Avg throughput per process                      = 5201499.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 random readers    = 5115397.00 kB/sec
        Parent sees throughput for 1 random readers     = 5009629.92 kB/sec
        Min throughput per process                      = 5115397.00 kB/sec 
        Max throughput per process                      = 5115397.00 kB/sec
        Avg throughput per process                      = 5115397.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 mixed workload    = 5025566.50 kB/sec
        Parent sees throughput for 1 mixed workload     = 4931217.40 kB/sec
        Min throughput per process                      = 5025566.50 kB/sec 
        Max throughput per process                      = 5025566.50 kB/sec
        Avg throughput per process                      = 5025566.50 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 random writers    = 3322413.50 kB/sec
        Parent sees throughput for 1 random writers     =  111279.78 kB/sec
        Min throughput per process                      = 3322413.50 kB/sec 
        Max throughput per process                      = 3322413.50 kB/sec
        Avg throughput per process                      = 3322413.50 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 pwrite writers    = 1825668.12 kB/sec
        Parent sees throughput for 1 pwrite writers     =  102905.21 kB/sec
        Min throughput per process                      = 1825668.12 kB/sec 
        Max throughput per process                      = 1825668.12 kB/sec
        Avg throughput per process                      = 1825668.12 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for 1 pread readers     = 4462963.00 kB/sec
        Parent sees throughput for 1 pread readers      = 4265415.77 kB/sec
        Min throughput per process                      = 4462963.00 kB/sec 
        Max throughput per process                      = 4462963.00 kB/sec
        Avg throughput per process                      = 4462963.00 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 fwriters         = 3229643.75 kB/sec
        Parent sees throughput for  1 fwriters          =  110374.10 kB/sec
        Min throughput per process                      = 3229643.75 kB/sec 
        Max throughput per process                      = 3229643.75 kB/sec
        Avg throughput per process                      = 3229643.75 kB/sec
        Min xfer                                        =  131072.00 kB

        Children see throughput for  1 freaders         = 4342435.50 kB/sec
        Parent sees throughput for  1 freaders          = 4267932.42 kB/sec
        Min throughput per process                      = 4342435.50 kB/sec 
        Max throughput per process                      = 4342435.50 kB/sec
        Avg throughput per process                      = 4342435.50 kB/sec
        Min xfer                                        =  131072.00 kB



iozone test complete.

最简单开始使用iozone方法是自动模式

1 #/opt/iozone/bin/iozone -a

iozone将在所有模式下进行测试,使用记录块从4k到16M,测试文件大小从64k到512M。

如果想以图表形式显示测试结果,可以使用,iozone将测试结果放在Excel中

1 #/opt/iozone/bin/iozone -Ra 或 #/opt/iozone/bin/iozone -Rab output.xls

如果内存大于512MB,则测试文件需要更大;最好测试文件是内存的两倍。例如内存为1G,将测试文件设置最大为2G

#/opt/iozone/bin/iozone -Ra -g 2g

如果我们只关心文件磁盘的read/write性能,而不必花费时间在其他模式上测试,则我们需要指定测试模式。具体将在参数解释中介绍

1 #/opt/iozone/bin/iozone -Ra -g 2g -i 0 -i 1

最后,如果我们测试的NFS,将使用-c,这通知iozone在测试过程中执行close()函数。使用close()将减少NFS客户端缓存的影响。但是如果测试文件比内存大,就没有必要使用参数-c

1 #/opt/iozone/bin/iozone -Rac

 

测试的定义
Write: 测试向一个新文件写入的性能。当一个新文件被写入时,不仅仅是那些文件中的数据需要被存储,还包括那些用于定位数据存储在存储介质的具体位置的额外信息。这些额外信息被称作“元数据”。它包括目录信息,所分配的空间和一些与该文件有关但又并非该文件所含数据的其他数据。拜这些额外信息所赐,Write的性能通常会比Re-write的性能低。
Re-write: 测试向一个已存在的文件写入的性能。当一个已存在的文件被写入时,所需工作量较少,因为此时元数据已经存在。Re-write的性能通常比Write的性能高。
Read: 测试读一个已存在的文件的性能。
Re-Read: 测试读一个最近读过的文件的性能。Re-Read性能会高些,因为操作系统通常会缓存最近读过的文件数据。这个缓存可以被用于读以提高性能。
Random Read: 测试读一个文件中的随机偏移量的性能。许多因素可能影响这种情况下的系统性能,例如:操作系统缓存的大小,磁盘数量,寻道延迟和其他。
Random Write: 测试写一个文件中的随机偏移量的性能。同样,许多因素可能影响这种情况下的系统性能,例如:操作系统缓存的大小,磁盘数量,寻道延迟和其他。
Random Mix: 测试读写一个文件中的随机偏移量的性能。同样,许多因素可能影响这种情况下的系统性能,例如:操作系统缓存的大小,磁盘数量,寻道延迟和其他。这个测试只有在吞吐量测试模式下才能进行。每个线程/进程运行读或写测试。这种分布式读/写测试是基于round robin 模式的。最好使用多于一个线程/进程执行此测试。
Backwards Read: 测试使用倒序读一个文件的性能。这种读文件方法可能看起来很可笑,事实上,有些应用确实这么干。MSC Nastran是一个使用倒序读文件的应用程序的一个例子。它所读的文件都十分大(大小从G级别到T级别)。尽管许多操作系统使用一些特殊实现来优化顺序读文件的速度,很少有操作系统注意到并增强倒序读文件的性能。
Record Rewrite: 测试写与覆盖写一个文件中的特定块的性能。这个块可能会发生一些很有趣的事。如果这个块足够小(比CPU数据缓存小),测出来的性能将会非常高。如果比CPU数据缓存大而比TLB小,测出来的是另一个阶段的性能。如果比此二者都大,但比操作系统缓存小,得到的性能又是一个阶段。若大到超过操作系统缓存,又是另一番结果。
Strided Read: 测试跳跃读一个文件的性能。举例如下:在0偏移量处读4Kbytes,然后间隔200Kbytes,读4Kbytes,再间隔200Kbytes,如此反复。此时的模式是读4Kbytes,间隔200Kbytes并重复这个模式。这又是一个典型的应用行为,文件中使用了数据结构并且访问这个数据结构的特定区域的应用程序常常这样做。
  许多操作系统并没注意到这种行为或者针对这种类型的访问做一些优化。同样,这种访问行为也可能导致一些有趣的性能异常。一个例子是在一个数据片化的文件系统里,应用程序的跳跃导致某一个特定的磁盘成为性能瓶颈。
Fwrite: 测试调用库函数fwrite()来写文件的性能。这是一个执行缓存与阻塞写操作的库例程。缓存在用户空间之内。如果一个应用程序想要写很小的传输块,fwrite()函数中的缓存与阻塞I/O功能能通过减少实际操作系统调用并在操作系统调用时增加传输块的大小来增强应用程序的性能。
  这个测试是写一个新文件,所以元数据的写入也是要的。
Frewrite:测试调用库函数fwrite()来写文件的性能。这是一个执行缓存与阻塞写操作的库例程。缓存在用户空间之内。如果一个应用程序想要写很小的传输块,fwrite()函数中的缓存与阻塞I/O功能能通过减少实际操作系统调用并在操作系统调用时增加传输块的大小来增强应用程序的性能。
  这个测试是写入一个已存在的文件,由于无元数据操作,测试的性能会高些。
Fread:测试调用库函数fread()来读文件的性能。这是一个执行缓存与阻塞读操作的库例程。缓存在用户空间之内。如果一个应用程序想要读很小的传输块,fwrite()函数中的缓存与阻塞I/O功能能通过减少实际操作系统调用并在操作系统调用时增加传输块的大小来增强应用程序的性能。
Freread: 这个测试与上面的fread 类似,除了在这个测试中被读文件是最近才刚被读过。这将导致更高的性能,因为操作系统缓存了文件数据。
  几个特殊测试:
  Mmap:许多操作系统支持mmap()的使用来映射一个文件到用户地址空间。映射之后,对内存的读写将同步到文件中去。这对一些希望将文件当作内存块来使用的应用程序来说很方便。一个例子是内存中的一块将同时作为一个文件保存在于文件系统中。
  mmap 文件的语义和普通文件略有不同。如果发生了对内存的存储,并不是立即发生相应的文件I/O操作。使用MS_SYNC 和MS_ASYNC标志位的 msyc()函数调用将控制内存和文件的一致性。调用msync() 时将MS_SYNC置位将强制把内存里的内容写到文件中去并等待直到此操作完成才返回。而MS_ASYNC 置位则告诉操作系统使用异步机制将内存刷新到磁盘,这样应用程序可以直接返回而不用等待此操作的完成。
  这个测试就是测量使用mmap()机制完成I/O的性能。
  Async I/O: 许多操作系统支持的另外一种I/O机制是POSIX 标准的异步I/O。本程序使用POSIX标准异步I/O接口来完成此测试功能。
  例如: aio_write(), aio_read(), aio_error()。这个测试测量POSIX异步I/O机制的性能。

 

参数介绍

iozone功能很强大,当然参数也很多,但是我们常用的就那几个参数
Usage: iozone [-s filesize_Kb] [-r record_size_Kb ] [-f [path]filename]
  [-i test] [-E] [-p] [-a] [-A] [-z] [-Z] [-m] [-M] [-t children] [-h] [-o]
  [-l min_number_procs] [-u max_number_procs] [-v] [-R] [-x]
  [-d microseconds] [-F path1 path2...] [-V pattern] [-j stride]
  [-T] [-C] [-B] [-D] [-G] [-I] [-H depth] [-k depth] [-U mount_point]
  [-S cache_size] [-O] [-K] [-L line_size] [-g max_filesize_Kb]
  [-n min_filesize_Kb] [-N] [-Q] [-P start_cpu] [-c] [-e] [-b filename]
  [-J milliseconds] [-X filename] [-Y filename] [-w] [-W]
  [-y min_recordsize_Kb] [-q max_recordsize_Kb] [-+m filename]
  [-+u ] [ -+d ] [-+p percent_read] [-+r] [-+t ] [-+A #]


-a
全自动模式测试。测试记录块大小从4k到16M,测试文件从64k到512M

-A
使用自动模式虽然测试比较全面,但是比较花时间。-a选项将在文件大于32MB时停止使用低于64k一下记录块,来节省时间。-A通知iozone不要节省时间,进行所有测试。注:在3.61版本以后不建议使用,用-az代替-aA

-B
使用mmap()。这将使用mmap()接口来创建并访问所有测试用的临时文件。一些应用程序倾向于将文件当作内存的一块来看待。这些应用程序对文件执行mmap()调用,然后就可以以读写内存的方式访问那个块来完成文件I/O。

-c
计算时间将close()包括进来

-C
显示吞吐量测试中每个客户端的字节数。

-D
对mmap文件使用MSYNC(MS_ASYNC)。告诉操作系统在mmap空间的所有数据需要被异步的写到磁盘上。

-e
测试时间是包含flush(fsync, fflush)

-f filename
指定用来测试临时文件,在测试完成后将被自动删除

-F filename filename ...
指定测试中每个临时文件名,文件名的数量应该和指定的进程或线程数相同

-g #
在自动模式下设置文件最大值,可以使用#k #m #g分别表示kb,mb,gb

-G
对mmap文件使用msync(MS_SYNC)。告诉操作系统在mmap空间的所有数据需要被同步的写到磁盘上

-h
显示帮助

-i #
指定运行于哪种模式测试。可以使用-i # -i # -i #进行多个测试
0=write/rewrite
1=read/re-read
2=random read/random write
3=backwards read
4=re-write-record
5=stride-read
6=fwirte/re-fwrite
7=fread/re-fread
8=random mix
9=pwrite/re-pwrite
10=pread/re-pread
11=pwritev/re-pwritev
12=preadv/re-preadv

-I
对所有文件操作使用DIRECT I/O。通知文件系统所有操作跳过缓存直接在磁盘上操作

-j #
设置访问文件的跨度为(# * 块)。stride read测试将使用这个跨度来读块

-J #(毫秒)
在每个I/O操作之前产生指定毫秒的计算延迟。看-X和-Y获取控制计算延迟的其他参数

-l #
设置程序最小进程数。在测试过程允许用户设置的最小进程或线程数。需要配合-u选项使用。

-L #
设置处理器交换信息的单位量为#(bytes)。可以加速测试。

-m
iozone将在内部使用多个缓存。一些程序反复复写一块缓存,还有就是设置多个缓存块。此参数将允许使用这两种模式。iozone默认行为是重复使用内部一个缓存。此选项将允许在内部使用多个缓存块。

-M
调用uname(),将返回字符串放在输出文件中

-n #
设置自动模式下测试文件的最小值

-N
报告结果以毫秒每操作的方式显示

-o
写方式是同步写到磁盘上

-O
报告结果以操作每秒方式显示

-q #
在自动模式下设置记录块的最大值,可以使用#k(kb),#m(mb),#g(gb)。使用-y可以设置最小值

-r #
设置记录块大小为#

-R
使用Excel显示结果

-s #
设置测试文件大小

-S #
设置处理器的缓存大小

-t #
设置测试程序的线程或进程数

-T 
使用POSIX的pthreads进行测试

-u #
设置最大进程或线程数,需要配合-l参数使用

-U mountpoint
在测试开始之前,iozone将unmount和remount挂载点。这将保证测试中缓存不包含任何文件

-w
在测试结束后不要删除临时文件。临时文件将在测试过后保存下来

-W
在测试过程中,当读或写文件时锁住文件

-y #
设置记录块最小值

-z
同-a一起使用,进行全部测试

-Z
允许mmap I/O和file I/O混合使用

 

下面做个在我机器上做的测试:只进行read/write测试,测试文件大小是4G,记录块从2k到8m,并将测试数据输出到Excel文件中

技术分享图片

#先在/tmp目录下创建一个文件

[root@comput3 mnt]# cd /tmp/
[root@comput3 tmp]# touch testfile
[root@comput3 tmp]# ll
total 0
-rw-r--r-- 1 root root 0 Jun 22 13:22 testfile

#再执行测试命令(生成的文件大小,别给太大,会卡死。我们指定4G)

[root@comput3 mnt]# /opt/iozone/bin/iozone -a -s 4g -i 0 -i 1 -f /tmp/testfile -y 2k -q 8m -Rb output.xls
Iozone: Performance Test of File I/O
Version $Revision: 3.465 $
Compiled for 32 bit mode.
Build: linux

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
Al Slater, Scott Rhine, Mike Wisner, Ken Goss
Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
Vangel Bojaxhi, Ben England, Vikentsi Lapa,
Alexey Skidanov.

Run began: Thu Jun 22 13:22:56 2017

Auto Mode
File size set to 4194304 kB
Using Minimum Record Size 2 kB
Using Maximum Record Size 8192 kB
Excel chart generation enabled
Command line used: /opt/iozone/bin/iozone -a -s 4g -i 0 -i 1 -f /tmp/testfile -y 2k -q 8m -Rb output.xls
Output is in kBytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 1024 kBytes.
Processor cache line size set to 32 bytes.
File stride size set to 17 * record size.
random random bkwd record stride 
kB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
4194304 2 1490669 2380831 3607767 3608702 
4194304 4 2055341 3253580 5060700 5085952 
4194304 8 2437956 3670713 5750648 5794959 
4194304 16 2529686 3698703 5750735 5778162 
4194304 32 2599803 3766791 5698635 5736475 
4194304 64 2660804 3828547 5624593 5665942 
4194304 128 2680742 3910113 5381341 5393153 
4194304 256 2515596 3830578 4935002 4965230 
4194304 512 2528649 3832630 4915910 4947781 
4194304 1024 2701632 3890505 4944666 4976889 
4194304 2048 2722534 3941544 4931400 4963038 
4194304 4096 2674452 3848342 4815188 4841886 
4194304 8192 2305839 3121477 3571541 3581370

iozone test complete.
Excel output is below:

"Writer report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 1490669 2055341 2437956 2529686 2599803 2660804 2680742 2515596 2528649 2701632 2722534 2674452 2305839

"Re-writer report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 2380831 3253580 3670713 3698703 3766791 3828547 3910113 3830578 3832630 3890505 3941544 3848342 3121477

"Reader report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 3607767 5060700 5750648 5750735 5698635 5624593 5381341 4935002 4915910 4944666 4931400 4815188 3571541

"Re-Reader report"
"2" "4" "8" "16" "32" "64" "128" "256" "512" "1024" "2048" "4096" "8192"
"4194304" 3608702 5085952 5794959 5778162 5736475 5665942 5393153 4965230 4947781 4976889 4963038 4841886 3581370

 

[root@comput3 mnt]# pwd
/mnt

[root@comput3 mnt]# ll
total 4
-rw-r--r-- 1 root root 3940 Jun 22 13:24 output.xls

技术分享图片

最后数据就是测试结果,左边第一列是测试文件大小,第二列是记录块大小(单位是kb),以后每列就是测试模式(单位是kb/s)


Linux下硬盘性能测试

标签:iozone   dd   

原文地址:http://blog.51cto.com/dreamlinux/2119659

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!