溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何進(jìn)行sysbench測試

發(fā)布時(shí)間:2021-10-11 10:25:05 來源:億速云 閱讀:181 作者:柒染 欄目:MySQL數(shù)據(jù)庫

如何進(jìn)行sysbench測試,很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

sysbench支持以下幾種測試模式:

1、CPU運(yùn)算性能

2、磁盤IO性能

3、調(diào)度程序性能

4、內(nèi)存分配及傳輸速度

5、POSIX線程性能

6、數(shù)據(jù)庫性能(OLTP基準(zhǔn)測試)

sysbench版本:

[root@127-0-0-1 sysbench]# /u01/opt/sysbench/bin/sysbench --version

sysbench 1.1.0

CPU測試:

[root@127-0-0-1 sysbench]# /u01/opt/sysbench/bin/sysbench cpu --cpu-max-prime=10000 run  

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:

Number of threads: 1

Initializing random number generator from current time

Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:

    events per second:   658.31

Throughput:

    events/s (eps):                      658.3125

    time elapsed:                        10.0013s

    total number of events:              6584

Latency (ms):

         min:                                    1.44

         avg:                                    1.52

         max:                                    3.07

         95th percentile:                        1.52

         sum:                                 9998.21

Threads fairness:

    events (avg/stddev):           6584.0000/0.00

    execution time (avg/stddev):   9.9982/0.00

線程測試:

[root@127-0-0-1 sysbench]# /u01/opt/sysbench/bin/sysbench threads help

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

threads options:

  --thread-yields=N number of yields to do per request [1000]         #每個(gè)請求要執(zhí)行的收益效率[1000]

  --thread-locks=N  number of locks per thread [8]                    #每個(gè)線程的鎖數(shù)[8]

[root@127-0-0-1 sysbench]# /u01/opt/sysbench/bin/sysbench threads --thread-yields=1000 --thread-locks=2 run

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:

Number of threads: 1

Initializing random number generator from current time

Initializing worker threads...

Threads started!

Throughput:

    events/s (eps):                      1349.6979

    time elapsed:                        10.0008s

    total number of events:              13498

Latency (ms):

         min:                                    0.73

         avg:                                    0.74

         max:                                    1.50

         95th percentile:                        0.74

         sum:                                 9996.37

Threads fairness:

    events (avg/stddev):           13498.0000/0.00

    execution time (avg/stddev):   9.9964/0.00

磁盤IO測試:

[root@127-0-0-1 sysbench]# /u01/opt/sysbench/bin/sysbench fileio help

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

fileio options:

  --file-num=N                  number of files to create [128]  #代表生成文件的數(shù)量[128]

  --file-block-size=N           block size to use in all IO operations [16384]  #在所有IO操作中使用的塊大小 [16384]

  --file-total-size=SIZE        total size of files to create [2G]   #要?jiǎng)?chuàng)建的文件的總大小 [2G]

  --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}   #測試模式 {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}

  --file-io-mode=STRING         file operations mode {sync,async,mmap} [sync]       #文件操作模式 {sync,async,mmap} [sync]

  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]   #每個(gè)線程要排隊(duì)的異步操作數(shù) [128]

  --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []  #用于打開文件的附加標(biāo)志列表 {sync,dsync,direct} []

  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]  #執(zhí)行fsync()函數(shù)的頻率。fsync主要是同步磁盤文件,因?yàn)榭赡苡邢到y(tǒng)和磁盤緩沖的關(guān)系。 0代表不使用fsync函數(shù)。默認(rèn)值為100。

  --file-fsync-all[=on|off]     do fsync() after each write operation [off]   #每執(zhí)行完一次寫操作,就執(zhí)行一次fsync。默認(rèn)為off。

  --file-fsync-end[=on|off]     do fsync() at the end of test [on]   #在測試結(jié)束時(shí)執(zhí)行fsync函數(shù)。默認(rèn)為on。

  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]  #文件同步函數(shù)的選擇,同樣是和API相關(guān)的參數(shù),由于多個(gè)操作系統(tǒng)對于fdatasync支持不同,因此不建議使用fdatasync。默認(rèn)為fsync。

  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]   #大多情況下,合并可能的IO的請求數(shù),默認(rèn)為0。

  --file-rw-ratio=N             reads/writes ratio for combined test [1.5]  # 測試時(shí)的讀寫比例,默認(rèn)時(shí)為1.5,即可3:2。

/u01/opt/sysbench/bin/sysbench fileio --threads=16 --file-total-size=2G --file-test-mode=rndrw prepare  #準(zhǔn)備

/u01/opt/sysbench/bin/sysbench fileio --threads=16 --file-total-size=2G --file-fsync-freq=0 --file-test-mode=rndrw run     #運(yùn)行

/u01/opt/sysbench/bin/sysbench fileio --threads=16 --file-total-size=2G --file-test-mode=rndrw cleanup  #清理

[root@127-0-0-1 yoon]# /u01/opt/sysbench/bin/sysbench fileio --threads=16 --file-total-size=2G --file-fsync-freq=0 --file-test-mode=rndrw run

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:

Number of threads: 16

Initializing random number generator from current time

Extra file open flags: (none)

128 files, 16MiB each

2GiB total file size

Block size 16KiB

Number of IO requests: 0

Read/Write ratio for combined random IO test: 1.50

Calling fsync() at the end of test, Enabled.

Using synchronous I/O mode

Doing random r/w test

Initializing worker threads...

Threads started!

Throughput:

         read:  IOPS=383594.04 5993.66 MiB/s (6284.80 MB/s)

         write: IOPS=255729.12 3995.77 MiB/s (4189.87 MB/s)

         fsync: IOPS=122.71

Latency (ms):

         min:                                  0.00

         avg:                                  0.01

         max:                                  1.73

         95th percentile:                      0.03

         sum:                             144444.71

內(nèi)存測試:

[root@127-0-0-1 yoon]# /u01/opt/sysbench/bin/sysbench memory help

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

memory options:

  --memory-block-size=SIZE    size of memory block for test [1K]   #測試內(nèi)存塊的大小 [1K]

  --memory-total-size=SIZE    total size of data to transfer [100G]  #要傳輸?shù)臄?shù)據(jù)的總大小100G]

  --memory-scope=STRING       memory access scope {global,local} [global]  #內(nèi)存訪問范圍 {global,local} [global]

  --memory-hugetlb[=on|off]   allocate memory from HugeTLB pool [off]  #從內(nèi)存池中分配內(nèi)存[off]

  --memory-oper=STRING        type of memory operations {read, write, none} [write]  #存儲(chǔ)操作類型 {read, write, none} [write]

  --memory-access-mode=STRING memory access mode {seq,rnd} [seq]  #存儲(chǔ)器存取方式 {seq,rnd} [seq]

[root@127-0-0-1 yoon]# /u01/opt/sysbench/bin/sysbench memory --memory-total-size=10G --memory-block-size=8K run 

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:

Number of threads: 1

Initializing random number generator from current time

Running memory speed test with the following options:

  block size: 8KiB

  total size: 10240MiB

  operation: write

  scope: global

Initializing worker threads...

Threads started!

Total operations: 1310720 (1077326.35 per second)

10240.00 MiB transferred (8416.61 MiB/sec)

Throughput:

    events/s (eps):                      1077326.3489

    time elapsed:                        1.2166s

    total number of events:              1310720

Latency (ms):

         min:                                    0.00

         avg:                                    0.00

         max:                                    0.02

         95th percentile:                        0.00

         sum:                                  893.01

Threads fairness:

    events (avg/stddev):           1310720.0000/0.00

    execution time (avg/stddev):   0.8930/0.00

OLTP測試:

[root@127-0-0-1 sysbench]# ls

bulk_insert.lua  oltp_delete.lua  oltp_point_select.lua  oltp_read_write.lua    oltp_update_non_index.lua  prepare.log               select_random_ranges.lua

oltp_common.lua  oltp_insert.lua  oltp_read_only.lua     oltp_update_index.lua  oltp_write_only.lua        select_random_points.lua  tests

/u01/opt/sysbench/bin/sysbench /u01/opt/sysbench/share/sysbench/oltp_common.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='root@01.com'  --mysql-db=sbtest  --table-size=5000000 --threads=10  --report-interval=10 prepare

[root@127-0-0-1 sysbench]#  /u01/opt/sysbench/bin/sysbench /u01/opt/sysbench/share/sysbench/oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='root@01.com'  --mysql-db=sbtest  --table-size=5000000 --threads=10  --report-interval=10 --time=120 run

sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:

Number of threads: 10

Report intermediate results every 10 second(s)

Initializing random number generator from current time

Initializing worker threads...

Threads started!

[ 10s ] thds: 10 tps: 824.26 qps: 16498.17 (r/w/o: 11550.29/3298.36/1649.53) lat (ms,95%): 16.71 err/s: 0.00 reconn/s: 0.00

[ 20s ] thds: 10 tps: 938.90 qps: 18778.84 (r/w/o: 13146.36/3754.69/1877.79) lat (ms,95%): 13.95 err/s: 0.00 reconn/s: 0.00

[ 30s ] thds: 10 tps: 969.19 qps: 19383.22 (r/w/o: 13568.10/3876.74/1938.37) lat (ms,95%): 13.70 err/s: 0.00 reconn/s: 0.00

[ 40s ] thds: 10 tps: 1003.32 qps: 20061.71 (r/w/o: 14042.19/4012.88/2006.64) lat (ms,95%): 13.22 err/s: 0.00 reconn/s: 0.00

[ 50s ] thds: 10 tps: 1011.57 qps: 20236.34 (r/w/o: 14166.91/4046.29/2023.14) lat (ms,95%): 13.22 err/s: 0.00 reconn/s: 0.00

[ 60s ] thds: 10 tps: 1115.50 qps: 22309.32 (r/w/o: 15615.94/4462.38/2230.99) lat (ms,95%): 11.87 err/s: 0.00 reconn/s: 0.00

[ 70s ] thds: 10 tps: 1064.13 qps: 21283.06 (r/w/o: 14898.46/4256.33/2128.27) lat (ms,95%): 12.30 err/s: 0.00 reconn/s: 0.00

[ 80s ] thds: 10 tps: 1030.00 qps: 20599.45 (r/w/o: 14419.27/4120.19/2060.00) lat (ms,95%): 12.52 err/s: 0.00 reconn/s: 0.00

[ 90s ] thds: 10 tps: 1056.32 qps: 21127.75 (r/w/o: 14790.22/4224.89/2112.65) lat (ms,95%): 12.30 err/s: 0.00 reconn/s: 0.00

[ 100s ] thds: 10 tps: 1097.38 qps: 21946.72 (r/w/o: 15362.43/4389.52/2194.76) lat (ms,95%): 12.30 err/s: 0.00 reconn/s: 0.00

[ 110s ] thds: 10 tps: 1147.39 qps: 22948.97 (r/w/o: 16063.71/4590.47/2294.79) lat (ms,95%): 11.87 err/s: 0.00 reconn/s: 0.00

[ 120s ] thds: 10 tps: 1110.00 qps: 22200.00 (r/w/o: 15540.00/4440.00/2220.00) lat (ms,95%): 12.08 err/s: 0.00 reconn/s: 0.00

SQL statistics:

    queries performed:

        read:                            1731702

        write:                           494772

        other:                           247386

        total:                           2473860

    transactions:                        123693 (1030.70 per sec.)

    queries:                             2473860 (20614.02 per sec.)

    ignored errors:                      0      (0.00 per sec.)

    reconnects:                          0      (0.00 per sec.)

Throughput:

    events/s (eps):                      1030.7010

    time elapsed:                        120.0086s

    total number of events:              123693

Latency (ms):

         min:                                    4.32

         avg:                                    9.70

         max:                                  185.38

         95th percentile:                       13.22

         sum:                              1199649.68

Threads fairness:

    events (avg/stddev):           12369.3000/304.67

    execution time (avg/stddev):   119.9650/0.00

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI