zoukankan      html  css  js  c++  java
  • Linux服务器iops性能测试-fio

     FIO是测试IOPS的非常好的工具,用来对硬件进行压力测试和验证,支持13种不同的I/O引擎,包括:sync,mmap, libaio, posixaio, SG v3, splice, null, network, syslet,guasi, solarisaio 等等。

    fio 官网地址:http://freecode.com/projects/fio

    FIO用法:

    随机读:

    fio -filename=/dev/sdb1 -direct=1 -iodepth1 -thread -rw=randread -ioengine=psync -bs=16k -size=200G -numjobs=10-runtime=1000 -group_reporting -name=mytest

    说明:

    filename=/dev/sdb1       测试文件名称,通常选择需要测试的盘的data目录。

    direct=1                 测试过程绕过机器自带的buffer。使测试结果更真实。

    rw=randwrite             测试随机写的I/O

    rw=randrw                测试随机写和读的I/O

    bs=16k                   单次io的块文件大小为16k

    bsrange=512-2048         同上,提定数据块的大小范围

    size=5g   本次的测试文件大小为5g,以每次4k的io进行测试。

    numjobs=30               本次的测试线程为30.

    runtime=1000             测试时间为1000秒,如果不写则一直将5g文件分4k每次写完为止。

    ioengine=psync           io引擎使用pync方式

    rwmixwrite=30            在混合读写的模式下,写占30%

    group_reporting          关于显示结果的,汇总每个进程的信息。

    这个工具最大的特点是使用简单,支持的文件操作非常多, 可以覆盖到我们能见到的文件使用方式:
    sync:Basic read(2) or write(2) I/O. fseek(2) is used to position the I/O location.
    psync:Basic pread(2) or pwrite(2) I/O.
    vsync: Basic readv(2) or writev(2) I/O. Will emulate queuing by coalescing adjacents iOS into a single submission.
    libaio: Linux native asynchronous I/O.
    posixaio: glibc POSIX asynchronous I/O using aio_read(3) and aio_write(3).
    mmap: File is memory mapped with mmap(2) and data copied using memcpy(3).
    splice: splice(2) is used to transfer the data and vmsplice(2) to transfer data from user-space to the kernel.
    syslet-rw: Use the syslet system calls to make regular read/write asynchronous.
    sg:SCSI generic sg v3 I/O.
    net : Transfer over the network. filename must be set appropriately to `host/port’ regardless of data direction. If receiving,
    only the port argument is used.
    netsplice: Like net, but uses splice(2) and vmsplice(2) to map data and send/receive.
    guasi The GUASI I/O engine is the Generic Userspace Asynchronous Syscall Interface approach to asycnronous I/O.

    此外

    lockmem=1g               只使用1g内存进行测试。

    zero_buffers             用0初始化系统buffer。

    nrfiles=8                每个进程生成文件的数量。

    顺序读:

    fio -filename=/dev/sdb1 -direct=1 -iodepth1 -thread -rw=read -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000-group_reporting -name=mytest

    随机写:

    fio -filename=/dev/sdb1 -direct=1 -iodepth1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=200G -numjobs=30-runtime=1000 -group_reporting -name=mytest

    顺序写:

    fio -filename=/dev/sdb1 -direct=1 -iodepth1 -thread -rw=write -ioengine=psync -bs=16k -size=200G -numjobs=30-runtime=1000 -group_reporting -name=mytest

    混合随机读写:

    fio -filename=/dev/sdb1 -direct=1 -iodepth1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=200G-numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop

     转自:http://blog.csdn.net/youngstonep/article/details/52315192

    注意事项

    使用fio工具测试磁盘iops后,可能会导致磁盘下的文件损坏,出现Structure needs cleaning错误。 

    解决办法(会造成数据丢失)参考以下链接:

    http://www.jb51.net/LINUXjishu/225992.html

    今天在使用fio进行IO测试的时候,文件系统/home分区遇到了mount: Structure needs cleaning 报错。大致情况:

    /home分区是xfs文件系统;

    执行fio进行多进程测试;

    测试完毕之后,执行du -hs /home/*,部分文件的数据提示 “mount: Structure needs cleaning”报错;

    解决方法

    可以使用xfs_repair来修复,但是要注意 xfs_repair修复的分区中的文件都会丢失,即使是du能正常显示的文件也会丢失。

    处理步骤:

    umount /home
    xfs_repair /home
    mount /home

    挂载命令也可用: mount /dev/sdc1 /mnt/usbhd1    —— 第一个参数是设备号,第二个参数是目录

    该工具一定要谨慎使用!损坏的数据目前还没办法恢复!!!

  • 相关阅读:
    Hive的安装和建表
    在MarkDown中插入数学公式对照表(持续更新)
    Beta版本冲刺总汇
    a版本十日冲刺总汇
    “我们只是信息的搬运工”
    调查报告
    Beta版本冲刺第七天
    Beta版本冲刺第六天
    Beta版本冲刺第五天
    Beta版本冲刺第四天
  • 原文地址:https://www.cnblogs.com/mister-w/p/7220747.html
Copyright © 2011-2022 走看看