资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

如何进行磁盘的I/O测试-创新互联

如何进行磁盘的I/O测试

 

创新互联公司成立与2013年,我们提供高端网站建设、小程序开发、电商视觉设计、手机APP定制开发及网络营销搜索优化服务,在传统互联网与移动互联网发展的背景下,我们坚守着用标准的设计方案与技术开发实力作基础,以企业及品牌的互联网商业目标为核心,为客户打造具商业价值与用户体验的互联网+产品。

https://wiki.mikejung.biz/Benchmarking

译文有增删

 

1 Linux 常见基准测试工具

FIO

Sysbench

Phoronix Test Suite (moved to it's own page)

IOzone

Ioping

UnixBench

Google's Perfkit Benchmarker

 

2 FIO

fio算是比较老的io测试工具了,作者是Jens Axboe。

主页https://www.thomas-krenn.com/en/wiki/Fio

fio的安装

我的测试环境有centos7 redhat5 因此要下载两个版本的fio包

redhat5 版本的需要去归档站点去下载

http://archives.fedoraproject.org/pub/archive/epel/

下载后的安装 rpm -ivh fio-1.57-1.el5.x86_64.rpm

 

centos7 则可以去很多镜像站点下载,站点列表可以查询

/tupian/20230522/span

如果配置了epel 的yum 源,直接yum install -y fio

 

 

fio测试选项和例子

示例 使用fio测试磁盘的随机写

 

fio --name=randwrite --ioengine=libaio --iodepth=1 --rw=randwrite --bs=4k \

  --direct=0 --size=512M --numjobs=8 --runtime=240 --group_reporting

 

--rw=randwrite 指定随机写

--direct=0 指定使用buffered IO 还是direct IO。如果使用buffer,注意总大小不要超过物理内存

--numjobs=8 启动8个进程

--size=512M 每个进程写512M

--group_reporting  将多个进程的统计结果进行聚合,更易阅读

--runtime=240 持续运行时间4分钟

--bs=4k  --blocksize=4k (default)

--ioengine=libaio 可用的io引擎可以使用 fio --enghelp查看(fio-2.2.8)

--iodepth=1 缺省 测试ssd磁盘时,可以扩大到32,通常4就够了 

The iodepth option defines the amount of IO units that will continue to hammer a file with requests during the test.

 

 

避免使用buffer的方法是指定--direct=1 或者使用比物理内存大一倍的写文件

 

fio结果的重点关注项目:

iops=1416        iops = 1416

95.00th=[    2]  95%的IO在2毫秒完成

util=99.62%      设备繁忙程度

 

示例 使用fio测试磁盘的随机读

 

fio --name=randread --ioengine=libaio --iodepth=16 --rw=randread --bs=4k \

  --direct=0 --size=512M --numjobs=8 --runtime=240 --group_reporting

 

 

fio 帮助

man fio

fio -h

fio -v

 

fio 命令行中写上选项,也可以将命令行选项写入一个参数文件job file中

fio 安装后,自带了一些样例

# rpm -ql -p fio-1.57-1.el5.x86_64.rpm

/usr/bin/fio

/usr/bin/fio_generate_plots

/usr/share/doc/fio-1.57

/usr/share/doc/fio-1.57/COPYING

/usr/share/doc/fio-1.57/HOWTO

/usr/share/doc/fio-1.57/README

/usr/share/doc/fio-1.57/REPORTING-BUGS

/usr/share/doc/fio-1.57/examples

/usr/share/doc/fio-1.57/examples/1mbs_clients

/usr/share/doc/fio-1.57/examples/aio-read

......

aio-read 参数文件,修改一下可以马上使用

 

# fio aio-read.bak

 

file1: (g=0): rw=randread, bs=128K-128K/128K-128K, ioengine=libaio, iodepth=4

file2: (g=0): rw=randread, bs=128K-128K/128K-128K, ioengine=libaio, iodepth=32

file3: (g=0): rw=randread, bs=128K-128K/128K-128K, ioengine=libaio, iodepth=8

file4: (g=0): rw=randread, bs=128K-128K/128K-128K, ioengine=libaio, iodepth=16

fio 1.57

......

 

fio 输出结果的一些注释

 

   io     Number of megabytes of I/O performed.

   bw     Average data rate (bandwidth).

   runt   Threads run time.

   slat   Submission  latency  minimum, maximum, average and standard deviation. This

          is the time it took to submit the I/O.

   clat   Completion latency minimum, maximum, average and standard deviation.   This

          is the time between submission and completion.

   bw     Bandwidth  minimum,  maximum,  percentage  of aggregate bandwidth received, average and standard deviation.

 

   The group statistics show:

          io     Number of megabytes I/O performed.

          aggrb  Aggregate bandwidth of threads in the group.

          minb   Minimum average bandwidth a thread saw.

          maxb   Maximum average bandwidth a thread saw.

          mint   Shortest runtime of threads in the group.

          maxt   Longest runtime of threads in the group.

 

   Finally, disk statistics are printed with reads first:

          ios    Number of I/Os performed by all groups.

          merge  Number of merges in the I/O scheduler.

          ticks  Number of ticks we kept the disk busy.

          io_queue

                 Total time spent in the disk queue.

          util   Disk utilization.

示例 随机读直接IO

fio --name=randread --ioengine=libaio --iodepth=16 --rw=randread --bs=4k --direct=1 --size=1G --numjobs=8 --runtime=240 --group_reporting

 

csdn上一个翻译成中文的帖子 /tupian/20230522/8722417 没耐心看英文的估计中文的也不会看完。

3 sysbench

sysbench可以测试cpu \ oltp mysql\ fileio 网上用来测试mysql的文章比较多。

sysbench的安装

在centos 中,可以从epel直接安装。安装时需要mysql / postgresql

源文中的安装方法

wget ftp://ftp.gnome.org/mirror/fedora/epel/6/x86_64/sysbench-0.4.12-5.el6.x86_64.rpm

wget http://downloads.mysql.com/archives/mysql-5.1/MySQL-shared-compat-5.1.49-1.rhel5.x86_64.rpm

rpm -iv MySQL-shared-compat-5.1.49-1.rhel5.x86_64.rpm

yum install postgresql-libs.x86_64

rpm -iv sysbench-0.4.12-5.el6.x86_64.rpm


网站题目:如何进行磁盘的I/O测试-创新互联
网页链接:http://cdkjz.cn/article/ephjd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220