Install&Config sysbench on CentOS 7 (--without-mysql)

記錄操作過程

1. 安裝相關 lib

# yum -y install git make automake libtool pkgconfig libaio-devel

2. 下載 sysbench source

# git clone https://github.com/akopytov/sysbench
# cd sysbench

3. complie source code ( 預設mysql會安裝,這裡指定不安裝 database 功能測試 )

# ./autogen.sh
# ./configure --without-mysql
# make -j
# make install
# which sysbench
/usr/local/bin/sysbench

 

a. fileio 測試 (參數說明)

# sysbench fileio help
sysbench 1.1.0-ead2689 (using bundled LuaJIT 2.1.0-beta3)

fileio options:
  --file-num=N                  number of files to create [128]
  --file-block-size=N           block size to use in all IO operations [16384]
  --file-total-size=SIZE        total size of files to create [2G]
  --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
  --file-io-mode=STRING         file operations mode {sync,async,mmap} [sync]
  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
  --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]
  --file-fsync-all[=on|off]     do fsync() after each write operation [off]
  --file-fsync-end[=on|off]     do fsync() at the end of test [on]
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]
  --file-rw-ratio=N             reads/writes ratio for combined test [1.5]

a.1 建立測試 file (prepare)

# sysbench fileio --file-num=16 --file-total-size=2G prepare

a.2 測試 io (run)

# sysbench fileio --file-num=16 --file-total-size=2G --file-test-mode=seqwr --time=30 run
sysbench 1.1.0-ead2689 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Extra file open flags: (none)
128 files, 16MiB each
2GiB total file size
Block size 16KiB
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing sequential write (creation) test
Initializing worker threads...

Threads started!


Throughput:
         read:  IOPS=0.00 0.00 MiB/s (0.00 MB/s)
         write: IOPS=22267.54 347.93 MiB/s (364.83 MB/s)
         fsync: IOPS=28504.18

Latency (ms):
         min:                                  0.00
         avg:                                  0.02
         max:                                  5.62
         95th percentile:                      0.03
         sum:                              29234.19

a.3 清除測試所產生出來的檔案 (cleanup)

# sysbench fileio cleanup

a.4 using script

# vim runTest.sh
#!/bin/sh

sysbench fileio cleanup
sysbench fileio --file-num=32 --file-total-size=10G prepare

if [ -z $1 ]; then
  FILEMODE=rndrw
else
  FILEMODE=$1
fi

if [ $? == 0 ]; then
  echo "sysbench fileio --file-num=32 --file-total-size=10G --file-test-mode=$FILEMODE --time=30 run"
  sysbench fileio --file-num=32 --file-total-size=10G --file-test-mode=$FILEMODE --time=30 run
fi

if [ $? == 0 ]; then
  echo "sysbench fileio cleanup"
  sysbench fileio cleanup
fi
# chmod a+x runTest.sh
# ./runTest.sh seqwr

 

參數備註:

fileio:
--file-test-mode=STRING 
  seqwr(順序寫)
  seqrewr(順序讀寫)
  seqrd(順序讀)
  rndrd(隨機讀)
  rndwr(隨機寫)
  rndrw(隨機讀寫)

--file-io-mode=STRING
  default: sync
  sync(同步)
  async(非同步)
  fastmmap(快速mmap)
  slowmmap(慢速mmap)

 

資料來源:

https://github.com/akopytov/sysbench#rhelcentos

如何用sysbench做好IO性能測試 https://www.cnblogs.com/DataArt/p/10099847.html

sysbench壓力測試工具簡介和使用(一) https://www.itread01.com/p/1394061.html

已轉向 blogger 記錄

https://slowlife-notes.blogspot.com