Linux服务器iops性能测试-fio
?FIO是測試IOPS的非常好的工具,用來對硬件進行壓力測試和驗證,支持13種不同的I/O引擎,包括:sync,mmap, libaio, posixaio, SG v3, splice, null, network, syslet,guasi, solarisaio 等等。
fio 官網(wǎng)地址: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???????? 同上,提定數(shù)據(jù)塊的大小范圍
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內(nèi)存進行測試。
zero_buffers???????????? 用0初始化系統(tǒng)buffer。
nrfiles=8??????????????? 每個進程生成文件的數(shù)量。
?
順序讀:
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后,可能會導致磁盤下的文件損壞,出現(xiàn)Structure needs cleaning錯誤。?
解決辦法(會造成數(shù)據(jù)丟失)參考以下鏈接:
http://www.jb51.net/LINUXjishu/225992.html
?
今天在使用fio進行IO測試的時候,文件系統(tǒng)/home分區(qū)遇到了mount: Structure needs cleaning 報錯。大致情況:
/home分區(qū)是xfs文件系統(tǒng);
執(zhí)行fio進行多進程測試;
測試完畢之后,執(zhí)行du -hs /home/*,部分文件的數(shù)據(jù)提示 “mount: Structure needs cleaning”報錯;
解決方法
可以使用xfs_repair來修復,但是要注意 xfs_repair修復的分區(qū)中的文件都會丟失,即使是du能正常顯示的文件也會丟失。
處理步驟:
umount /home
xfs_repair /home
mount /home
掛載命令也可用: mount /dev/sdc1 /mnt/usbhd1? ? —— 第一個參數(shù)是設備號,第二個參數(shù)是目錄
?
該工具一定要謹慎使用!損壞的數(shù)據(jù)目前還沒辦法恢復!!!
轉載于:https://www.cnblogs.com/willdoop/p/7220747.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結
以上是生活随笔為你收集整理的Linux服务器iops性能测试-fio的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CodeForces 869E Th
- 下一篇: [数位dp] bzoj 3209 花神的