fio
一、安裝
http://freshmeat.sourceforge.net/projects/fio上下載fio-2.1.10.tar.gz,版本包見附件
解壓
tar ?-xvf ?fio-3.3.tar.gz
cd ?fio-3.3
執行命令:
./configure
make
make install
安裝libaio-devel
yum install libaio-devel
重新執行:
#./configure
#make
#make install
直接執行fio測試。
#fio -ioengine=libaio -filename=fiofile -bs=20k -direct=1 -iodepth=4 -thread -size=300g -rw=randwrite -name=20k_randwrite -numjobs=2 -group_reporting
如果有報錯:是因為沒裝libaio-devel
檢查libaio和rbd是否存在,存在表示已經安裝了libaio和rdb,下面可以看到所有引擎
[root@ceph1 home]# fio --enghelp
Available IO engines:
cpuio
mmap
sync
psync
vsync
pvsync
null
net
netsplice
libaio
posixaio
falloc
e4defrag
splice
rbd
sg
binject
二、fio引擎介紹
參考網址:
http://blog.yufeng.info/archives/677
ioengine=str
Defines how the job issues I/O. The following types are defined:
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. This ioengine defines engine specific options.
posixaio
POSIX asynchronous I/O using aio_read(3) and aio_write(3).
solarisaio
Solaris native asynchronous I/O.
windowsaio
Windows native asynchronous I/O.
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. May be either synchronous using the SG_IO ioctl, or if the target is an sg character device, we use read(2) and write(2) for asynchronous I/O.
null
Doesn’t transfer any data, just pretends to. Mainly used to exercise fio itself and for debugging and testing purposes.
net
Transfer over the network. The protocol to be used can be defined with the protocol parameter. Depending on the protocol, filename, hostname, port, or listen must be specified. This ioengine defines engine specific options.
netsplice
Like net, but uses splice(2) and vmsplice(2) to map data and send/receive. This ioengine defines engine specific options.
cpuio
Doesn’t transfer any data, but burns CPU cycles according to cpuload and cpucycles parameters.
guasi
The GUASI I/O engine is the Generic Userspace Asynchronous Syscall Interface approach to asycnronous I/O.
個別中文解釋:
默認值是sync同步阻塞I/O,
libaio是Linux的native異步I/O
io引擎使用pync方式
sync:采用read,write,使用fseek定位讀寫位置。
psync:采用pread、pwrite進行文件讀寫操作
vsync:采用readv(2) orwritev(2)進行文件讀寫操作
三、各引擎使用方法
1、fio-vsync:
vsync:采用readv(2) orwritev(2)進行文件讀寫操作
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=vsync -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file
2、sync:采用read,write,使用fseek定位讀寫位置。同步阻塞I/O,
fio -filename=/mnt/data/111.log -ioengine=sync -direct=1 -rw=randwrite -bs=8k -size=1G -numjobs=8 -runtime=10-group_reporting -name=fio_test
3、psync對磁盤進行讀寫(lsblk),如下查出來就是/dev/vdb
[root@host111 data]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 75G 0 disk
├─vda1 252:1 0 200M 0 part /boot
└─vda2 252:2 0 74.8G 0 part
├─systemvg-swaplv (dm-0) 253:0 0 10G 0 lvm [SWAP]
├─systemvg-rootlv (dm-1) 253:1 0 8G 0 lvm /
├─systemvg-homelv (dm-2) 253:2 0 2G 0 lvm /home
├─systemvg-varlv (dm-3) 253:3 0 6G 0 lvm /var
├─systemvg-tmplv (dm-4) 253:4 0 2G 0 lvm /tmp
├─systemvg-optlv (dm-5) 253:5 0 30G 0 lvm /opt
└─systemvg-usrlv (dm-6) 253:6 0 10G 0 lvm /usr
vdb 252:16 0 100G 0 disk /mysql
vdc 252:32 0 500G 0 disk /mnt/data
或者對一個文件進行寫:
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file
4、posixaio:glibc POSIX asynchronous I/O using aio_read(3) and aio_write(3).
fio -name=/mnt/data/11.log -direct=0 -iodepth=96 -rw=randread -ioengine=posixaio -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting
5、libaio:Linux native asynchronous I/O.Linux的native異步I/O
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file
6、mmap:File is memory mapped with mmap(2) and data copied using memcpy(3).
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=mmap -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file
7、splice: splice(2) is used to transfer the data and vmsplice(2) to transfer data from user-space to the kernel.
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=splice -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file
8、falloc
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=falloc -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file
9、pvsync:
fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=pvsync -bs=4k -size=1G -numjobs=64 -runtime=10 -group_reporting -name=file
引擎參照:沒有舉例的可能執行有問題,或者是針對塊存儲的
binject:只針對block devices
sg:針對塊
splice
e4defrag:Option inplace: missing long option name
falloc
posixaio
libaio
net:fio: network IO can't be random
netsplice
null
sync
psync
vsync
pvsync
mmap
cpuio
syslet-rw
使用配置文件執行:
參考:https://segmentfault.com/a/1190000003880571
如下為rdb測試的配置文件:執行:fio 256k-randread.fio
[root@host111 fio_cfg]# vi 256k-randread.fio
[randread-256k]
description="randread test with block size of 256k-test-poolimages1"
ioengine=rbd
clientname=admin
pool=test-pool
rbdname=test-poolimages1
iodepth=8
runtime=300
rw=randread
bs=256k
numjobs=1
size=5g
#write_iops_log=write_iops
#log_avg_msec=1000
#filename=/data/osd.0/1.txt
write_bw_log=rw
write_lat_log=rw
write_iops_log=rw
[randread-256k]
description="randread test with block size of 256k-test-poolimages2"
ioengine=rbd
clientname=admin
pool=test-pool
rbdname=test-poolimages2
iodepth=8
runtime=300
rw=randread
bs=256k
numjobs=1
size=5g
#write_iops_log=write_iops
#log_avg_msec=1000
#filename=/data/osd.0/1.txt
write_bw_log=rw
write_lat_log=rw
write_iops_log=rw
四、補充
1、安裝插件:
yum install gnuplot
2.輸出bw,lat和iops數據并畫圖
fio安裝完后自帶有一個高級腳本fio_generate_plots能夠根據fio輸出的數據進行畫圖。操作流程如下:
fio的輸出日志主要包含三種:bw,lat和iops,設置這三種的參數如下:
write_bw_log=rw
w
write_lat_log=rw
w
write_iops_log=rw
如:fio -filename=/mnt/data/112.log -direct=1 -iodepth 1 -thread -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs=1 -runtime=10 -group_reporting -name=file -write_bw_log=rww -write_lat_log=rww -write_iops_log=rw
最后生成:
[root@host111 fio_cfg]# ls
psync randrw.fio read.fio rw_iops.1.log rww_clat.1.log rww_slat.1.log
randread.fio randwrite.fio rw.fio rww_bw.1.log rww_lat.1.log write.fio
需要將$1.log改為*.log
[root@host111 fio_cfg]# mv rw_iops.1.log rw_iops.log
[root@host111 fio_cfg]# mv rww_bw.1.log rww_bw.log
[root@host111 fio_cfg]# mv rww_clat.1.log rww_clat.log
[root@host111 fio_cfg]# mv rww_lat.1.log rww_lat.log
[root@host111 fio_cfg]# mv rww_slat.1.log rww_slat.log
[root@host111 fio_cfg]# ls
psync randrw.fio read.fio rw_iops.log rww_clat.log rww_slat.log
randread.fio randwrite.fio rw.fio rww_bw.log rww_lat.log write.fio
或者使用下面腳本進行修改:
這里需要強調的一點是,后面接的參數rw,是輸出日志文件名的prefix,如最終會生成的日志文件如下:
rw_iops.log
rw_clat.log
rw_slat.log
rw_lat.log
rw_bw.log
這個參數在后面畫圖的時候也要用到。
for i in clat lat slat bw iops;do mv rbd_$i.1.log rbd_$i.log;done
3、畫圖
前提是還需要安裝好gnuplot,然后使用下面的命令即可自動畫圖:
root@ubuntu:/tmp> fio_generate_plots bw
發現沒有,fio_generate_plots接受的唯一參數就是這個日志文件名的prefix。
本例中生成的圖片文件有:
bw-bw.svg?
bw-clat.svg?
bw-iops.svg?
bw-lat.svg?
bw-slat.svg
下載到本地,需要用谷歌瀏覽器才能打開,圖片軟件打不開
轉載于:https://www.cnblogs.com/AgainstTheWind/p/9869643.html
總結
- 上一篇: 英语角
- 下一篇: 游戏编程十年总结(下)(转)