分散式系統ceph測試
一 FIO
FIO測試IOPS非常好的工具,用來對硬體進行壓力測試和驗證,支援13中不同的I/O引擎
1 FIO安裝
[[email protected] ~]# wget http://brick.kernel.dk/snaps/fio-2.0.7.tar.gz
[[email protected] ~]# yum install libaio-devel -y
[[email protected] ~]# cd fio-2.0.7/
[[email protected] fio-2.0.7]# make
[[email protected] ~]# fdisk -l
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ceph--01c3a345--e83d--4495--89d3--a25f01be6cf5-osd--block--6909d49d--67cf--472b--8211--656fa8b06687: 21.5 GB, 21470642176 bytes, 41934848 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
1.2 FIO引數說明
-filename=/dev/sdb 測試檔名稱,通常選用需要測試的盤的data目錄,如果沒有/dev/sdb1則選擇/dev/sdb
-direct=1 測試過程繞過機器自帶的buffer.使測試結果更真實
rw=ranwrite 測試隨機寫的I/O
rw=randrw 測試隨機寫和讀的I/OS
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關於顯示結果的,彙總每個程序的資訊。
lockmem=1g 只使用1g記憶體進行測試
zero_buffers 用0初始化系統buffer
nrfiles=8 每個程序生成檔案的數量
[[email protected] ~]# fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=1G -numjobs=1 -runtime=100 -group_reporting -name=mytest
下列引數可以根據上面引數說明進行調整
[[email protected] ~]# cat fio_test.sh
#隨機讀
fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=1G -numjobs=1 -runtime=100 -group_reporting -name=mytest
#順序讀
fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=16k -size=2G -numjobs=30 -runtime=1000 -group_reporting -name=mytest
#隨機寫
fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=2G -numjobs=30 -runtime=1000 -group_reporting -name=mytest
#順序寫
fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=2G -numjobs=30 -runtime=1000 -group_reporting -name=mytest
#混合隨機讀寫
fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=2G -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop
#實際測試範例
fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=2G -numjobs=30 -runtime=100 -group_reporting -name=mytest1
[[email protected] ~]#
壓力測試fio方式方案,進行10000全累加 之後再除以10000,求平均值,裡面會有read,write引數
[[email protected] ~]# fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=1G -numjobs=1 -runtime=100 -group_reporting -name=mytest | grep io=
read : io=1024.0MB, bw=287045KB/s, iops=17940 , runt= 3653msec
READ: io=1024.0MB, aggrb=287045KB/s, minb=287045KB/s, maxb=287045KB/s, mint=3653msec, maxt=3653msec
write: io=803600KB, bw=8031.4KB/s, iops=501 , runt=100058msec
二 netperf
安裝netperf下載netperf-2.7.0
https://pan.baidu.com/s/1mijg6y0
下載之後,在所有的測試機器都需要安裝
netperf-2.7.0.tar
[[email protected] ~]# tar -xvf netperf-2.7.0.tar
[[email protected] ~]# cd netperf-2.7.0/
[[email protected] netperf-2.7.0]# ./configure && make && make install
[[email protected] ~]# scp -r netperf-2.7.0 [email protected]:/root/
[[email protected] ~]# scp -r netperf-2.7.0 [email protected]:/root/
在ceph1機器上啟動server程序(測試對稱多處理結構SMP即多核)
[[email protected] ~]# netserver
Starting netserver with host 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC
[[email protected] ~]# ps -ef | grep netperf
root 8722 1544 0 23:10 pts/0 00:00:00 grep --color=auto netperf
[[email protected] ~]# netstat -lnp | grep 12865
tcp6 0 0 :::12865 :::* LISTEN 8699/netserver
TCP_STREAM sockbuf 8192(Mbits/s)測試send size(10,32,64,100,128,256,512,1000,1024,1280,1448,1472,2048,8192,10000,32768,65536)
TCP_STREAM, sockbuf 65536 (Mbits/s)測試send size(10,32,64,100,128,256,512,1000,1024,1280,1448,1472,2048,8192,10000,32768,65536)
UDP_STREAM, sockbuf 200000 (Mbits/s)測試send size(10,32,64,100,128,256,512,1000,1024,1280,1448,1472,2048,8192,10000,32768,65507)
TCP_RR (Transactions/second)測試send size(1,10,32,64,100,128,256,512,1000,1024,1280,1448,1472,2048,8192)
UDP_RR(Transactions/second) 測試send size(1,10,32,64,100,128,256,512,1000,1024,1280,1448,1472,2048,8192)
SCTP_STREAM, sockbuf65536(Mbits/s)send size(10,32,64,100,128,256,512 1000,1024,1280,1448,1472,2048,8192,10000,32768,65536)
SCTP_STREAM, sockbuf 200000 (Mbits/s)send size(10,32,64,100,128,256,512,1000,1024,1280,1448,1472,2048,8192,10000,32768,65536)
SCTP_RR, sockbuf 65536 (Transactions/second) send size(1,10,32,64,100,128,256,512,1000,1280,1448,1472,2048,8192)
在ceph2機器上啟動server 程序,下面例子測試TCP_STREAM
[[email protected] ~]# netperf -H 192.168.229.130 -l 10 -t TCP_STREAM
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.229.130 () port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
87380 16384 16384 10.01 1790.95
即測試請求/應答(request/response)網路流量的效能
1 TCP_RR
[[email protected] ~]# netperf -H 192.168.229.130 -l 10 -t TCP_RR
2 TCP_CRR
[[email protected] ~]# netperf -H 192.168.229.130 -l 10 -t TCP_CRR
3 UDP_RR
[[email protected] ~]# netperf -H 192.168.229.130 -l 10 -t UDP_RR
三 Iperf
Iperf是一個網路效能測試工具。可以測試TCP和UDP頻寬質量,可以測量最大TCP頻寬,具有多種引數和UDP特性,可以報告頻寬,延遲抖動和資料包丟失
安裝方式: yum install epel-release -y && yum install iperf -y
-s 以server模式啟動。#iperf -s
-c host以client模式啟動。host是server端地址。#iperf -c serverip
通用引數:
-f [kmKM] 分別表示以Kbits, Mbits, KBytes, MBytes顯示報告,預設以Mbits為單位,#iperf -c 192.168.100.6 -f K
-i sec 以秒為單位顯示報告間隔,#iperf -c 192.168.100.6 -i 2
-l 緩衝區大小,預設是8KB,#iperf -c 192.168.100.6 -l 64
-m 顯示tcp最大mtu值
-o 將報告和錯誤資訊輸出到檔案#iperf -c 192.168.100.6 -o ciperflog.txt
-p 指定伺服器端使用的埠或客戶端所連線的埠#iperf -s -p 5001;iperf -c 192.168.100.55 -p 5001
-u 使用udp協議
-w 指定TCP視窗大小,預設是8KB
-B 繫結一個主機地址或介面(當主機有多個地址或介面時使用該引數)
-C 相容舊版本(當server端和client端版本不一樣時使用)
-M 設定TCP資料包的最大mtu值
-N 設定TCP不延時
-V 傳輸ipv6資料包
server專用引數:
-D 以服務方式執行。#iperf -s -D
-R 停止iperf服務。針對-D,#iperf -s -R
client端專用引數:
-d 同時進行雙向傳輸測試
-n 指定傳輸的位元組數,#iperf -c 192.168.100.6 -n 1024000
-r 單獨進行雙向傳輸測試
-t 測試時間,預設20秒,#iperf -c 192.168.100.6 -t 5
-F 指定需要傳輸的檔案
-T 指定ttl值
測試方法
[[email protected] ~]# iperf -s -d
WARNING: option -d is not valid for server mode
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[ 4] local 192.168.229.130 port 5001 connected with 192.168.229.131 port 35716
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 0.0 sec 1.00 MBytes 590 Mbits/sec
[ 4] local 192.168.229.130 port 5001 connected with 192.168.229.131 port 35718
[ 4] 0.0- 0.1 sec 9.88 MBytes 1.42 Gbits/sec
[[email protected] ~]# iperf -c 192.168.229.130 -n 102400
------------------------------------------------------------
Client connecting to 192.168.229.130, TCP port 5001
TCP window size: 230 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.229.131 port 35720 connected with 192.168.229.130 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 0.0 sec 128 KBytes 0.00 bits/sec
[[email protected] ~]# iperf -c 192.168.229.130 -n 1024000000
------------------------------------------------------------
Client connecting to 192.168.229.130, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.229.131 port 35722 connected with 192.168.229.130 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 3.9 sec 977 MBytes 2.12 Gbits/sec
[[email protected] ~]# iperf -c 192.168.229.130 -t 100
------------------------------------------------------------
Client connecting to 192.168.229.130, TCP port 5001
TCP window size: 230 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.229.131 port 35724 connected with 192.168.229.130 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-100.0 sec 26.0 GBytes 2.23 Gbits/sec
[[email protected] ~]#
可以用主機名測試不用IP地址
[[email protected] ~]# iperf -c ceph1 -t 1
------------------------------------------------------------
Client connecting to ceph1, TCP port 5001
TCP window size: 178 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.229.131 port 35738 connected with 192.168.229.130 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 265 MBytes 2.21 Gbits/sec
[[email protected] ~]#
四 rados效能測試
4.1 引數說明
該工具的語法為:rados bench -p <pool_name> <seconds> <write|seq|rand> -b <block size> -t --no-cleanup
pool_name:測試所針對的儲存池
seconds:測試所持續的秒數
<write|seq|rand>:操作模式,write:寫,seq:順序讀;rand:隨機讀
-b:block size,即塊大小,預設為 4M
-t:讀/寫並行數,預設為 16
--no-cleanup 表示測試完成後不刪除測試用資料。在做讀測試之前,需要使用該引數來執行一遍寫測試來產生測試資料,在全部測試結束後可以執行 rados -p <pool_name> cleanup 來清理所有測試資料。
4.2 rados 寫操作
[[email protected] ~]# rados bench -p fs_data 1 write --no-cleanup
hints = 1
Maintaining 16 concurrent writes of 4194304 bytes to objects of size 4194304 for up to 1 seconds or 0 objects
Object prefix: benchmark_data_ceph1_12897
sec Cur ops started finished avg MB/s cur MB/s last lat(s) avg lat(s)
0 16 16 0 0 0 - 0
1 16 32 16 59.6521 64 0.677269 0.552556
Total time run: 1.33617
Total writes made: 32
Write size: 4194304
Object size: 4194304
Bandwidth (MB/sec): 95.7964
Stddev Bandwidth: 0
Max bandwidth (MB/sec): 64
Min bandwidth (MB/sec): 64
Average IOPS: 23
Stddev IOPS: 0
Max IOPS: 16
Min IOPS: 16
Average Latency(s): 0.64773
Stddev Latency(s): 0.313858
Max latency(s): 1.33553
Min latency(s): 0.174907
[[email protected] ~]#
4.3 順序讀
[[email protected] ~]# rados bench -p fs_data 1 seq
hints = 1
sec Cur ops started finished avg MB/s cur MB/s last lat(s) avg lat(s)
0 16 17 1 226.336 -1 0.0153576 0.0153576
Total time run: 0.529385
Total reads made: 32
Read size: 4194304
Object size: 4194304
Bandwidth (MB/sec): 241.79
Average IOPS: 60
Stddev IOPS: 0
Max IOPS: 31
Min IOPS: 31
Average Latency(s): 0.237907
Max latency(s): 0.5281
Min latency(s): 0.00636216
[[email protected] ~]#
4.4 隨機讀
[[email protected] ~]# rados bench -p fs_data 1 rand
hints = 1
sec Cur ops started finished avg MB/s cur MB/s last lat(s) avg lat(s)
0 16 17 1 248.167 -1 0.011158 0.011158
1 16 89 73 287.214 288 0.403247 0.179399
Total time run: 1.27151
Total reads made: 89
Read size: 4194304
Object size: 4194304
Bandwidth (MB/sec): 279.983
Average IOPS: 69
Stddev IOPS: 0
Max IOPS: 72
Min IOPS: 72
Average Latency(s): 0.223529
Max latency(s): 0.660905
Min latency(s): 0.00182668
[[email protected] ~]#
4.5清除歷史測試資料
rados -p fs_data cleanup
五 rados load-gen
RADOS效能測試: 使用rados load-gen工具
# rados -p rbd load-gen
--num-objects 初始生成測試用的物件數,預設 200
--min-object-size 測試物件的最小大小,預設 1KB,單位byte
--max-object-size 測試物件的最大大小,預設 5GB,單位byte
--min-op-len 壓測IO的最小大小,預設 1KB,單位byte
--max-op-len 壓測IO的最大大小,預設 2MB,單位byte
--max-ops 一次提交的最大IO數,相當於iodepth
--target-throughput 一次提交IO的歷史累計吞吐量上限,預設 5MB/s,單位B/s
--max-backlog 一次提交IO的吞吐量上限,預設10MB/s,單位B/s
--read-percent 讀寫混合中讀的比例,預設80,範圍[0, 100]
--run-length 執行的時間,預設60s,單位秒
六IO監控工具
iostat主要用於監控系統裝置的IO負載情況,iostat首次執行時顯示自系統啟動開始的各項統計資訊,之後執行iostat將顯示自上次執行該命令以後的統計資訊。使用者可以通過指
定統計的次數和時間來獲得所需的統計資訊。
iostat -d -k 2
引數-d 表示,顯示裝置(磁碟)使用狀態,-k某些使用block為單位的列強制使用kilobytes為單位;
2表示,資料顯示每隔2秒重新整理一次
[[email protected] ~]# iostat -d -k 1 10
Linux 3.10.0-862.el7.x86_64 (ceph2) 12/18/2018 _x86_64_ (1 CPU)
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
fd0 0.00 0.00 0.00 48 0
sda 7.32 23.41 218.97 820102 7670958
sdb 2.17 24.01 129.89 841084 4550488
sdc 1.67 6.26 59.65 219428 2089592
dm-0 2.45 23.83 129.89 834972 4550260
dm-1 1.87 6.09 59.64 213444 2089364
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
fd0 0.00 0.00 0.00 0 0
sda 1.98 0.00 16.83 0 17
sdb 0.00 0.00 0.00 0 0
sdc 0.00 0.00 0.00 0 0
tps:每秒的傳輸次數,一次傳輸意思是一次I/O請求。多個邏輯請求可能會被合併為一次I/O請求。
KB_read/s:每秒從裝置(drive expressed)讀取的資料量
KB_wrth/s:每秒向裝置(driveexpressed)寫入的資料量
KB_read:讀取的總資料量
KB_wrth:寫入的總資料量;if 這些單位都是Kilobytes: