小型計算機系統接口(SCSI,Small Computer System Interface)ios
SAS(Serial Attached SCSI,串列SCSI)git
SCSI 硬盤名稱: sd[a-p]github
sda一、sda2又分別表明不一樣分區(Partition)app
1. 進入/sys/block/sda/queue/, 查看磁盤sda的參數dom
ls -1 /sys/block/sda/queue/ | awk '{cmd="cat "i$0; print i$0; system(cmd) }' i=`pwd`'/'
/sys/block/sda/queue/add_random
1
/sys/block/sda/queue/discard_granularity
0
/sys/block/sda/queue/discard_max_bytes
0
/sys/block/sda/queue/discard_zeroes_data
0
/sys/block/sda/queue/hw_sector_size
512
/sys/block/sda/queue/iosched
cat: /sys/block/sda/queue/iosched: 是一個目錄
/sys/block/sda/queue/iostats
1
/sys/block/sda/queue/logical_block_size
512
/sys/block/sda/queue/max_hw_sectors_kb
32767
/sys/block/sda/queue/max_integrity_segments
0
/sys/block/sda/queue/max_sectors_kb
512
/sys/block/sda/queue/max_segments
128
/sys/block/sda/queue/max_segment_size
65536
/sys/block/sda/queue/minimum_io_size
4096
/sys/block/sda/queue/nomerges
0
/sys/block/sda/queue/nr_requests
128
/sys/block/sda/queue/optimal_io_size
0
/sys/block/sda/queue/physical_block_size
4096
/sys/block/sda/queue/read_ahead_kb
128
/sys/block/sda/queue/rotational
1
/sys/block/sda/queue/rq_affinity
1
/sys/block/sda/queue/scheduler
noop deadline [cfq]
/sys/block/sda/queue/unpriv_sgio
0
/sys/block/sda/queue/write_same_max_bytesasync
scsi設備列表ide
lsscsi -l
[0:0:0:0] disk ATA ST1000DM003-1ER1 CC46 /dev/sda
state=running queue_depth=1 scsi_level=6 type=0 device_blocked=0 timeout=30oop
執行fio命令時,先確保改磁盤沒有數據,否則數據會被覆蓋測試
fio --name=randwrite --rw=randwrite --bs=4k --size=20G --runtime=1200 --ioengine=libaio --iodepth=16 --numjobs=1 --filename=/dev/sda --direct=1 --group_reportingspa
filename=/dev/sda 測試文件名稱,一般選擇須要測試的盤的data目錄。
direct=1 測試過程繞過機器自帶的buffer。使測試結果更真實。
rw=randwrite 測試隨機寫的I/O
rw=randrw 測試隨機寫和讀的I/O
bs=4k 單次io的塊文件大小爲4k
bsrange=512-2048 同上,提定數據塊的大小範圍
size=5g 本次的測試文件大小爲5g,以每次4k的io進行測試。
numjobs=30 本次的測試線程爲30.
runtime=1200 測試時間爲1200秒
ioengine=psync io引擎使用pync方式
rwmixwrite=30 在混合讀寫的模式下,寫佔30%
group_reporting 彙總每一個進程的信息。
lockmem=1g 只使用1g內存進行測試。
zero_buffers 用0初始化系統buffer。
nrfiles=8 每一個進程生成文件的數量。
runtime=int Terminate processing after the specified number of seconds. filename=str fio normally makes up a file name based on the job name, thread number, and file number. If you want to share files between threads in a job or several jobs, specify a filename for each of them to override the default. If the I/O engine is file-based, you can specify a number of files by separating the names with a ':' character. '-' is a reserved name, meaning stdin or stdout, depending on the read/write direction set. iodepth=int Number of I/O units to keep in flight against the file. Note that increasing iodepth beyond 1 will not affect synchronous ioengines (except for small degress when verify_async is in use). Even async engines my impose OS restrictions causing the desired depth not to be achieved. This may happen on Linux when using libaio and not setting direct=1, since buffered IO is not async on that OS. Keep an eye on the IO depth distribution in the fio output to verify that the achieved depth is as expected. Default: 1.
而後觀察iostat輸出
iostat -mtx 2
2018年01月22日 16時54分33秒 avg-cpu: %user %nice %system %iowait %steal %idle 1.01 0.00 0.51 25.25 0.00 73.23 Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 1.50 0.00 3.00 183.50 0.12 0.71 9.09 18.11 101.74 177.67 100.50 5.36 100.00
rrqms:每秒這個設備相關的讀取請求有多少被Merge了(讀取數據時,VFS將請求發到各個FS,若是FS發現不一樣的讀取請求讀取的是相同Block的數據,FS會將這個請求合併Merge)
wrqm/s:每秒這個設備相關的寫入請求有多少被Merge了。
rsec/s:The number of sectors read from the device per second.
wsec/s:The number of sectors written to the device per second.
rKB/s:The number of kilobytes read from the device per second.
wKB/s:The number of kilobytes written to the device per second.
avgrq-sz:The average size (in sectors) of the requests that were issued to the device. (平均請求扇區數)
avgqu-sz: The average queue length of the requests that were issued to the device. (平均請求隊列的長度)
await:每個IO請求的響應時間(隊列時間+服務時間),通常地系統IO響應時間應該低於5ms
svctm:表示平均每次設備I/O操做的服務時間。若是await的值遠高於svctm的值,則表示I/O隊列等待太長。
%util: 在統計時間內全部處理IO時間,除以總共統計時間。
參考: