1. smartctl
2. fio
-
先介绍IOPS,IOPS(Input/Output Operation Per Second)是一个用于计算机存储设备(如HDD、SSD或者存储区域网络(SAN)性能测试的量测方法,可以视为每秒的读写次数。存储设备制造商提供的IOPS不保证是实际的应用性能。)
-
fio是一个测试IOPS的工具,用来对磁盘进行压力测试和验证。磁盘IO是检查磁盘性能的重要指标,可以按照负载情况分成照顺序读写,随机读写两大类。fio的典型用途是编写和模拟I/O负载匹配的作业文件。FIO是一个多线程io生成工具,可以生成多种IO模式,用来测试磁盘的性能(也包含文件系统:如针对网络文件系统的NFS的IO测试)。
-
随机读写与顺序读写
- 顺序读写:文件指针只能从头移动到尾。
- 随机读写:文件指针可以随意移动,根据需要。
-
fio常用参数
参数说明:
filename=/dev/sdb1 测试文件名称,通常选择需要测试的盘的data目录。
direct=1 是否使用directIO,测试过程绕过OS自带的buffer,使测试磁盘的结果更真实。Linux读写的时候,内核维护了缓存,数据先写到缓存,后面再后台写到SSD。读的时候也优先读缓存里的数据。这样速度可以加快,但是一旦掉电缓存里的数据就没了。所以有一种模式叫做DirectIO,跳过缓存,直接读写SSD。 rw=randwrite 测试随机写的I/O
rw=randrw 测试随机写和读的I/O
bs=16k 单次io的块文件大小为16k
bsrange=512-2048 同上,提定数据块的大小范围
size=5G 每个线程读写的数据量是5GB。
numjobs=1 每个job(任务)开1个线程,这里用了几,后面每个用-name指定的任务就开几个线程测试。所以最终线程数=任务数(几个name=jobx)* numjobs。
name=job1:一个任务的名字,重复了也没关系。如果fio -name=job1 -name=job2,建立了两个任务,共享-name=job1之前的参数。-name之后的就是job2任务独有的参数。
thread 使用pthread_create创建线程,另一种是fork创建进程。进程的开销比线程要大,一般都采用thread测试。
runtime=1000 测试时间为1000秒,如果不写则一直将5g文件分4k每次写完为止。
ioengine=libaio 指定io引擎使用libaio方式。libaio:Linux本地异步I/O。请注意,Linux可能只支持具有非缓冲I/O的排队行为(设置为“direct=1”或“buffered=0”);rbd:通过librbd直接访问CEPH Rados
iodepth=16 队列的深度为16.在异步模式下,CPU不能一直无限的发命令到SSD。比如SSD执行读写如果发生了卡顿,那有可能系统会一直不停的发命令,几千个,甚至几万个,这样一方面SSD扛不住,另一方面这么多命令会很占内存,系统也要挂掉了。这样,就带来一个参数叫做队列深度。
Block Devices(RBD),无需使用内核RBD驱动程序(rbd.ko)。该参数包含很多ioengine,如:libhdfs/rdma等rwmixwrite=30 在混合读写的模式下,写占30%
group_reporting 关于显示结果的,汇总每个进程的信息。此外lockmem=1g 只使用1g内存进行测试。zero_buffers 用0初始化系统buffer。nrfiles=8 每个进程生成文件的数量。
磁盘读写常用测试点:
1. Read=100% Ramdon=100% rw=randread (100%随机读)
2. Read=100% Sequence=100% rw=read (100%顺序读)
3. Write=100% Sequence=100% rw=write (100%顺序写)
4. Write=100% Ramdon=100% rw=randwrite (100%随机写)
5. Read=70% Sequence=100% rw=rw, rwmixread=70, rwmixwrite=30(70%顺序读,30%顺序写)
6. Read=70% Ramdon=100% rw=randrw, rwmixread=70, rwmixwrite=30(70%随机读,30%随机写)
————————————————
声明:本文为优快云博主「亚历山大的陀螺」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/don_chiang709/article/details/92628623
[root@localhost ~]# fio
--debug=options Enable debug logging. May be one/more of:
process,file,io,mem,blktrace,verify,random,parse,
diskutil,job,mutex,profile,time,net,rate,compress,
steadystate,helperthread,zbd
--parse-only Parse options only, don't start any IO
--merge-blktrace-only Merge blktraces only, don't start any IO
--output Write output to file
--bandwidth-log Generate aggregate bandwidth logs
--minimal Minimal (terse) output
--output-format=type Output format (terse,json,json+,normal)
--terse-version=type Set terse version output format (default 3, or 2 or 4)
--version Print version info and exit
--help Print this page
--cpuclock-test Perform test/validation of CPU clock
--crctest=[type] Test speed of checksum functions
--cmdhelp=cmd Print command help, "all" for all of them
--enghelp=engine Print ioengine help, or list available ioengines
--enghelp=engine,cmd Print help for an ioengine cmd
--showcmd Turn a job file into command line options
--eta=when When ETA estimate should be printed
May be "always", "never" or "auto"
--eta-newline=t Force a new line for every 't' period passed
--status-interval=t Force full status dump every 't' period passed
--readonly Turn on safety read-only checks, preventing writes
--section=name Only run specified section in job file, multiple sections can be specified
--alloc-size=kb Set smalloc pool to this size in kb (def 16384)
--warnings-fatal Fio parser warnings are fatal
--max-jobs=nr Maximum number of threads/processes to support
--server=args Start a backend fio server
--daemonize=pidfile Background fio server, write pid to file
--client=hostname Talk to remote backend(s) fio server at hostname
--remote-config=file Tell fio server to load this local job file
--idle-prof=option Report cpu idleness on a system or percpu basis
(option=system,percpu) or run unit work
calibration only (option=calibrate)
--trigger-file=file Execute trigger cmd when file exists
--trigger-timeout=t Execute trigger at this time
--trigger=cmd Set this command as local trigger
--trigger-remote=cmd Set this command as remote trigger
--aux-path=path Use this path for fio state generated files
命令示例
[root@localhost ~]# fio --enghelp=libaio
userspace_reap : Use alternative user-space reap implementation
hipri : Use polled IO completions
查看之前的fio命令
history |grep fio
fio 运行示例
[root@localhost ~]# fio --name=mytest --filename=/dev/sdb --direct=1 --ba=4k --rw=randread --bs=4k --size=100% -numjobs=1 --runtime=10 --ioengine=libaio --group_reporting --iodepth=32
mytest: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=32
fio-3.14
Starting 1 process
Jobs: 1 (f=1): [r(1)][100.0%][r=476KiB/s][r=119 IOPS][eta 00m:00s]
mytest: (groupid=0, jobs=1): err= 0: pid=67228: Mon Jul 13 13:14:23 2020
read: IOPS=124, BW=496KiB/s (508kB/s)(5100KiB/10273msec)
slat (nsec): min=6239, max=52337, avg=12067.39, stdev=2543.50
clat (msec): min=11, max=1059, avg=257.08, stdev=222.10
lat (msec): min=11, max=1059, avg=257.10, stdev=222.10
clat percentiles (msec):
| 1.00th=[ 16], 5.00th=[ 24], 10.00th=[ 34], 20.00th=[ 63],
| 30.00th=[ 100], 40.00th=[ 146], 50.00th=[ 197], 60.00th=[ 268],
| 70.00th=[ 334], 80.00th=[ 414], 90.00th=[ 550], 95.00th=[ 718],
| 99.00th=[ 1028], 99.50th=[ 1036], 99.90th=[ 1053], 99.95th=[ 1062],
| 99.99th=[ 1062]
bw ( KiB/s): min= 184, max= 616, per=100.00%, avg=496.85, stdev=84.80, samples=20
iops : min= 46, max= 154, avg=124.10, stdev=21.21, samples=20
lat (msec) : 20=2.59%, 50=13.88%, 100=13.80%, 250=27.61%, 500=29.88%
lat (msec) : 750=7.84%, 1000=2.90%, 2000=1.49%
cpu : usr=0.34%, sys=0.19%, ctx=1276, majf=0, minf=64
IO depths : 1=0.1%, 2=0.2%, 4=0.3%, 8=0.6%, 16=1.3%, 32=97.6%, >=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=99.9%, 8=0.0%, 16=0.0%, 32=0.1%, 64=0.0%, >=64=0.0%
issued rwts: total=1275,0,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=32
Run status group 0 (all jobs):
READ: bw=496KiB/s (508kB/s), 496KiB/s-496KiB/s (508kB/s-508kB/s), io=5100KiB (5222kB), run=10273-10273msec
Disk stats (read/write):
sdb: ios=1254/0, merge=0/0, ticks=315621/0, in_queue=321825, util=98.64%
参数解析:
- io = 处理了多少io数据
- bw = 平均io带宽
- runt = 线程运行时间
- slat = 提交延迟,提交IO到kernel所花的时间
- clat = 完成延迟,提交到kernel后花的时间
- lat = 响应时间
- cpu = cpu占用率
- IO depths = IO 队列深度
- IO submit = 单个IO要提交的IO数
- IO complete = Like the above submit numbers, but for completions instead.
- IO issued rwts = The number if read/write request issued, and how many of them were short.
- merge= = 总共发生的IO合并数
- in_queue = 花费在队列上的时间。
- util = 磁盘利用率