Linux|操作系统运维|磁盘性能检测之fio和iostat的初步使用

本文主要是介绍Linux|操作系统运维|磁盘性能检测之fio和iostat的初步使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前言:

有的时候,我们接手一个新的服务器的时候,需要了解该服务器的磁盘性能是否可靠,比如,磁盘是否有坏道,磁盘的读写性能是否能够符合我们将要部署的服务,例如数据库服务,如果该数据库是一个读写比较频繁也就是IO比较高的数据库,那么,该磁盘是否能够支持高IO呢?

针对以上需求,建议使用工具fio和iostat这两个工具

一、

iostat在centos7下的安装

配置update源即可

iostat工具包含在sysstat软件包中。因此,需要安装sysstat软件包来获得iostat工具。运行以下命令来安装sysstat包:

 

sudo yum install sysstat -y

常用选项
  • -d:仅显示磁盘I/O相关信息。
  • -k:以KB为单位显示传输速率。
  • -m:以MB为单位显示传输速率。
  • -x:显示详细的磁盘统计信息,包括传输速率、响应时间、等待时间和使用率等。
  • -p [磁盘]:显示指定磁盘和分区的情况。
  • 显示所有设备的负载情况
iostat
  • 每隔2秒刷新显示,且显示3次
iostat 2 3
  • 只查看磁盘状态,并以KB为单位显示传输速率
iostat -dk
  • 查看指定磁盘(如sda)的详细统计信息
iostat -dx sda

3. 解读iostat输出

iostat的输出包含CPU和磁盘的统计信息。以下是关于磁盘部分的主要字段及其解释:

  • tps:每秒传输次数。
  • kB_read/s 和 kB_wrtn/s:每秒读和写的千字节数。
  • await:平均每次设备I/O操作的等待时间(毫秒)。
  • svctm:平均每次设备I/O操作的服务时间(毫秒)。
  • %util:一秒中有百分之多少的时间用于I/O操作,即被I/O消耗的CPU百分比。

4. 磁盘性能分析

  • 如果%util接近100%,说明产生的I/O请求太多,I/O系统已经满负荷,该磁盘可能存在瓶颈。
  • 如果await远大于svctm,说明I/O队列太长,I/O响应太慢,可能需要进行必要优化。
  • 如果avgqu-sz(平均I/O队列长度)比较大,也表示有大量的I/O在等待。

通过iostat的输出,可以识别系统中的磁盘瓶颈和性能问题,从而采取适当的措施来优化系统性能。

示例

1、查看磁盘sda和sdb的详细状态,使用参数-dx

[root@centos5 ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  100G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   80G  0 part └─centos-root 253:0    0   80G  0 lvm  /
sdb               8:16   0   20G  0 disk 
sr0              11:0    1  4.4G  0 rom  /mnt
[root@centos5 ~]# iostat -dx sda
Linux 3.10.0-1062.el7.x86_64 (centos5) 	06/23/2024 	_x86_64_	(4 CPU)Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sda               0.00     0.04    0.35    0.31    14.16     9.66    72.48     0.00    1.17    1.61    0.69   0.37   0.02[root@centos5 ~]# iostat -dx sdb
Linux 3.10.0-1062.el7.x86_64 (centos5) 	06/23/2024 	_x86_64_	(4 CPU)Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00     0.00    0.00    0.00     0.09     0.00    54.15     0.00    0.08    0.08    0.00   0.03   0.00

2、查看所有磁盘的性能,主要是观察tps这列,一般是tps越高越好

[root@centos5 ~]# iostat 
Linux 3.10.0-1062.el7.x86_64 (centos5) 	06/23/2024 	_x86_64_	(4 CPU)avg-cpu:  %user   %nice %system %iowait  %steal   %idle0.01    0.00    0.19    0.01    0.00   99.79Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.04         0.00       1046          0
sda               0.65        14.07         9.60     398575     272060
sdb               0.00         0.09         0.00       2464          0
dm-0              0.62        13.74         9.53     389310     269972

3、查看磁盘sda的io详情,这里主要关注的是uitl这一列,越低表示磁盘IO负载越低

[root@centos5 ~]# iostat -dkx /dev/sda
Linux 3.10.0-1062.el7.x86_64 (centos5) 	06/23/2024 	_x86_64_	(4 CPU)Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sda               0.00     0.04    0.34    0.31    13.96     9.54    72.35     0.00    1.17    1.61    0.68   0.37   0.02[root@centos5 ~]# iostat -dmx /dev/sda
Linux 3.10.0-1062.el7.x86_64 (centos5) 	06/23/2024 	_x86_64_	(4 CPU)Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sda               0.00     0.04    0.34    0.31     0.01     0.01    72.35     0.00    1.17    1.61    0.68   0.37   0.02

4、一段时间内的磁盘IO状态查询

下面是8秒内的磁盘状态,2秒一刷新,刷新四次

 

[root@centos5 ~]# iostat 2 4
Linux 3.10.0-1062.el7.x86_64 (centos5) 	06/23/2024 	_x86_64_	(4 CPU)avg-cpu:  %user   %nice %system %iowait  %steal   %idle0.01    0.00    0.19    0.01    0.00   99.80Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.04         0.00       1046          0
sda               0.64        13.72         9.39     398607     272860
sdb               0.00         0.08         0.00       2464          0
dm-0              0.61        13.40         9.32     389342     270772avg-cpu:  %user   %nice %system %iowait  %steal   %idle0.00    0.00    0.00    0.00    0.00  100.00Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.00         0.00          0          0
sda               0.50         0.00         6.00          0         12
sdb               0.00         0.00         0.00          0          0
dm-0              0.50         0.00         6.00          0         12avg-cpu:  %user   %nice %system %iowait  %steal   %idle0.00    0.00    0.00    0.00    0.00  100.00Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.00         0.00          0          0
sda               0.00         0.00         0.00          0          0
sdb               0.00         0.00         0.00          0          0
dm-0              0.00         0.00         0.00          0          0avg-cpu:  %user   %nice %system %iowait  %steal   %idle0.00    0.00    0.00    0.00    0.00  100.00Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.00         0.00          0          0
sda               0.00         0.00         0.00          0          0
sdb               0.00         0.00         0.00          0          0
dm-0              0.00         0.00         0.00          0          0

 

需要明确一点,这个iostat是一个可以实时查看磁盘IO负载情况的工具,没有报告生成 ,主要关注三个指标:%iowait和%util和tps

%iowait 是磁盘的读写响应等待时间,这个数值越小越好,越小表明磁盘读写速度快

%util指的是在统计的时间间隔内,磁盘设备处于非空闲状态的百分比。它表示了磁盘设备被I/O请求占用的程度。换句话说,它反映了磁盘的繁忙程度

tps是磁盘的IO吞吐率,这个数值越高越好,越高表明磁盘处理数据速度越快

二、

fio磁盘检测报告工具

FIO(Flexible I/O Tester)是一个功能强大的开源工具,主要用于测试和评估存储系统的性能。其主要功能包括以下几个方面:

  1. I/O类型测试
    • 顺序读/写:用于测试存储设备对连续数据的读取和写入性能,这通常用于评估存储设备的吞吐量。
    • 随机读/写:测试存储设备对随机数据访问的读取和写入性能,这通常用于评估存储设备的IOPS(每秒输入/输出操作数)。
    • 混合读/写:测试存储设备在同时进行读取和写入操作时的性能,这可以模拟实际工作负载中的混合操作。
  2. 块大小调整
    • 通过改变读写操作的块大小,FIO可以测试存储设备在不同块大小下的性能。这有助于确定最佳的块大小设置。
  3. 并发连接与队列深度
    • 通过同时发起多个并行连接,FIO可以测试存储设备在高并发负载下的性能,评估存储设备在多用户或多线程环境中的表现。
    • 调整请求队列的深度,测试存储设备在不同负载下的性能,评估存储设备在高负载情况下的响应能力。
  4. 多种I/O引擎支持
    • FIO支持多种I/O引擎,如同步、异步、mmap等,可以模拟各种复杂的I/O场景。
  5. 详细的性能指标
    • FIO的输出结果非常详细,包括每个测试任务的IOPS、带宽、延迟等性能指标,为存储设备的性能评估提供准确的数据支持。
  6. 输出格式与数据保存
    • 支持将输出结果以CSV格式保存,方便后续的数据分析和可视化。
  7. 配置选项丰富
    • FIO提供了许多其他配置选项,例如数据验证、文件系统类型、线程数、运行时间等,以满足不同测试需求。
  8. 跨平台兼容性
    • FIO支持多种操作系统,包括Linux、FreeBSD、NetBSD、OS X、OpenSolaris、AIX、HP-UX、Windows等。

归纳起来,FIO是一款功能全面、配置灵活、跨平台的磁盘I/O性能测试工具,广泛用于标准测试、QA、验证测试等场景,帮助用户准确地评估存储设备的性能,为系统的优化和升级提供有力的数据支持。

1、fio的部署

该工具部署比较简单,但需要多个网络源,安装过程大概如下,各位可参考:

[root@centos5 ~]# yum install fio -y
Loaded plugins: fastestmirror
Repository 'local' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package fio.x86_64 0:3.7-2.el7 will be installed
--> Processing Dependency: librdmacm.so.1(RDMACM_1.0)(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: libpmemblk.so.1(LIBPMEMBLK_1.0)(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: libpmem.so.1(LIBPMEM_1.0)(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: libibverbs.so.1(IBVERBS_1.1)(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: libibverbs.so.1(IBVERBS_1.0)(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: librdmacm.so.1()(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: librbd.so.1()(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: librados.so.2()(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: libpmemblk.so.1()(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: libpmem.so.1()(64bit) for package: fio-3.7-2.el7.x86_64
--> Processing Dependency: libibverbs.so.1()(64bit) for package: fio-3.7-2.el7.x86_64
--> Running transaction check
---> Package libibverbs.x86_64 0:22.4-6.el7_9 will be installed
--> Processing Dependency: rdma-core(x86-64) = 22.4-6.el7_9 for package: libibverbs-22.4-6.el7_9.x86_64
---> Package libpmem.x86_64 0:1.5.1-2.1.el7 will be installed
---> Package libpmemblk.x86_64 0:1.5.1-2.1.el7 will be installed
--> Processing Dependency: libndctl.so.6(LIBNDCTL_3)(64bit) for package: libpmemblk-1.5.1-2.1.el7.x86_64
--> Processing Dependency: libndctl.so.6(LIBNDCTL_14)(64bit) for package: libpmemblk-1.5.1-2.1.el7.x86_64
--> Processing Dependency: libndctl.so.6(LIBNDCTL_1)(64bit) for package: libpmemblk-1.5.1-2.1.el7.x86_64
--> Processing Dependency: libdaxctl.so.1(LIBDAXCTL_2)(64bit) for package: libpmemblk-1.5.1-2.1.el7.x86_64
--> Processing Dependency: libndctl.so.6()(64bit) for package: libpmemblk-1.5.1-2.1.el7.x86_64
--> Processing Dependency: libdaxctl.so.1()(64bit) for package: libpmemblk-1.5.1-2.1.el7.x86_64
---> Package librados2.x86_64 1:10.2.5-4.el7 will be installed
--> Processing Dependency: libboost_thread-mt.so.1.53.0()(64bit) for package: 1:librados2-10.2.5-4.el7.x86_64
--> Processing Dependency: libboost_system-mt.so.1.53.0()(64bit) for package: 1:librados2-10.2.5-4.el7.x86_64
--> Processing Dependency: libboost_random-mt.so.1.53.0()(64bit) for package: 1:librados2-10.2.5-4.el7.x86_64
--> Processing Dependency: libboost_iostreams-mt.so.1.53.0()(64bit) for package: 1:librados2-10.2.5-4.el7.x86_64
---> Package librbd1.x86_64 1:10.2.5-4.el7 will be installed
---> Package librdmacm.x86_64 0:22.4-6.el7_9 will be installed
--> Running transaction check
---> Package boost-iostreams.x86_64 0:1.53.0-28.el7 will be installed
---> Package boost-random.x86_64 0:1.53.0-28.el7 will be installed
---> Package boost-system.x86_64 0:1.53.0-28.el7 will be installed
---> Package boost-thread.x86_64 0:1.53.0-28.el7 will be installed
---> Package daxctl-libs.x86_64 0:65-6.el7_9 will be installed
---> Package ndctl-libs.x86_64 0:65-6.el7_9 will be installed
---> Package rdma-core.x86_64 0:22.4-6.el7_9 will be installed
--> Finished Dependency ResolutionDependencies Resolved==============================================================================================================================================================================================================================================================================================================================================Package                                                                              Arch                                                                        Version                                                                              Repository                                                                        Size
==============================================================================================================================================================================================================================================================================================================================================
Installing:fio                                                                                  x86_64                                                                      3.7-2.el7                                                                            base_x86_64                                                                      467 k
Installing for dependencies:boost-iostreams                                                                      x86_64                                                                      1.53.0-28.el7                                                                        base_x86_64                                                                       61 kboost-random                                                                         x86_64                                                                      1.53.0-28.el7                                                                        base_x86_64                                                                       39 kboost-system                                                                         x86_64                                                                      1.53.0-28.el7                                                                        base_x86_64                                                                       40 kboost-thread                                                                         x86_64                                                                      1.53.0-28.el7                                                                        base_x86_64                                                                       58 kdaxctl-libs                                                                          x86_64                                                                      65-6.el7_9                                                                           updates                                                                           27 klibibverbs                                                                           x86_64                                                                      22.4-6.el7_9                                                                         updates                                                                          269 klibpmem                                                                              x86_64                                                                      1.5.1-2.1.el7                                                                        base_x86_64                                                                       59 klibpmemblk                                                                           x86_64                                                                      1.5.1-2.1.el7                                                                        base_x86_64                                                                       80 klibrados2                                                                            x86_64                                                                      1:10.2.5-4.el7                                                                       base_x86_64                                                                      1.8 Mlibrbd1                                                                              x86_64                                                                      1:10.2.5-4.el7                                                                       base_x86_64                                                                      2.4 Mlibrdmacm                                                                            x86_64                                                                      22.4-6.el7_9                                                                         updates                                                                           64 kndctl-libs                                                                           x86_64                                                                      65-6.el7_9                                                                           updates                                                                           65 krdma-core                                                                            x86_64                                                                      22.4-6.el7_9                                                                         updates                                                                           51 kTransaction Summary
==============================================================================================================================================================================================================================================================================================================================================
Install  1 Package (+13 Dependent packages)Total download size: 5.5 M
Installed size: 16 M
Downloading packages:
(1/14): boost-random-1.53.0-28.el7.x86_64.rpm                                                                                                                                                                                                                                                                          |  39 kB  00:00:00     
(2/14): boost-iostreams-1.53.0-28.el7.x86_64.rpm                                                                                                                                                                                                                                                                       |  61 kB  00:00:00     
(3/14): boost-system-1.53.0-28.el7.x86_64.rpm                                                                                                                                                                                                                                                                          |  40 kB  00:00:00     
(4/14): boost-thread-1.53.0-28.el7.x86_64.rpm                                                                                                                                                                                                                                                                          |  58 kB  00:00:00     
(5/14): libpmem-1.5.1-2.1.el7.x86_64.rpm                                                                                                                                                                                                                                                                               |  59 kB  00:00:00     
(6/14): daxctl-libs-65-6.el7_9.x86_64.rpm                                                                                                                                                                                                                                                                              |  27 kB  00:00:00     
(7/14): libpmemblk-1.5.1-2.1.el7.x86_64.rpm                                                                                                                                                                                                                                                                            |  80 kB  00:00:00     
(8/14): fio-3.7-2.el7.x86_64.rpm                                                                                                                                                                                                                                                                                       | 467 kB  00:00:00     
(9/14): libibverbs-22.4-6.el7_9.x86_64.rpm                                                                                                                                                                                                                                                                             | 269 kB  00:00:00     
(10/14): ndctl-libs-65-6.el7_9.x86_64.rpm                                                                                                                                                                                                                                                                              |  65 kB  00:00:00     
(11/14): rdma-core-22.4-6.el7_9.x86_64.rpm                                                                                                                                                                                                                                                                             |  51 kB  00:00:00     
(12/14): librdmacm-22.4-6.el7_9.x86_64.rpm                                                                                                                                                                                                                                                                             |  64 kB  00:00:00     
(13/14): librados2-10.2.5-4.el7.x86_64.rpm                                                                                                                                                                                                                                                                             | 1.8 MB  00:00:00     
(14/14): librbd1-10.2.5-4.el7.x86_64.rpm                                                                                                                                                                                                                                                                               | 2.4 MB  00:00:00     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                                                                                                          25 MB/s | 5.5 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : boost-system-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                         1/14 Installing : boost-thread-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                         2/14 Installing : libpmem-1.5.1-2.1.el7.x86_64                                                                                                                                                                                                                                                                                              3/14 Installing : rdma-core-22.4-6.el7_9.x86_64                                                                                                                                                                                                                                                                                             4/14 Installing : libibverbs-22.4-6.el7_9.x86_64                                                                                                                                                                                                                                                                                            5/14 Installing : daxctl-libs-65-6.el7_9.x86_64                                                                                                                                                                                                                                                                                             6/14 Installing : boost-random-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                         7/14 Installing : boost-iostreams-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                      8/14 Installing : 1:librados2-10.2.5-4.el7.x86_64                                                                                                                                                                                                                                                                                           9/14 Installing : 1:librbd1-10.2.5-4.el7.x86_64                                                                                                                                                                                                                                                                                            10/14 Installing : ndctl-libs-65-6.el7_9.x86_64                                                                                                                                                                                                                                                                                             11/14 Installing : libpmemblk-1.5.1-2.1.el7.x86_64                                                                                                                                                                                                                                                                                          12/14 Installing : librdmacm-22.4-6.el7_9.x86_64                                                                                                                                                                                                                                                                                            13/14 Installing : fio-3.7-2.el7.x86_64                                                                                                                                                                                                                                                                                                     14/14 Verifying  : 1:librbd1-10.2.5-4.el7.x86_64                                                                                                                                                                                                                                                                                             1/14 Verifying  : boost-system-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                         2/14 Verifying  : fio-3.7-2.el7.x86_64                                                                                                                                                                                                                                                                                                      3/14 Verifying  : boost-iostreams-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                      4/14 Verifying  : boost-thread-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                         5/14 Verifying  : boost-random-1.53.0-28.el7.x86_64                                                                                                                                                                                                                                                                                         6/14 Verifying  : 1:librados2-10.2.5-4.el7.x86_64                                                                                                                                                                                                                                                                                           7/14 Verifying  : daxctl-libs-65-6.el7_9.x86_64                                                                                                                                                                                                                                                                                             8/14 Verifying  : libpmemblk-1.5.1-2.1.el7.x86_64                                                                                                                                                                                                                                                                                           9/14 Verifying  : libibverbs-22.4-6.el7_9.x86_64                                                                                                                                                                                                                                                                                           10/14 Verifying  : rdma-core-22.4-6.el7_9.x86_64                                                                                                                                                                                                                                                                                            11/14 Verifying  : librdmacm-22.4-6.el7_9.x86_64                                                                                                                                                                                                                                                                                            12/14 Verifying  : ndctl-libs-65-6.el7_9.x86_64                                                                                                                                                                                                                                                                                             13/14 Verifying  : libpmem-1.5.1-2.1.el7.x86_64                                                                                                                                                                                                                                                                                             14/14 Installed:fio.x86_64 0:3.7-2.el7                                                                                                                                                                                                                                                                                                                      Dependency Installed:boost-iostreams.x86_64 0:1.53.0-28.el7        boost-random.x86_64 0:1.53.0-28.el7        boost-system.x86_64 0:1.53.0-28.el7        boost-thread.x86_64 0:1.53.0-28.el7        daxctl-libs.x86_64 0:65-6.el7_9        libibverbs.x86_64 0:22.4-6.el7_9        libpmem.x86_64 0:1.5.1-2.1.el7        libpmemblk.x86_64 0:1.5.1-2.1.el7       librados2.x86_64 1:10.2.5-4.el7               librbd1.x86_64 1:10.2.5-4.el7              librdmacm.x86_64 0:22.4-6.el7_9            ndctl-libs.x86_64 0:65-6.el7_9             rdma-core.x86_64 0:22.4-6.el7_9       Complete!
[root@centos5 ~]# rpm -qa |grep libaio
libaio-0.3.109-13.el7.x86_64

 2、

fio的使用方式

fio一般是使用配置文件,配置文件以fio为后缀,当然了,后缀名其实无所谓,但用fio会一目了然嘛

[root@centos5 ~]# cat test_fio.txt 
[random-rw-test]
rw=randrw
bs=4k
iodepth=10
ioengine=libaio
numjobs=10
size=5G
filename=/root/test.file
  1. 测试配置:

    • 测试类型:随机读写(randrw)
    • 块大小:4096字节,这里也就是4K对齐啦
    • I/O引擎:psync
    • I/O深度:10,当iodepth设置为10时,FIO会尝试在队列中同时保持最多10个I/O请求。这些请求可能处于等待或正在处理状态,但都没有完成
  2. 测试类型的种类
  1. 随机读写(randrw):
    • 随机混合读写,涉及同时进行随机读取(randread)和随机写入(randwrite)操作。
    • 在fio工具中,可以使用-rw=randrw参数来设置这种测试类型。
  2. 随机读(randread):
    • 仅进行随机读取操作。
    • 在fio工具中,使用-rw=randread参数设置。
  3. 随机写(randwrite):
    • 仅进行随机写入操作。
    • 在fio工具中,使用-rw=randwrite参数设置。
  4. 顺序读(read):
    • 顺序读取操作,从文件的起始位置到结束位置连续读取数据。
    • 在fio工具中,使用-rw=read参数设置。
  5. 顺序写(write):
    • 顺序写入操作,从文件的起始位置开始连续写入数据。
    • 在fio工具中,使用-rw=write参数设置。
  6. 顺序混合读写(rw):
    • 同时进行顺序读取和顺序写入操作。
    • 这种模式虽然通常不特别指定为“顺序混合读写”,但可以通过设置合适的读写比例和模式来模拟。

以上配置文件的测试项目执行,生成的报告如下:

输出的很多,但是主要关注err这里,如果这里非零,那么,表示磁盘读写遇到了错误

因为是10个线程,因此,每个线程的读写情况(也就是每个jobs)都给了一个报告总结

其次,需要关注read这一行和write这一行,是读写的IOPS,读写用时

在总结一下:

  1. IOPS (每秒输入/输出操作数):
    • read: IOPS=2219 和 write: IOPS=2217:这表示测试期间每秒完成的读取和写入操作数。对于随机读写测试,这是衡量存储设备性能的一个重要指标。
  2. 带宽(BW):
    • read: BW=8878KiB/s 和 write: BW=8869KiB/s:这是每秒传输的数据量。与IOPS类似,这也是一个关键的性能指标。
  3. 延迟:
    • clat (nsec) 和 lat (nsec)clat 是完成时间(completion latency),即从请求开始到请求完成的时间;lat 是延迟(latency),可能包括等待时间和完成时间。注意这些值的范围、平均值和标准偏差,它们提供了关于系统响应时间的详细信息。
  4. 延迟的百分位数:
    • 这部分显示了延迟的分布情况。特别是99%和99.9%的延迟值,它们可以帮助识别可能的性能瓶颈或异常值。
  5. 带宽和IOPS的样本统计:
    • minmaxavgstdev 和 samples 提供了关于测试期间带宽和IOPS的详细统计信息。注意最小值、最大值、平均值和标准偏差,它们可以帮助你了解性能的稳定性和变化范围。
  6. 错误(err):
    • 在这个报告中,err=0 表示没有发生错误。如果这里有非零值,那么需要进一步检查以确定问题的原因。
  7. 测试参数:
    • ioengine=psync:这表示使用了同步I/O引擎。在fio中,你可以选择不同的I/O引擎来模拟不同类型的I/O工作负载。例如,libaio 通常用于模拟异步I/O。
    • iodepth=10:这是队列深度,表示同时发出的I/O请求的数量。根据你的测试目标和硬件能力,可能需要调整这个值。
    • 其他参数,如bs(块大小)和size(测试文件的大小),也可能影响测试结果。
  8. 测试时间:
    • 注意测试运行的持续时间(在这个例子中是295418msec)以及是否达到了预期的测试时间或数据量。
  9. 系统资源:
    • 虽然报告中没有直接给出,但在解释fio测试结果时,还需要考虑系统的其他资源(如CPU、内存和网络)的使用情况。这些资源可能成为性能瓶颈。

[root@centos5 ~]# fio test_fio.txt 
random-rw-test: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=10
...
fio-3.7
Starting 10 processes
random-rw-test: Laying out IO file (1 file / 5120MiB)
Jobs: 10 (f=10): [m(10)][99.3%][r=86.7MiB/s,w=86.9MiB/s][r=22.2k,w=22.2k IOPS][eta 00m:02s]
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6361: Sun Jun 23 12:56:22 2024read: IOPS=2219, BW=8878KiB/s (9091kB/s)(2561MiB/295418msec)clat (nsec): min=282, max=817925k, avg=53077.71, stdev=1939391.82lat (nsec): min=296, max=817925k, avg=53108.61, stdev=1939392.31clat percentiles (nsec):|  1.00th=[     692],  5.00th=[     764], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1400],| 50.00th=[   15040], 60.00th=[   23168], 70.00th=[   47360],| 80.00th=[   57600], 90.00th=[   73216], 95.00th=[   95744],| 99.00th=[  403456], 99.50th=[  561152], 99.90th=[  880640],| 99.95th=[ 1908736], 99.99th=[71827456]bw (  KiB/s): min=    7, max=24688, per=10.31%, avg=9143.45, stdev=6171.68, samples=568iops        : min=    1, max= 6172, avg=2285.82, stdev=1542.95, samples=568write: IOPS=2217, BW=8869KiB/s (9082kB/s)(2559MiB/295418msec)clat (nsec): min=439, max=1912.2M, avg=397129.59, stdev=7021242.97lat (nsec): min=463, max=1912.2M, avg=397172.29, stdev=7021245.03clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1160], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5216], 60.00th=[    24960], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3489792], 99.50th=[  5079040], 99.90th=[ 10158080],| 99.95th=[ 28180480], 99.99th=[299892736]bw (  KiB/s): min=    7, max=25120, per=10.26%, avg=9103.84, stdev=6192.87, samples=570iops        : min=    1, max= 6280, avg=2275.91, stdev=1548.25, samples=570lat (nsec)   : 500=0.01%, 750=1.91%, 1000=10.69%lat (usec)   : 2=25.62%, 4=7.96%, 10=3.93%, 20=7.37%, 50=10.29%lat (usec)   : 100=16.25%, 250=1.95%, 500=1.28%, 750=4.72%, 1000=4.43%lat (msec)   : 2=2.76%, 4=0.40%, 10=0.37%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.04%, sys=5.93%, ctx=1105536, majf=0, minf=40IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=655676,655044,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6362: Sun Jun 23 12:56:22 2024read: IOPS=2218, BW=8873KiB/s (9086kB/s)(2558MiB/295205msec)clat (nsec): min=360, max=329418k, avg=49250.84, stdev=1479677.88lat (nsec): min=378, max=329418k, avg=49280.13, stdev=1479678.59clat percentiles (nsec):|  1.00th=[     692],  5.00th=[     764], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1400],| 50.00th=[   15040], 60.00th=[   23168], 70.00th=[   47360],| 80.00th=[   57600], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  411648], 99.50th=[  569344], 99.90th=[  872448],| 99.95th=[ 1548288], 99.99th=[31588352]bw (  KiB/s): min=    7, max=27401, per=10.43%, avg=9253.19, stdev=6240.70, samples=564iops        : min=    1, max= 6850, avg=2313.21, stdev=1560.26, samples=564write: IOPS=2221, BW=8887KiB/s (9101kB/s)(2562MiB/295205msec)clat (nsec): min=601, max=2037.9M, avg=400192.04, stdev=7491462.90lat (nsec): min=643, max=2037.9M, avg=400240.13, stdev=7491525.34clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1160], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5088], 60.00th=[    24960], 70.00th=[    69120],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3457024], 99.50th=[  5079040], 99.90th=[ 10158080],| 99.95th=[ 28442624], 99.99th=[312475648]bw (  KiB/s): min=    7, max=27457, per=10.46%, avg=9284.77, stdev=6244.89, samples=563iops        : min=    1, max= 6864, avg=2321.11, stdev=1561.30, samples=563lat (nsec)   : 500=0.01%, 750=1.90%, 1000=10.75%lat (usec)   : 2=25.69%, 4=7.92%, 10=3.94%, 20=7.34%, 50=10.15%lat (usec)   : 100=16.34%, 250=1.97%, 500=1.26%, 750=4.74%, 1000=4.43%lat (msec)   : 2=2.75%, 4=0.40%, 10=0.37%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.03%, sys=5.96%, ctx=1100960, majf=0, minf=39IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=654814,655906,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6363: Sun Jun 23 12:56:22 2024read: IOPS=2218, BW=8876KiB/s (9089kB/s)(2560MiB/295404msec)clat (nsec): min=307, max=422401k, avg=52494.66, stdev=1781361.99lat (nsec): min=323, max=422401k, avg=52522.72, stdev=1781362.63clat percentiles (nsec):|  1.00th=[     692],  5.00th=[     764], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1400],| 50.00th=[   15168], 60.00th=[   23424], 70.00th=[   47872],| 80.00th=[   57600], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  403456], 99.50th=[  561152], 99.90th=[  847872],| 99.95th=[ 1417216], 99.99th=[60555264]bw (  KiB/s): min=    7, max=24824, per=10.28%, avg=9118.65, stdev=6208.62, samples=570iops        : min=    1, max= 6206, avg=2279.61, stdev=1552.19, samples=570write: IOPS=2218, BW=8873KiB/s (9086kB/s)(2560MiB/295404msec)clat (nsec): min=584, max=2006.7M, avg=397591.31, stdev=6988532.53lat (nsec): min=606, max=2006.7M, avg=397632.89, stdev=6988535.65clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1160], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5024], 60.00th=[    24960], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3457024], 99.50th=[  5079040], 99.90th=[ 10420224],| 99.95th=[ 30801920], 99.99th=[299892736]bw (  KiB/s): min=    7, max=24640, per=10.30%, avg=9145.55, stdev=6207.50, samples=568iops        : min=    1, max= 6160, avg=2286.34, stdev=1551.91, samples=568lat (nsec)   : 500=0.01%, 750=1.87%, 1000=10.75%lat (usec)   : 2=25.61%, 4=7.96%, 10=3.90%, 20=7.31%, 50=10.25%lat (usec)   : 100=16.33%, 250=2.00%, 500=1.29%, 750=4.74%, 1000=4.41%lat (msec)   : 2=2.75%, 4=0.40%, 10=0.36%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.03%, sys=5.97%, ctx=1104134, majf=0, minf=37IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=655472,655248,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6364: Sun Jun 23 12:56:22 2024read: IOPS=2218, BW=8875KiB/s (9088kB/s)(2560MiB/295389msec)clat (nsec): min=340, max=413983k, avg=51025.11, stdev=1620038.77lat (nsec): min=355, max=413983k, avg=51055.60, stdev=1620039.22clat percentiles (nsec):|  1.00th=[     692],  5.00th=[     764], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1400],| 50.00th=[   15040], 60.00th=[   23168], 70.00th=[   47360],| 80.00th=[   57600], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  415744], 99.50th=[  577536], 99.90th=[  872448],| 99.95th=[ 1466368], 99.99th=[53215232]bw (  KiB/s): min=    7, max=24184, per=10.34%, avg=9169.75, stdev=6172.01, samples=567iops        : min=    1, max= 6046, avg=2292.39, stdev=1543.04, samples=567write: IOPS=2218, BW=8874KiB/s (9087kB/s)(2560MiB/295389msec)clat (nsec): min=585, max=2007.2M, avg=398960.79, stdev=7102444.88lat (nsec): min=651, max=2007.2M, avg=399004.26, stdev=7102450.53clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1176], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5216], 60.00th=[    25472], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3457024], 99.50th=[  5079040], 99.90th=[ 10289152],| 99.95th=[ 30277632], 99.99th=[299892736]bw (  KiB/s): min=    7, max=24096, per=10.37%, avg=9203.16, stdev=6147.91, samples=565iops        : min=    1, max= 6024, avg=2300.74, stdev=1537.02, samples=565lat (nsec)   : 500=0.01%, 750=1.82%, 1000=10.82%lat (usec)   : 2=25.60%, 4=7.90%, 10=3.91%, 20=7.34%, 50=10.36%lat (usec)   : 100=16.25%, 250=1.97%, 500=1.28%, 750=4.76%, 1000=4.42%lat (msec)   : 2=2.74%, 4=0.41%, 10=0.36%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.03%, sys=5.96%, ctx=1103774, majf=0, minf=38IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=655369,655351,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6365: Sun Jun 23 12:56:22 2024read: IOPS=2215, BW=8862KiB/s (9075kB/s)(2557MiB/295403msec)clat (nsec): min=372, max=371577k, avg=47097.11, stdev=1325479.58lat (nsec): min=387, max=371577k, avg=47124.44, stdev=1325480.30clat percentiles (nsec):|  1.00th=[     692],  5.00th=[     764], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1064], 40.00th=[    1400],| 50.00th=[   15040], 60.00th=[   23424], 70.00th=[   46848],| 80.00th=[   57088], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  411648], 99.50th=[  569344], 99.90th=[  856064],| 99.95th=[ 1368064], 99.99th=[30277632]bw (  KiB/s): min=    7, max=23296, per=10.36%, avg=9190.93, stdev=6182.41, samples=565iops        : min=    1, max= 5824, avg=2297.58, stdev=1545.73, samples=565write: IOPS=2221, BW=8886KiB/s (9099kB/s)(2563MiB/295403msec)clat (nsec): min=678, max=1861.6M, avg=402442.21, stdev=7122063.50lat (nsec): min=698, max=1861.6M, avg=402482.83, stdev=7122069.27clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1176], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1800], 40.00th=[     2544],| 50.00th=[     5152], 60.00th=[    25216], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3457024], 99.50th=[  5079040], 99.90th=[ 10551296],| 99.95th=[ 32374784], 99.99th=[312475648]bw (  KiB/s): min=    6, max=23800, per=10.31%, avg=9149.29, stdev=6232.14, samples=569iops        : min=    1, max= 5950, avg=2287.17, stdev=1558.16, samples=569lat (nsec)   : 500=0.01%, 750=1.85%, 1000=10.86%lat (usec)   : 2=25.47%, 4=7.99%, 10=3.93%, 20=7.34%, 50=10.54%lat (usec)   : 100=16.00%, 250=1.99%, 500=1.28%, 750=4.74%, 1000=4.44%lat (msec)   : 2=2.75%, 4=0.41%, 10=0.36%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.03%, sys=5.99%, ctx=1103436, majf=0, minf=36IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=654489,656231,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6366: Sun Jun 23 12:56:22 2024read: IOPS=2217, BW=8870KiB/s (9083kB/s)(2559MiB/295423msec)clat (nsec): min=346, max=311204k, avg=48984.44, stdev=1478448.08lat (nsec): min=363, max=311204k, avg=49015.08, stdev=1478448.85clat percentiles (nsec):|  1.00th=[     692],  5.00th=[     764], 10.00th=[     820],| 20.00th=[     932], 30.00th=[    1064], 40.00th=[    1368],| 50.00th=[   14784], 60.00th=[   22656], 70.00th=[   46848],| 80.00th=[   57088], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  407552], 99.50th=[  561152], 99.90th=[  864256],| 99.95th=[ 1531904], 99.99th=[32112640]bw (  KiB/s): min=    7, max=25480, per=10.26%, avg=9105.49, stdev=6220.42, samples=570iops        : min=    1, max= 6370, avg=2276.29, stdev=1555.18, samples=570write: IOPS=2219, BW=8877KiB/s (9090kB/s)(2561MiB/295423msec)clat (nsec): min=660, max=2005.7M, avg=400898.48, stdev=7307794.53lat (nsec): min=714, max=2005.7M, avg=400940.84, stdev=7307796.73clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1160], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5152], 60.00th=[    25472], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3489792], 99.50th=[  5013504], 99.90th=[ 10420224],| 99.95th=[ 30801920], 99.99th=[320864256]bw (  KiB/s): min=    7, max=25208, per=10.34%, avg=9180.43, stdev=6222.49, samples=566iops        : min=    1, max= 6302, avg=2295.04, stdev=1555.69, samples=566lat (nsec)   : 500=0.01%, 750=1.88%, 1000=11.01%lat (usec)   : 2=25.48%, 4=7.92%, 10=3.94%, 20=7.34%, 50=10.36%lat (usec)   : 100=16.05%, 250=1.99%, 500=1.29%, 750=4.72%, 1000=4.43%lat (msec)   : 2=2.76%, 4=0.40%, 10=0.37%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.04%, sys=6.00%, ctx=1100892, majf=0, minf=39IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=655078,655642,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6367: Sun Jun 23 12:56:22 2024read: IOPS=2220, BW=8880KiB/s (9093kB/s)(2561MiB/295340msec)clat (nsec): min=351, max=372771k, avg=52229.23, stdev=1616711.81lat (nsec): min=366, max=372771k, avg=52262.22, stdev=1616755.58clat percentiles (nsec):|  1.00th=[     700],  5.00th=[     772], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1416],| 50.00th=[   15168], 60.00th=[   23424], 70.00th=[   47360],| 80.00th=[   57600], 90.00th=[   73216], 95.00th=[   95744],| 99.00th=[  415744], 99.50th=[  577536], 99.90th=[  897024],| 99.95th=[ 1531904], 99.99th=[61603840]bw (  KiB/s): min=    6, max=24640, per=10.26%, avg=9099.50, stdev=6245.30, samples=573iops        : min=    1, max= 6160, avg=2274.76, stdev=1561.44, samples=573write: IOPS=2217, BW=8872KiB/s (9085kB/s)(2559MiB/295340msec)clat (nsec): min=472, max=1860.3M, avg=397843.00, stdev=7032490.44lat (nsec): min=510, max=1860.3M, avg=397885.49, stdev=7032493.49clat percentiles (nsec):|  1.00th=[     1048],  5.00th=[     1176], 10.00th=[     1288],| 20.00th=[     1528], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5152], 60.00th=[    25216], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3457024], 99.50th=[  5013504], 99.90th=[ 10289152],| 99.95th=[ 31064064], 99.99th=[308281344]bw (  KiB/s): min=    6, max=24048, per=10.28%, avg=9122.06, stdev=6229.80, samples=571iops        : min=    1, max= 6012, avg=2280.40, stdev=1557.57, samples=571lat (nsec)   : 500=0.01%, 750=1.77%, 1000=10.85%lat (usec)   : 2=25.55%, 4=7.94%, 10=3.94%, 20=7.34%, 50=10.31%lat (usec)   : 100=16.33%, 250=1.96%, 500=1.26%, 750=4.75%, 1000=4.44%lat (msec)   : 2=2.75%, 4=0.40%, 10=0.36%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.03%, sys=5.93%, ctx=1103446, majf=0, minf=39IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=655675,655045,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6368: Sun Jun 23 12:56:22 2024read: IOPS=2217, BW=8870KiB/s (9083kB/s)(2558MiB/295328msec)clat (nsec): min=346, max=1860.3M, avg=53776.95, stdev=2863271.52lat (nsec): min=368, max=1860.3M, avg=53805.74, stdev=2863271.89clat percentiles (nsec):|  1.00th=[     700],  5.00th=[     772], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1416],| 50.00th=[   15168], 60.00th=[   23424], 70.00th=[   47872],| 80.00th=[   57600], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  407552], 99.50th=[  561152], 99.90th=[  839680],| 99.95th=[ 1466368], 99.99th=[30801920]bw (  KiB/s): min=    6, max=26280, per=10.30%, avg=9138.30, stdev=6238.09, samples=570iops        : min=    1, max= 6570, avg=2284.44, stdev=1559.63, samples=570write: IOPS=2220, BW=8883KiB/s (9096kB/s)(2562MiB/295328msec)clat (nsec): min=586, max=1362.6M, avg=395907.51, stdev=6520932.99lat (nsec): min=609, max=1362.6M, avg=395948.10, stdev=6520935.12clat percentiles (nsec):|  1.00th=[     1048],  5.00th=[     1176], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5088], 60.00th=[    24960], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3489792], 99.50th=[  5079040], 99.90th=[ 10420224],| 99.95th=[ 31588352], 99.99th=[329252864]bw (  KiB/s): min=    7, max=26112, per=10.38%, avg=9215.91, stdev=6223.75, samples=566iops        : min=    1, max= 6528, avg=2303.84, stdev=1556.04, samples=566lat (nsec)   : 500=0.01%, 750=1.77%, 1000=10.68%lat (usec)   : 2=25.77%, 4=7.96%, 10=3.92%, 20=7.33%, 50=10.25%lat (usec)   : 100=16.33%, 250=1.98%, 500=1.28%, 750=4.74%, 1000=4.42%lat (msec)   : 2=2.75%, 4=0.40%, 10=0.37%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.04%, sys=5.93%, ctx=1103120, majf=0, minf=38IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=654907,655813,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6369: Sun Jun 23 12:56:22 2024read: IOPS=2216, BW=8865KiB/s (9078kB/s)(2558MiB/295424msec)clat (nsec): min=312, max=458061k, avg=48869.63, stdev=1521849.86lat (nsec): min=329, max=458061k, avg=48901.31, stdev=1521852.24clat percentiles (nsec):|  1.00th=[     692],  5.00th=[     772], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1400],| 50.00th=[   14912], 60.00th=[   22912], 70.00th=[   46848],| 80.00th=[   57088], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  407552], 99.50th=[  561152], 99.90th=[  831488],| 99.95th=[ 1531904], 99.99th=[28704768]bw (  KiB/s): min=    7, max=24360, per=10.24%, avg=9082.80, stdev=6209.80, samples=571iops        : min=    1, max= 6090, avg=2270.62, stdev=1552.52, samples=571write: IOPS=2220, BW=8882KiB/s (9095kB/s)(2562MiB/295424msec)clat (nsec): min=548, max=2007.2M, avg=400839.69, stdev=7013168.15lat (nsec): min=570, max=2007.2M, avg=400881.57, stdev=7013171.21clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1176], 10.00th=[     1288],| 20.00th=[     1528], 30.00th=[     1800], 40.00th=[     2576],| 50.00th=[     5152], 60.00th=[    25728], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3457024], 99.50th=[  5079040], 99.90th=[ 10420224],| 99.95th=[ 30801920], 99.99th=[329252864]bw (  KiB/s): min=    7, max=24000, per=10.27%, avg=9116.81, stdev=6218.26, samples=570iops        : min=    1, max= 6000, avg=2279.13, stdev=1554.63, samples=570lat (nsec)   : 500=0.01%, 750=1.78%, 1000=10.74%lat (usec)   : 2=25.69%, 4=8.01%, 10=3.95%, 20=7.34%, 50=10.31%lat (usec)   : 100=16.11%, 250=2.02%, 500=1.30%, 750=4.73%, 1000=4.44%lat (msec)   : 2=2.74%, 4=0.40%, 10=0.37%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.03%, sys=6.01%, ctx=1100486, majf=0, minf=37IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=654731,655989,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10
random-rw-test: (groupid=0, jobs=1): err= 0: pid=6370: Sun Jun 23 12:56:22 2024read: IOPS=2219, BW=8878KiB/s (9091kB/s)(2561MiB/295338msec)clat (nsec): min=391, max=449165k, avg=47668.55, stdev=1502799.64lat (nsec): min=405, max=449165k, avg=47698.87, stdev=1502800.28clat percentiles (nsec):|  1.00th=[     700],  5.00th=[     772], 10.00th=[     820],| 20.00th=[     940], 30.00th=[    1080], 40.00th=[    1400],| 50.00th=[   15040], 60.00th=[   23168], 70.00th=[   47360],| 80.00th=[   57600], 90.00th=[   73216], 95.00th=[   96768],| 99.00th=[  415744], 99.50th=[  577536], 99.90th=[  839680],| 99.95th=[ 1400832], 99.99th=[10158080]bw (  KiB/s): min=    7, max=25632, per=10.27%, avg=9113.87, stdev=6256.22, samples=572iops        : min=    1, max= 6408, avg=2278.43, stdev=1564.08, samples=572write: IOPS=2218, BW=8874KiB/s (9087kB/s)(2559MiB/295338msec)clat (nsec): min=535, max=2037.1M, avg=402320.10, stdev=7199187.94lat (nsec): min=561, max=2037.1M, avg=402364.23, stdev=7199191.28clat percentiles (nsec):|  1.00th=[     1032],  5.00th=[     1176], 10.00th=[     1288],| 20.00th=[     1512], 30.00th=[     1784], 40.00th=[     2544],| 50.00th=[     5152], 60.00th=[    25216], 70.00th=[    70144],| 80.00th=[   659456], 90.00th=[   897024], 95.00th=[  1122304],| 99.00th=[  3457024], 99.50th=[  5079040], 99.90th=[ 10420224],| 99.95th=[ 31064064], 99.99th=[333447168]bw (  KiB/s): min=    7, max=25512, per=10.24%, avg=9091.74, stdev=6264.44, samples=573iops        : min=    1, max= 6378, avg=2272.90, stdev=1566.13, samples=573lat (nsec)   : 500=0.01%, 750=1.77%, 1000=10.80%lat (usec)   : 2=25.70%, 4=7.94%, 10=3.94%, 20=7.28%, 50=10.30%lat (usec)   : 100=16.24%, 250=1.99%, 500=1.29%, 750=4.74%, 1000=4.43%lat (msec)   : 2=2.75%, 4=0.41%, 10=0.36%, 20=0.02%, 50=0.01%lat (msec)   : 100=0.01%, 250=0.01%, 500=0.01%, 750=0.01%, 1000=0.01%cpu          : usr=0.04%, sys=5.97%, ctx=1102804, majf=0, minf=38IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%issued rwts: total=655521,655199,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=10Run status group 0 (all jobs):READ: bw=86.6MiB/s (90.8MB/s), 8862KiB/s-8880KiB/s (9075kB/s-9093kB/s), io=24.0GiB (26.8GB), run=295205-295424msecWRITE: bw=86.7MiB/s (90.9MB/s), 8869KiB/s-8887KiB/s (9082kB/s-9101kB/s), io=25.0GiB (26.9GB), run=295205-295424msecDisk stats (read/write):dm-0: ios=2234623/5030599, merge=0/0, ticks=287034/18529581, in_queue=18819425, util=79.96%, aggrios=2237019/5030577, aggrmerge=3/22, aggrticks=287782/18406978, aggrin_queue=18694777, aggrutil=79.80%sda: ios=2237019/5030577, merge=3/22, ticks=287782/18406978, in_queue=18694777, util=79.80%

fio的引擎问题

  1. sync:同步I/O引擎,每个I/O操作都会等待前一个I/O操作完成后再进行。
  2. mmap:使用内存映射文件进行I/O操作。
  3. libaio:Linux的异步I/O(AIO)接口,用于异步提交I/O请求。
  4. posixaio:POSIX标准的异步I/O接口。
  5. SG v3:SCSI通用(SG)接口的第3版,用于与SCSI设备通信。
  6. splice:Linux的splice系统调用,用于在两个文件描述符之间移动数据。
  7. null:一个不执行任何I/O操作的引擎,主要用于基准测试或模拟。
  8. network:用于通过网络进行I/O的引擎。
  9. syslet:这是fio的一个实验性特性,用于在Linux上执行系统调用。
  10. guasi:这是一个错误或特定于某个版本的fio的引擎名称,通常不是fio的标准引擎之一。
  11. solarisaio:针对Solaris操作系统的异步I/O引擎。

查询操作系统使用的是哪种IO磁盘调度器,本例是deadline

磁盘调度器(例如Linux下的cfq、deadline、noop等),Linux提供了几种不同的磁盘调度算法,包括CFQ(完全公平队列),Deadline(截止时间),和NOOP(电梯式)等。对于数据库服务器,通常推荐使用DeadlineNOOP,尤其是当使用SSD时

[root@centos5 ~]# cat /sys/block/sda/queue/scheduler 
noop [deadline] cfq 
  • 永久更改调度器编辑GRUB配置文件(如/etc/default/grub),在GRUB_CMDLINE_LINUX_DEFAULT添加磁盘调度器参数,例如:

     
    [root@centos5 ~]# cat /etc/default/
    grub     nss      useradd  
    [root@centos5 ~]# cat /etc/default/grub 
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT=saved
    GRUB_DISABLE_SUBMENU=true
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rhgb  elevator=noop quiet splash"
    GRUB_DISABLE_RECOVERY="true"
    

    然后运行以下命令并重启系统,此命令会根据/etc/default/grub和其他GRUB配置文件生成一个新的GRUB配置文件,并保存到指定路径。

    grub2-mkconfig -o /boot/grub2/grub.cfg

    在重申一次,配置文件可以按需配置测试选项,上面的配置文件是一个比较全的,可调整IO引擎,读写顺序,bs,iodepth,size这些选项

  • 例如磁盘的顺序读写性能,使用IO引擎为mmap,那么配置文件如下:

[root@centos5 ~]# cat test_fio.txt 
[random-rw-test]
rw=rw
bs=4k
iodepth=10
ioengine=mmap
numjobs=10
size=5G
filename=/root/test.file

实际测试的时候,会发现顺序读写速度是非常快的,比随机读写也就是randrw快很多

总共引擎有这么些,常用的是sync,libaio,psync,postixaio:

[root@centos5 ~]# fio --enghelp  cmd
Available IO engines:cpuiommapsyncpsyncvsyncpvsyncpvsync2nullnetnetspliceftruncatefilecreatelibaiordmaposixaiofalloce4defragspliceradosrbdmtdpmemblkdev-daxlibpmemsg

这篇关于Linux|操作系统运维|磁盘性能检测之fio和iostat的初步使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1088117

相关文章

使用Python开发一个Ditto剪贴板数据导出工具

《使用Python开发一个Ditto剪贴板数据导出工具》在日常工作中,我们经常需要处理大量的剪贴板数据,下面将介绍如何使用Python的wxPython库开发一个图形化工具,实现从Ditto数据库中读... 目录前言运行结果项目需求分析技术选型核心功能实现1. Ditto数据库结构分析2. 数据库自动定位3

Python yield与yield from的简单使用方式

《Pythonyield与yieldfrom的简单使用方式》生成器通过yield定义,可在处理I/O时暂停执行并返回部分结果,待其他任务完成后继续,yieldfrom用于将一个生成器的值传递给另一... 目录python yield与yield from的使用代码结构总结Python yield与yield

Go语言使用select监听多个channel的示例详解

《Go语言使用select监听多个channel的示例详解》本文将聚焦Go并发中的一个强力工具,select,这篇文章将通过实际案例学习如何优雅地监听多个Channel,实现多任务处理、超时控制和非阻... 目录一、前言:为什么要使用select二、实战目标三、案例代码:监听两个任务结果和超时四、运行示例五

python使用Akshare与Streamlit实现股票估值分析教程(图文代码)

《python使用Akshare与Streamlit实现股票估值分析教程(图文代码)》入职测试中的一道题,要求:从Akshare下载某一个股票近十年的财务报表包括,资产负债表,利润表,现金流量表,保存... 目录一、前言二、核心知识点梳理1、Akshare数据获取2、Pandas数据处理3、Matplotl

Linux线程同步/互斥过程详解

《Linux线程同步/互斥过程详解》文章讲解多线程并发访问导致竞态条件,需通过互斥锁、原子操作和条件变量实现线程安全与同步,分析死锁条件及避免方法,并介绍RAII封装技术提升资源管理效率... 目录01. 资源共享问题1.1 多线程并发访问1.2 临界区与临界资源1.3 锁的引入02. 多线程案例2.1 为

Java使用Thumbnailator库实现图片处理与压缩功能

《Java使用Thumbnailator库实现图片处理与压缩功能》Thumbnailator是高性能Java图像处理库,支持缩放、旋转、水印添加、裁剪及格式转换,提供易用API和性能优化,适合Web应... 目录1. 图片处理库Thumbnailator介绍2. 基本和指定大小图片缩放功能2.1 图片缩放的

Python使用Tenacity一行代码实现自动重试详解

《Python使用Tenacity一行代码实现自动重试详解》tenacity是一个专为Python设计的通用重试库,它的核心理念就是用简单、清晰的方式,为任何可能失败的操作添加重试能力,下面我们就来看... 目录一切始于一个简单的 API 调用Tenacity 入门:一行代码实现优雅重试精细控制:让重试按我

MySQL中EXISTS与IN用法使用与对比分析

《MySQL中EXISTS与IN用法使用与对比分析》在MySQL中,EXISTS和IN都用于子查询中根据另一个查询的结果来过滤主查询的记录,本文将基于工作原理、效率和应用场景进行全面对比... 目录一、基本用法详解1. IN 运算符2. EXISTS 运算符二、EXISTS 与 IN 的选择策略三、性能对比

Oracle数据库定时备份脚本方式(Linux)

《Oracle数据库定时备份脚本方式(Linux)》文章介绍Oracle数据库自动备份方案,包含主机备份传输与备机解压导入流程,强调需提前全量删除原库数据避免报错,并需配置无密传输、定时任务及验证脚本... 目录说明主机脚本备机上自动导库脚本整个自动备份oracle数据库的过程(建议全程用root用户)总结

使用Python构建智能BAT文件生成器的完美解决方案

《使用Python构建智能BAT文件生成器的完美解决方案》这篇文章主要为大家详细介绍了如何使用wxPython构建一个智能的BAT文件生成器,它不仅能够为Python脚本生成启动脚本,还提供了完整的文... 目录引言运行效果图项目背景与需求分析核心需求技术选型核心功能实现1. 数据库设计2. 界面布局设计3