文件系统测试工具

本文介绍了如何使用pjdftest进行POSIX接口测试,以及vdbench这款磁盘I/O工作负载生成器进行文件系统性能评估,包括安装步骤、参数配置和测试案例,涵盖了单机和多主机联机测试,以及极限性能测试如小文件创建和读写的优化实践。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考链接:
https://blog.csdn.net/liuaigui/article/details/7240706

pjdftest

测试 posix 接口工具。

安装教程

git clone https://github.com/pjd/pjdfstest.git
cd pjdfstest/
autoreconf ifs
./configure
make pjdfstest

使用方法

  # cd /path/to/filesystem/under/test
  # prove -rv /path/to/pjdfstest/tests
  
  
[root@localhost cephfs]# prove -rv /root/pjdfstest/tests/mkdir/
All tests successful.
Files=13, Tests=118,  4 wallclock secs ( 0.04 usr  0.07 sys +  0.99 cusr  1.23 csys =  2.33 CPU)
Result: PASS

vdbench

参考链接:
https://www.e-learn.cn/topic/3737957
https://www.mayiwenku.com/p-3909056.html
https://www.oracle.com/downloads/server-storage/vdbench-downloads.html

Vdbench是一个磁盘I/O工作负载生成器,用于对存储产品进行测试。vdbench 使用 java 编写,支持全平台,需要运行在 java 虚拟机上。vdbench 除了支持常用的负载参数(读写比、块大小等)之外,还支持读写命中率这种特殊配置,能够测试 raw disk 和 文件系统。支持多主机同时运行负载程序,适合分布式文件系统测试。

安装教程

下载 vdbench

需要注册 Oracle 账户。注册成功后,如果登录提示用户名或密码错误,可以尝试修改密码后重新登录。此网站不需要使用 vpn。

https://www.oracle.com/downloads/server-storage/vdbench-downloads.html

下载的格式为 zip,使用解压命令 unzip

[root@localhost ~]# unzip vdbench50405.zip -d vdbench50405
Archive:  vdbench50405.zip
...
[root@localhost ~]# cd vdbench50405
[root@localhost vdbench50405]# ls
aix            example1  example4  example7  linux       solaris         vdbench      vdbench.pdf
build_sds.txt  example2  example5  examples  mac         solx86          vdbench.bat  windows
classes        example3  example6  hp        readme.txt  swatcharts.txt  vdbench.jar

安装 jdk

yum install java -y

# 完毕后,通过查看 java 版本号验证
java -version

运行测试用例,检查 vdbench 是否安装成功

[root@localhost vdbench50405]# ./vdbench -t
...
六月 28, 2021  interval        i/o   MB/sec   bytes   read     resp     read    write     resp     resp queue  cpu%  cpu%
                             rate  1024**2     i/o    pct     time     resp     resp      max   stddev depth sys+u   sys
10:37:31.034         1     101.00     0.10    1024  51.49    0.021    0.014    0.027    0.053    0.012   0.0   4.7   1.9
10:37:32.056         2     100.00     0.10    1024  51.00    0.022    0.019    0.026    0.083    0.013   0.0   1.5   0.5
10:37:33.052         3      99.00     0.10    1024  54.55    0.023    0.019    0.027    0.063    0.011   0.0   2.0   1.5
10:37:34.049         4      99.00     0.10    1024  49.49    0.026    0.020    0.032    0.090    0.012   0.0   1.5   1.0
10:37:35.053         5     100.00     0.10    1024  51.00    0.023    0.017    0.029    0.072    0.011   0.0   1.3   0.8
10:37:35.066   avg_2-5      99.80     0.10    1024  51.50    0.023    0.018    0.028    0.090    0.012   0.0   2.7   1.3
10:23:17.293 Vdbench execution completed successfully. Output directory: /root/vdbench50405/output 

使用教程

命令格式

./vdbench -f parmfile [parameter]

在 ../examples/directory 中有许多 parmfile 例子,可以查看学习。

可以在 parameter 中设置变量参数 lun: ./vdbench -f parmfile lun=/dev/x
paramfile 中可以使用 $param 来替换参数:sd=sd1,lun=$lun

Terminology 术语说明

  • Raw I/O Workload:通常设置(General)、主机设置(Host Definition,HD)、重放组(Replay Group,RG)、存储定义(Storage Definition,SD)、工作负载(Workload Definition,WD)、运行参数(Run Definition,RD)
  • File system Workload:通常设置(General)、主机设置(Host Definition,HD)、文件系统定义(File System Definition,FSD)、文件系统工作负载(File system Workload Definition,FWD)、运行参数(Run Definition,RD)

这些设置需要按顺序写在 parmfile,注意并非所有的设置都需要指明。

这里简单描述下 文件测试 工作流程:

  1. 根据 General、HD 完成初始设置
  2. 根据 FSD,构造一个符合设定文件树结构
  3. 根据 FWD 和 RD,运行负载测试

parmfile 参数介绍

仅介绍文件系统测试相关参数。

参数名定义描述
HD 参数介绍
hd=host_labellocalhost 表示在本机运行,其他标签表示远程主机,远程主机ip在 system 中设置
system=system_name远程主机时设置,表示IP地址或者域名
vdbench=/vdbench/dir/name远程主机时设置,表明远程主机中 vdbench 的安装位置
shell=rsh|ssh|vdbench使用何种远程协议,一般 ssh
user=xxxxx注意:只需要指定用户名,不需要密码。这说明需要实现配置远程免密登录。
mount=mount /xx /yy在执行测试前,运行此挂载命令。如果在多主机上测试,此命令可以避免手动在每个主机上挂载目录。
FSD
fsd=name标识一个文件系统测试,需要为唯一名称
fsd=default所有其它的文件测试都应用此命令后的参数设置,具体含义后文通过例子
anchor=/dir/工作目录
count=(nn,mm)例如:FSD=fsd1,anchor=/dir/file,count=(0,2),创建两个工作目录/dir/file0、/dir/file1
depth=nn目录深度,表示在工作目录下,有几层目录到达最终写入的文件
distribution=all | bottom默认bottom,只在最底层创建文件;all 表示 在每层目录都创建文件
files=n每层或者最底层目录创建多少文件
sizes=(nn,nn,…)文件大小,单位byte。
width=n每个新目录中创建 n 个子目录。
测试文件数量 = (width ^ depth)*files
journal=dir日志文件存储位置
shared=yes|no一般只有在多主机联机测试时指定,vdbench不允许不同的slave之间共享同一个目录结构下的所有文件,因为这样会带来很大的开销,但是它们允许共享同一个目录结构。加入设置了shared=yes,那么不同的slave可以平分一个目录下所有的文件来进行访问,相当于每个slave有各自等分的访问区域,因此不能测试多个客户的对同一个文件的读写。
默认为 no
当多主机联机测试时,写入的根目录anchor为同一个路径时,需要指定参数值为yes
FWD
fwd=uname文件负载设置唯一名称
fwd=default其他文件负载设置都使用 fwd=default 后的参数
fsd=(xx, yy, …)标识使用此 fwd 的 fsd
fileio=(random,sequential)随机或顺序 IO
host=host_label工作主机地址,填写 HD 设置中 hd 名称
operation=xxxmkdir、rmdir、create、delete、open、close、read、write、getattr、setattr
xfersizes=nn|(nn,xx…)读写大小。xfersizes=(8k,50,16k,30,2k,20)标识50%的8k,30%的16k,20%的2k。
threads=n线程数量
skew=n标识此fwd 在总的工作中的占比。默认是所有 fwd 平均分摊总工作量
rdpct=n读操作占比。仅有一条 fwd 时,默认 100
For operation=read and operation=write only
RD
rd=uname|default唯一标识名称
fwd=(xx,yy,…)标识此 rd 的 fwd 名称
format=yes/no/only/
restart/clean/once/
directories
yes:创建新目录前,删除旧目录和文件
no:标识不删除,相当于重写,默认为 no
restart:只创建不存在的目录或文件,表示不会重复写
only:The same as ‘yes’, but Vdbench will NOT execute the current RD
directories:The same as ‘yes’, but it will only create the directories.
clean:Vdbench will only delete the current file structure and NOT execute the current RD.
once:This overrides the default behavior that a format is done for each forxxx parameter loop done.
elapsed运行时间,单位秒,默认30秒
interval在读写 interval 总量的字节后停止运行,单位秒
fwdrate=(100,200,max,curve)每秒执行操作数。max 表示不做限制,能跑多少跑多少。

结果分析

09:35:14.000 Starting RD=rd1; elapsed=120; fwdrate=max. For loops: None

六月 29, 2021 .Interval. .ReqstdOps... ...cpu%...  read ....read..... ....write.... ..mb/sec... mb/sec .xfer.. ...mkdir.... ...rmdir.... ...create... ....open.... ...close.... ...delete...
                          rate   resp total  sys   pct   rate   resp   rate   resp  read write  total    size  rate   resp  rate   resp  rate   resp  rate   resp  rate   resp  rate   resp
09:35:15.021          1 380005  0.001  37.8 18.6 100.0 380005  0.001    0.0  0.000  1484  0.00 1484.6    4096   0.0  0.000   0.0  0.000   0.0  0.000  3805  0.028  3797  0.004   0.0  0.000
09:35:16.076          2 1220731  0.001  84.3 60.9 100.0 1220731  0.001    0.0  0.000  4768  0.00 4768.4    4095   0.0  0.000   0.0  0.000   0.0  0.000 12208  0.017 12207  0.003   0.0  0.000
09:35:17.049          3 1179613  0.001  83.7 69.1 100.0 1179613  0.001    0.0  0.000  4607  0.00 4607.8    4096   0.0  0.000   0.0  0.000   0.0  0.000 11794  0.022 11797  0.002   0.0  0.000
09:35:18.052          4 1357032  0.001  85.0 71.5 100.0 1357032  0.001    0.0  0.000  5300  0.00 5300.8    4095   0.0  0.000   0.0  0.000   0.0  0.000 13572  0.013 13571  0.004   0.0  0.000
参数名称功能说明
interval每次读取结果的间隔序号,间隔时间在 RD 的 interval 中设置
ReqstdOpsIOPS:单位时间内总的操作数
cpu% totalCPU 总使用率(系统本身 + 用户占用)
cpu% sysCPU 系统使用率(负载程序使用 CPU 率 = cpu% total - cpu% sys)
read/write/读写量总览
rate单位间隔内的请求数量
resp单位间隔内平均响应时间
mb/sec吞吐量:每秒读、写数据
xfer每次读写操作的平均大小,一般在 FWD 中 xfersizes 设置

vdbench 自带数据总结,保存在 ./output 文件夹中,可以使用 命令行浏览器 访问。

# 安装 w3m
[root@localhost vdbench50405]# yum install w3m

# 查看结果报告
[root@localhost vdbench50405]# w3m ./output/summary.html 

# histogram 中以柱形图的形式记录了延时分布
# summary 是报告总结
# w3m操作:
# hjkl:左上下右移动光标
# 回车:跳转链接
# B:返回
# Q:退出

测试用例

单机

可根据示例自行更改。

* 构建文件树结构
* 文件总数 = (width ^ depth) * files
* anchor:目标根目录
* depth:目录树深度
* width:目录树宽度
* files:每个叶子目录里创建多少个文件
* size:每个文件大小
fsd=fsd1,anchor=/mnt/cephfs,depth=2,width=100,files=20,size=4k

* 构建负载任务
* xfersize:块大小
* threads:线程数
* fileio:文件读写方式,random 或者 sequential
* fileselect:选择读写文件的方式,随机选文件或顺序选择。random 或者 sequential
* operation:write 或者 read
fwd=fwd1,xfersize=4k,threads=16,fileio=sequential,fileselect=sequential,operation=write

* 运行参数
* fwdrate:全速读写
* format:构造目录文件的参数,restart表示已有的文件不会删除后重新创建
* elapsed:最大运行时间,秒
* interval:结果打印间隔时间,秒
rd=rd1,fwd=fwd1,fwdrate=max,format=restart,elapsed=3000,interval=1

联机

首先每台机器都要安装vdbench。其次需要配置SSH免密登录:

# 改写 client 主机们的名称,方便操作
hostnamectl set-hostname {clientname}

# 在每个 client 上记录自己和其他主机的 clientname
vi /etc/hosts
192.168.159.101 client1
192.168.159.102 client2
192.168.159.103 client3

# 在 vdbench 运行的主 client 上操作,生成 ssh 公钥并发送给其他 client
[root@client1 ~]# ssh-keygen
[root@client1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub client2
[root@client1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub client3

# 验证
ssh client2

parmfile 可根据示例自行更改。

* vdbench 的安装位置最好一致,不一样的需要在指定client的hd中配置vdbench
* 
hd=default,vdbench=/root/vdbench50405,user=root,shell=ssh
hd=hd1,system=client1
hd=hd2,system=client2
hd=hd3,system=client3

* 构建文件树结构
* 文件总数 = (width ^ depth) * files
* anchor:目标根目录
* depth:目录树深度
* width:目录树宽度
* files:每个叶子目录里创建多少个文件
* size:每个文件大小
* shared:yes 表示所有 client 都使用同一个 anchor
fsd=fsd1,anchor=/mnt/cephfs,depth=2,width=100,files=20,size=4k,shared=yes

* 构建负载任务
* xfersize:块大小
* threads:线程数
* fileio:文件读写方式,random 或者 sequential
* fileselect:选择读写文件的方式,随机选文件或顺序选择。random 或者 sequential
* operation:write 或者 read
* host:此 fwd 针对哪个 client
fwd=default,xfersize=4k,fileio=sequential,fileselect=sequential,operation=write,threads=24
fwd=fwd1,fsd=fsd1,host=hd1
fwd=fwd3,fsd=fsd1,host=hd2
fwd=fwd3,fsd=fsd1,host=hd3

* 运行参数
* fwdrate:全速读写
* format:构造目录文件的参数,restart表示已有的文件不会删除后重新创建
* elapsed:最大运行时间,秒
* interval:结果打印间隔时间,秒
rd=rd1,fwd=fwd*,fdwrate=max,format=restart,elapsed=600,interval=1

极限性能测试

小文件创建测试

目的:单节点压测文件系统创建小文件的极限性能。

测试创建不同大小文件的性能,通过调整线程数,探究最优线程数。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-V6XYrGMM-1634779144161)(C:\Users\wq\AppData\Roaming\Typora\typora-user-images\image-20210927142226336.png)]

1、单进程+多线程

# 文件数目:10w
# 文件大小:4K
# xfersize:4K
# 线程数:(1,4,8,16,24,32)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=100000,size=4k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=8
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# 文件数目:10w
# 文件大小:128K
# xfersize:4K
# 线程数:(1,4,8,16,24,32)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=100000,size=128k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=8
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# 文件数目:5w
# 文件大小:512K
# xfersize:4K
# 线程数:(1,4,8,16,24,32)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=50000,size=512k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=8
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# 文件数目:2w
# 文件大小:4M
# xfersize:4K
# 线程数:(1,4,8,16,24,32)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=20000,size=4M
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=8
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# 文件数目:1w
# 文件大小:16M
# xfersize:4K
# 线程数:(1,4,8,16,24,32)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=10000,size=16M
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=8
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# 记录顺序新写文件的性能
# 记录参数:吞吐率、IOPS、create延时、open延时、write延时、close延时

2、多进程+多线程

采用nohup+后台运行进程的方式,同时执行多个vdbench。结果保存在当前目录的nohup.out文件中。

# 这是同时运行两个vdbench进程的命令。
# 指定nohup输出文件为 out1 、out2
nohup ../vdbench50405/vdbench -f 4kb-write2 > out1 & nohup ../vdbench50405/vdbench -f 4kb-write > out2 &

注意:需要保证每个vdbench执行的脚本中的工作目录不为同一个。可以设置相同的父目录。

在测试之前,创建n(进程数)个vdbench脚本文件;每个脚本文件对应一个vdbench进程。脚本文件中除了工作目录(anchor)不同,其他内容都相同。

后台执行完毕后,查看每个nohup的输出文件,记录下每个进程中的性能测试结果(吞吐率、IOPS、create延时、open延时、write延时、close延时)。汇总结果中,吞吐率和IOPS为多个进程输出之和,延时为多个进程输出平均值。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2CbFN6i7-1634779144163)(C:\Users\wq\AppData\Roaming\Typora\typora-user-images\image-20210927151635234.png)]

# vdbench进程数:2
# 工作目录:/dir1,/dir2
# 文件数目:10w * 2
# 文件大小:4K
# xfersize:4K
# 线程数:(1,4,8,16,24)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=100000,size=4k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=8
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:4
# 工作目录:/dir1,/dir2,/dir3,/dir4
# 文件数目:5w * 4
# 文件大小:4K
# xfersize:4K
# 线程数:(1,4,8,16,24)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=50000,size=4k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=8
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:6
# 工作目录:/dir1,/dir2,/dir3,/dir4,/dir5,/dir6
# 文件数目:5w * 6
# 文件大小:4K
# xfersize:4K
# 线程数:(2,4)
# 测试不同线程下,最优性能
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=50000,size=4k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=2
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:4
# 工作目录:/dir1,/dir2,/dir3,/dir4
# 文件数目:2w * 4
# 文件大小:128K
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=20000,size=128k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:6
# 工作目录:/dir1,/dir2,/dir3,/dir4,/dir5,/dir6
# 文件数目:2w * 6
# 文件大小:128K
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=20000,size=128k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:4
# 工作目录:/dir1,/dir2,/dir3,/dir4
# 文件数目:1w * 4
# 文件大小:512K
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=10000,size=512k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:6
# 工作目录:/dir1,/dir2,/dir3,/dir4,/dir5,/dir6
# 文件数目:1w * 6
# 文件大小:512K
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=10000,size=512k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:6
# 工作目录:/dir1,/dir2,/dir3,/dir4,/dir5,/dir6
# 文件数目:1w * 6
# 文件大小:512K
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=10000,size=512k
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:4
# 工作目录:/dir1,/dir2,/dir3,/dir4
# 文件数目:5K * 6
# 文件大小:4M
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=5000,size=4M
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:6
# 工作目录:/dir1,/dir2,/dir3,/dir4,/dir5,/dir6
# 文件数目:5K * 6
# 文件大小:4M
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=5000,size=4M
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:4
# 工作目录:/dir1,/dir2,/dir3,/dir4
# 文件数目:2K * 4
# 文件大小:16M
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=2000,size=16M
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

# vdbench进程数:6
# 工作目录:/dir1,/dir2,/dir3,/dir4,/dir5,/dir6
# 文件数目:2K * 6
# 文件大小:16M
# xfersize:4K
# 线程数:(4)
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=2000,size=16M
fwd=fwd1,fsd=fsd1,operation=create,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,interval=1

小文件读写测试

1、单进程读写测试

# 文件数目:10w
# 文件大小:4K
# xfersize:4K
# operation: write\read
# fileio:sequential\random
# 线程数:4
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=100000,size=4K
fwd=fwd1,fsd=fsd1,operation=write,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,elapsed=300,interval=1

# 文件数目:10w
# 文件大小:128K
# xfersize:4K
# fileio:sequential\random
# 线程数:4
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=100000,size=4K
fwd=fwd1,fsd=fsd1,operation=write,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,elapsed=300,interval=1

2、单进程+读

# 文件数目:10w
# 文件大小:4K
# xfersize:4K
# fileio:sequential\random
# 线程数:4
fsd=fsd1,anchor=/dir1,depth=1,width=10,files=100000,size=4K
fwd=fwd1,fsd=fsd1,operation=read,xfersize=4k,fileio=sequential,fileselect=sequential,threads=4
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,elapsed=300,interval=1

3、多进程+写

4、多进程+读

ior/mdtest

安装教程

1、 安装依赖

[root@test1 ~]# yum -y install gcc gcc-c++ gcc-gfortran

2、创建软件包目录

[root@test1 ~]# mkdir tools

3、安装openmpi(除了openmpi外,还可以使用mpich,不过使用上跟openmpi会有所差异)

[root@test1 ~]# cd tools

[root@test1 tools]# curl -O https://download.open-mpi.org/release/open-mpi/v1.10/openmpi-1.10.7.tar.gz

[root@test1 openmpi-1.10.7]# ./configure --prefix=/usr/local/openmpi/

[root@test1 openmpi-1.10.7]# make

[root@test1 openmpi-1.10.7]# make install

4、添加环境变量

在.bashrc文件中添加以下三行内容

[root@test1 ~]# vim /root/.bashrc

export PATH=$PATH:/usr/local/openmpi/bin/:/usr/local/ior/bin/

export LD_LIBRARY_PATH=/usr/local/openmpi/lib:${LD_LIBRARY_PATH}

export MPI_CC=mpicc

[root@test1 ~]# source /root/.bashrc

5、安装IOR

[root@test1 ~]# cd tools/

[root@test1 tools]# yum -y install git automake

[root@test1 tools]# git clone https://github.com/chaos/ior.git

[root@test1 tools]# cd ior

[root@test1 ior]# ./bootstrap

[root@test1 ior]# ./configure --prefix=/usr/local/ior/

[root@test1 ior]# make

[root@test1 ior]# make install

6、安装mdtest

[root@test1 ~]# cd tools/

[root@test1 tools]# mkdir mdtest

[root@test1 tools]# cd mdtest

[root@test1 mdtest]# wget https://nchc.dl.sourceforge.net/project/mdtest/mdtest%20latest/mdtest-1.9.3/mdtest-1.9.3.tgz

[root@test1 mdtest]# tar xf mdtest-1.9.3.tgz

[root@test1 mdtest]# make

mdtest使用简介

参数说明
-F只创建文件
-L只在目录树的子目录层创建文件/目录
-z目录树深度
-b目录树分支
-I每个树节点包含的项目数
-u为每个工作任务指定工作目录
-d指出测试运行的目录
[root@node-1 fs1]# mdtest -F -L -z 4 -b 2 -I 10 -u -d /mnt/fs1/mdtest1/
-- started at 10/10/2020 14:04:19 --

mdtest-3.4.0+dev was launched with 1 total task(s) on 1 node(s)
Command line used: mdtest '-F' '-L' '-z' '4' '-b' '2' '-I' '10' '-u' '-d' '/mnt/fs1/mdtest1/'
WARNING: Read bytes is 0, thus, a read test will actually just open/close.
Path: /mnt/fs1/mdtest1
FS: 7.0 GiB   Used FS: 0.0%   Inodes: 0.0 Mi   Used Inodes: 100.0%

Nodemap: 1
1 tasks, 160 files

SUMMARY rate: (of 1 iterations)
   Operation                      Max            Min           Mean        Std Dev
   ---------                      ---            ---           ----        -------
   File creation             :        517.555        517.555        517.555          0.000
   File stat                 :       1101.718       1101.718       1101.718          0.000
   File read                 :       1087.185       1087.185       1087.185          0.000
   File removal              :        428.320        428.320        428.320          0.000
   Tree creation             :        404.253        404.253        404.253          0.000
   Tree removal              :        126.012        126.012        126.012          0.000
-- finished at 10/10/2020 14:04:20 --

参考链接

ior和mdtest测试工具安装和使用:https://yq.aliyun.com/articles/649319

filebench

参考链接:

https://github.com/filebench/filebench/wiki/Workload-model-language#fsync

文件系统压测工具,可以构建文件系统,并对其进行压测(打开,读取,写入等操作)。

安装教程

1、安装依赖

yum install -y gcc libtool automake flex bison

2、下载压缩包并解压

wget https://github.com/filebench/filebench/releases/download/1.5-alpha3/filebench-1.5-alpha3.tar.gz
tar -zxvf filebench-1.5-alpha3.tar.gz

3、安装

cd filebench-1.5-alpha3
./configure
make
make install

使用方法

filebench -f workload.f

工作负载文件用例介绍

第1行表示定义一个文件集,名称为testF,共有10000个文件,每个文件大小16K,路径为/tmp。prealloc表示文件系统在执行负载前预分配(在负载执行前生成完整文件集)。

第3行到第9行定义负载。名称为readerP,有2个进程,每个进程有3个线程。每个线程重复执行第5行到第6行的任务,每次任务会一次完成以下动作:1.在testF文件集中,随机打开一个文件,openOP是此次操作的名称,并非是文件名;2.读取整个文件,操作名为readOP;3.关闭此文件。重复执行此流程,直到到达设定的运行时间。

第11行,表示运行负载60秒。

01  define fileset name="testF",entries=10000,filesize=16k,prealloc,path="/tmp"
02
03  define process name="readerP",instances=2 {
04    thread name="readerT",instances=3 {
05      flowop openfile name="openOP",filesetname="testF"
06      flowop readwholefile name="readOP",filesetname="testF"
07      flowop closefile name="closeOP"
08    }
09  }
10
11  run 60

负载文件在/usr/local/share/filebench/workloads目录下有例子,可以自行参考并做相应修改。

# op典型流程语句集
# 示例:flowop <op> <name=op<num>> [parameters]
	# delete
	# 删除bigfileset文件集中所有内容
    flowop deletefile name=deletefile1,filesetname=bigfileset
    
    # create + append + fsync + close
    # 创建一个文件并写入meaniosize大小的内容,完成后刷新到硬盘。meaniosize是可自定义的大小。
    flowop createfile name=createfile1,filesetname=bigfileset,fd=1
    flowop appendfilerand name=appendfilerand1,iosize=$meaniosize,fd=1
    flowop fsync name=fsyncfile1,fd=1
    flowop closefile name=closefile1,fd=1
    
    # open + read + close
    # 读取一整个文件
    flowop openfile name=openfile2,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile2,fd=1,iosize=$iosize
    flowop closefile name=closefile2,fd=1
    
	# open + append + close
	# 随机打开一个文件,并追加写入meanappendsize大小的内容,同步到磁盘。meanappendsize是可自定义的大小。
	flowop openfile name=openfile1,filesetname=bigfileset,fd=1
    flowop appendfilerand name=appendfilerand1,iosize=$meanappendsize,fd=1
    flowop fsync name=fsyncfile2,fd=1
    flowop closefile name=closefile2,fd=1

文件测试负载设置

[root@node-1 ~]# cat file_bench_cephfs.f
# dir:工作目录
# nfiles:总文件数
# meandirwidth:每个目录下文件树。filebench会自动根据nfiles和meandirwidth计算出有多少个目录,并创建均匀分布的文件树。
# filesize:文件大小。cvar(type=cvar-gamma,parameters=mean:4096;gamma:1.5)表示文件大小符合伽马分布,均值未4096byte(4kb),gama值为1.5
# nthreads:工作线程数
# iosize:每次io操作大小(一般用于读写操作)
# meanappendsize:append操作大小(一般是appendwrite)
set $dir=/mnt/cephfs
set $nfiles=80000
set $meandirwidth=100
set $filesize=cvar(type=cvar-gamma,parameters=mean:4096;gamma:1.5)
set $nthreads=100
set $iosize=1m
set $meanappendsize=16k

define fileset name=bigfileset,path=$dir,size=$filesize,entries=$nfiles,dirwidth=$meandirwidth,prealloc=80

define process name=filereader,instances=1
{
  thread name=filereaderthread,memsize=10m,instances=$nthreads
  {
    flowop createfile name=createfile1,filesetname=bigfileset,fd=1
    flowop writewholefile name=wrtfile1,srcfd=1,fd=1,iosize=$iosize
    flowop fsync name=fsyncfile1,fd=1
    flowop closefile name=closefile1,fd=1
    
    flowop openfile name=openfile1,filesetname=bigfileset,fd=1
    flowop appendfilerand name=appendfilerand1,iosize=$meanappendsize,fd=1
    flowop fsync name=fsyncfile2,fd=1
    flowop closefile name=closefile2,fd=1
    
    flowop openfile name=openfile2,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile1,fd=1,iosize=$iosize
    flowop closefile name=closefile3,fd=1
    
    flowop deletefile name=deletefile1,filesetname=bigfileset
    flowop statfile name=statfile1,filesetname=bigfileset
  }
}

echo  "File-server Version 3.0 personality successfully loaded"

run 1200

结果分析

# 此测试参数
# set $dir=/mnt/cephfs
# set $nfiles=1000
# set $meandirwidth=100
# set $filesize=cvar(type=cvar-gamma,parameters=mean:4096000;gamma:1.5)
# set $nthreads=16
# set $iosize=1m
# set $meanappendsize=16k
[root@node-1 ~]# filebench -f file_bench_cephfs.f 
Filebench Version 1.5-alpha3
0.000: Allocated 173MB of shared memory
0.011: File-server Version 3.0 personality successfully loaded
0.011: Populating and pre-allocating filesets
0.012: bigfileset populated: 1000 files, avg. dir. width = 100, avg. dir. depth = 1.5, 0 leafdirs, 3705.622MB total size
0.012: Removing bigfileset tree (if exists)
0.034: Pre-allocating directories in bigfileset tree
0.034: Pre-allocating files in bigfileset tree
44.623: Waiting for pre-allocation to finish (in case of a parallel pre-allocation)
44.623: Population and pre-allocation of filesets completed
44.775: Starting 1 filereader instances
50.512: Running...
60.523: Run took 10 seconds...
60.523: Per-Operation Breakdown
# 操作名称      10秒内总操作次数   操作频率    io流量       每次操作平均耗时[最小耗时 - 最大耗时]
statfile1            135ops       13ops/s   0.0mb/s      0.3ms/op [0.00ms - 25.63ms]          
deletefile1          135ops       13ops/s   0.0mb/s      9.5ms/op [0.04ms - 345.04ms]
closefile3           135ops       13ops/s   0.0mb/s      0.0ms/op [0.00ms -  0.03ms]
readfile1            135ops       13ops/s  48.2mb/s     76.4ms/op [0.10ms - 521.70ms]
openfile2            137ops       14ops/s   0.0mb/s      1.9ms/op [0.00ms - 104.39ms]
closefile2           137ops       14ops/s   0.0mb/s      0.0ms/op [0.00ms -  0.08ms]
fsyncfile2           137ops       14ops/s   0.0mb/s    321.6ms/op [1.88ms - 1132.77ms]
appendfilerand1      144ops       14ops/s   0.1mb/s     60.6ms/op [0.01ms - 433.30ms]
openfile1            144ops       14ops/s   0.0mb/s      5.8ms/op [0.00ms - 111.33ms]
closefile1           144ops       14ops/s   0.0mb/s      0.0ms/op [0.00ms -  1.62ms]
fsyncfile1           144ops       14ops/s   0.0mb/s    600.8ms/op [38.30ms - 1375.71ms]
wrtfile1             151ops       15ops/s  61.4mb/s      1.4ms/op [0.04ms - 15.47ms]
createfile1          151ops       15ops/s   0.0mb/s      0.6ms/op [0.02ms - 67.76ms]
# 总结:总ops + 平均ops + 读执行次数(read)/写执行次数(append,write) + io流量 + 平均延时
60.523: IO Summary:  1829 ops 182.695 ops/s 13/29 rd/wr 109.7mb/s 354.3ms/op
60.524: Shutting down processes

7ops 14ops/s 0.0mb/s 0.0ms/op [0.00ms - 0.08ms]
fsyncfile2 137ops 14ops/s 0.0mb/s 321.6ms/op [1.88ms - 1132.77ms]
appendfilerand1 144ops 14ops/s 0.1mb/s 60.6ms/op [0.01ms - 433.30ms]
openfile1 144ops 14ops/s 0.0mb/s 5.8ms/op [0.00ms - 111.33ms]
closefile1 144ops 14ops/s 0.0mb/s 0.0ms/op [0.00ms - 1.62ms]
fsyncfile1 144ops 14ops/s 0.0mb/s 600.8ms/op [38.30ms - 1375.71ms]
wrtfile1 151ops 15ops/s 61.4mb/s 1.4ms/op [0.04ms - 15.47ms]
createfile1 151ops 15ops/s 0.0mb/s 0.6ms/op [0.02ms - 67.76ms]

总结:总ops + 平均ops + 读执行次数(read)/写执行次数(append,write) + io流量 + 平均延时

60.523: IO Summary: 1829 ops 182.695 ops/s 13/29 rd/wr 109.7mb/s 354.3ms/op
60.524: Shutting down processes


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值