记就自己接触到的测试工具,主要有以下几种:
iozone,iometer,bonnie++
iozone
主页地址:
http://www.iozone.org

通过如下操作测试文件IO性能:read, write, re-read, re-write, read backwards, read strided, fread,fwrite, random read, pread, mmap, aio_read, aio_write.
iozone具有如下特性:
ANSII C source
POSIX async I/O
Mmap() file I/O
Normal file I/O
Single stream measurement
Multiple stream measurement
Distributed fileserver measurements (Cluster) //这个特性很实用
POSIX pthreads
Multi-process measurement
Excel importable output for graph generation //一个有用的特性
Latency plots
64bit compatible source
Large file compatible
Stonewalling in throughput tests to eliminate straggler effects
Processor cache size configurable
Selectable measurements with fsync, O_SYNC //bonnie++最近版本已经加入fsync这一阻塞机制了,保证测试结果的真实性(有没有同步并刷新到磁盘文件中,性能差别很大)
Builds for: AIX, BSDI, HP-UX, IRIX, FreeBSD, Linux, OpenBSD, NetBSD, OSFV3, OSFV4, OSFV5, SCO OpenServer, Solaris, Windows95/98/NT //支持的平台真是多。

安装及测试过程如下:
解压:tar xvf iozone3_283.tar
进入src/current目录;
敲入 make linux; //linux表示目标平台;
编译生成目标文件iozone

进行测试:比如 iozone -a;//所有参数都是缺省的,并完成所有的文件操作;
iozone -s15m -i0 -i1 -t50:其含义如下:-s15m(文件的大小为15MB);-i0(写/重写操作);-i1(读/重读操作);
-t50(工作在throughput模式,并且线程数为50)
当然还有-u 就是工作在CPU利用率模式了,具体细节参考IOzone_msword_98.pdf。

Iometer是一个测试简单系统和集群系统下的IO子系统性能的工具;其中dynamometer起到引擎的作用(也就是负载生成器),iometer经常被当作测量工具,其实它也是一个负载生成器workload generator,通过配置可以将iometer仿真为任意程序或benchmark下的磁盘IO负载或网络IO负载,或用于生成合成IO负载。
IOmeter用于以下几个方面:
1、Performance of disk and network controllers.//磁盘和网络控制器的性能;
2、Bandwidth and latency capabilities of buses.//总线带宽和延迟;
3、Network throughput to attached drives. //到附联驱动器的网络带宽;
4、Shared bus performance. //共享的总线性能;
5、System-level hard drive performance. //系统级硬盘驱动器性能;
6、System-level network performance. //系统级网络性能;

测试时分两种情况:单机环境和网络环境;
在单机环境下,运行iometer.exe,它自动运行dynamo,在iometer控制界面里可设置测试参数;
在网络环境下,也有几种测试方式,最简单也是最常用的方式是采用网络映射方式将远程目录映射成本机的一个盘符,然后按照单机情况进行测试;
iometer的安装:在lustre(linux系统下)安装iometer,
tar zxvf iometer-2004.07.30.linux.i386-bin.tar.gz
在源目录下执行
make makefile_linux.i386
make makefile_linux.i386
在linux下运行: ./dynamo -i 客户端ip(windows) -m 服务器ip(linux)。

bonnie++胜在简单,不过准确性稍差
在编译过程中,如果遇到以下错误,可能是因为你没有设置正确的环境变量,设置环境变量后继续编译,一般可以成功
# export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
# ./configure
编译完成之后会生成bonnie++,可以用来测试了.

bonnie++[-d scratch-dir] 测试目录
[-s size(Mb)[:chunk-size(b)]]文件大小:块大小 默认大小:300M:8K
[-n number-to-stat[:max-size[:min-size][:num-directories]]]文件创建测试的文件数n*1024,最大文件大小,最小文件大小,目录数,max=-1:hard link,-2:soft link
[-m machine-name]机器名,仅用于显示
[-r ram-size-in-Mb]机器内存大小
[-x number-of-tests] test数量
[-u uid-to-use:gid-to-use] 测试所用的用户名:组名
[-g gid-to-use]
[-q]安静模式
[-f]快速模式,不进行单字符IO测试
[-b]不使用写缓存
[-p processes | -y] bonnie++进程数,使用信号量同步多个进程
[-y] 每个测试开始之前等待信号量

测试实例:
bonnie++ -s 40 -r 1 -n 0 -u 0 -f>>bonnietest (生成的文件名)
bonnie++ -m go –d /tmp –s 30:512 –n 1 –r 2 –x 2 –u 0>>test

结果处理:
测试时,将测试结果重定向到文件,得到的文件内容如上所示
结果可以直接导入excel(新建一个文件,然后是菜单中的数据->导入外部数据)。得到结果中会有+++++的内容
+++++的含义: 当所用时间小于1s的时候,结果不准确,所以不给出

结果项解析:
Sequential Output(顺序写入)
per charutc(),每次一个字符,顺序写入,完成整个文件
The CPU overhead here is that required to do the stdio code plus the OS file space allocation.
block:每次一个块,顺序写入,完成整个文件,
The CPU overhead should be just the OS file space allocation.
rewrite:每次读出一个块,修改其中一个字节,然后写回
this should test the effectiveness of the filesystem cache and the speed of data transfer.

Sequential Input(顺序读出)
per char:get(),每次一个字符,顺序读出,完成整个文件
This should exercise only stdio and sequential input.
block:每次一个块,顺序读出,完成整个文件
This should be a very pure test of sequential input performance.

Random Seeks(随机寻道):
3个seeks进程,8K个随机寻道操作,每次都是整块读出,%10得情况,修改一个字节,然后写回

Sequential Create (建立文件时,是真正将文件写入磁盘的)
create
read(stat) 顺序遍历所有文件:操作:读取文件属性,如果文件大小不为0,还要对文件内容进行读取,
delete 顺序删除所有文件

Random Create
create
read(stat) 按随机顺序遍历文件,文档中说这一步不会遍历所有文件,但是代码里边反应的情况好像不是这样
delete 按随机顺序删除所有文件

这里补充一点关于iometer的编译。iometer中有一种叫cross compile(交叉编译)交叉编译我还没有研究过。如果不用cross compile,就必须将makefile中的cross compile给注释掉。下面提供这种情况的详细编译步骤:
#cp Makefile-Linux24 Makefile
#make (或者make -f Makefile-Linux24)
#./dynamo -i (windows ip) -m (linux ip)

如果make的时候说库什么的不在,可以安装一个rpm包后再make
#rpm -i compat-libstdc++-7.3-2.96.118.i386.rpm
安装这个rpm包的时候如果有环境方面的错误,可以运行
#export LD_ASSUME_KERNEL=2.2.5
后再运行上面的rpm安装命令。
以上用到的iometer安装程序中:
windows下为:iometer-2004.07.30.win32.i386-setup.exe
linux下为:iometer-2004.07.30.linux.i386-bin.tar.gz