---
title: fio测试步骤
description: "fio-3.7建议直接使用yum的方式安装，CentOS 7.6下直接使用以下命令即可安装："
url: https://www.hikunpeng.com/document/detail/zh/kunpengsdss/testGuide/tstg/ceph-wjcc_cszd_010.html
sourcePath: /source/zh/kunpengsdss/testGuide/tstg/ceph-wjcc_cszd_010.html
indexId: 3ad847d8ce015c29d61a4e42b148a24c75dfe87d21318bcb683962276613408c61
---
# fio测试步骤

#### 安装fio

fio-3.7建议直接使用yum的方式安装，CentOS 7.6下直接使用以下命令即可安装：

```
yum -y install fio
```

也可以采用以下的方式下载源码包编译安装。


1. 下载fio压缩包到所有client的“/home”目录下。
  下载链接：https://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.git/snapshot/fio-3.7.tar.gz(https://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.git/snapshot/fio-3.7.tar.gz)

2. 所有客户端解压fio。
  1 cd /home && tar -zxvf fio-3.7.tar.gz

3. 进入fio解压后的目录。
  1 cd fio-3.7

4. 安装rbd引擎依赖。
  1 yum -y install librbd-devel

  安装librbd-devel需要配置Ceph源，具体配置方法请参考《Ceph块存储 部署指南（CentOS 7.6&openEuler 20.03）》中“配置部署环境(https://www.hikunpeng.com/document/detail/zh/kunpengsdss/ecosystemEnable/Ceph/kunpengcephblock_04_0003.html)”相关内容。

5. 编译安装fio。
  1 ./configure && make && make install


#### fio测试模型

fio通过执行工作负载配置文件运行，选取其中一台客户端执行即可，该客户端会通过负载配置文件中的其他客户端IP地址等信息自动登录到其他客户端执行测试。测试前需要先挂载CephFS文件系统。


#### 创建fio工作负载

本文以1个Ceph客户端，每个客户端读写3个文件，每个文件读写最大容量为10G为例。下文以client1创建1MB顺序写工作负载为例，需要为每个client同时创建3个配置文件。


1. 创建第一个配置文件。
  1 vi 1024Kclient1_file1_write.fio

```
[global]
ioengine=libaio
size=10G
direct=1
numjobs=1
runtime=60
ramp_time=10
log_avg_msec=500
thread
time_based
[1024K-write]
filename=/mnt/cephfs/1024K_client1_file1
bs=1024K
rw=write
iodepth=64
write_bw_log=1024K-write
stonewall
buffer_compress_percentage=40
```


2. 创建第二个配置文件。
  1 vi 1024Kclient1_file2_write.fio

```
[global]
ioengine=libaio
size=10G
direct=1
numjobs=1
runtime=60
ramp_time=10
log_avg_msec=500
thread
time_based
[1024K-read]
filename=/mnt/cephfs/1024K_client1_file2
bs=1024K
rw=read
iodepth=64
write_bw_log=1024K-read
stonewall
buffer_compress_percentage=40
```


3. 创建第三个配置文件。
  1 vi 1024Kclient1_file3_write.fio

```
[global]
ioengine=libaio
size=10G
direct=1
numjobs=1
runtime=60
ramp_time=10
log_avg_msec=500
thread
time_based
[1024K-rw]
filename=/mnt/cephfs/1024K_client1_file3
bs=1024K
rw=rw
iodepth=64
write_bw_log=1024K-rw
rwmixwrite=30
stonewall
buffer_compress_percentage=40
```


  buffer_compress_percentage=40是测试压缩时用到的参数。加上此参数，fio写入的数据可被压缩为一定比例。如果不需要测试压缩，可以将此字段删除。


#### 执行测试用例

1. 启动fio服务。
  1 fio -S &

2. 在client1上执行测试用例（以image1write为例）。
  1 fio --client=client1 ./1024Kclient1_image1write.fio --client=client1 ./1024Kclient1_image2write.fio --client=client1 ./1024Kclient1_image3write.fio --output=./1mwrite.log


#### 查看测试结果

测试完成后会在当前目录下生成1mwrite.log，包含各项测试数据。
