Login
网站首页 > 文章中心 > 其它

sysbench的安装与使用_with MySQL)

作者:小编 更新时间:2023-08-12 08:24:01 浏览量:300人看过

sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试.

项目主页:?http://sysbench.sourceforge.net/

安装文档http://sysbench.sourceforge.net/docs/#install

一.安装三步骤:

①configure

二.使用

sysbench的安装与使用_with MySQL)-图1

首先,看看sysbench支持哪些功能参数:

[root@monsrv bin]# sysbench --hlp
Unknown option: --hlp.
Usage:
  sysbench [general-options]... --test= [test-options]... command

General options:
  --num-threads=N            number of threads to use [1]
  --max-requests=N           limit for total number of requests [10000]
  --max-time=N               limit for total execution time in seconds [0]
  --forced-shutdown=STRING   amount of time to wait after --max-time before forcing shutdown [off]
  --thread-stack-size=SIZE   size of stack per thread [32K]
  --init-rng=[on|off]        initialize random number generator [off]
  --test=STRING              test to run
  --debug=[on|off]           print more debugging info [off]
  --validate=[on|off]        perform validation checks where possible [off]
  --help=[on|off]            print help and exit
  --version=[on|off]         print version and exit

Compiled-in tests:
  fileio - File I/O test
  cpu - CPU performance test
  memory - Memory functions speed test
  threads - Threads subsystem performance test
  mutex - Mutex performance test
  oltp - OLTP test

Commands: prepare run cleanup help version

See 'sysbench --test= help' for a list of options for each test.

从帮助可以看出,sysbench的测试主要包括以下几个方面:

(1)磁盘io性能

[root@monsrv bin]# sysbench --test=fileio help 
sysbench 0.4.12:  multi-threaded system evaluation benchmark

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,fastmmap,slowmmap} [sync]
  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
  --file-extra-flags=STRING     additional flags to use on opening 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]

参数详解:

示例:

准备工作:

[root@monsrv bin]# sysbench --test=fileio --file-num=16 --file-total-size=2G prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

16 files, 131072Kb each, 2048Mb total
Creating files for the test...

开始测试:

[root@monsrv bin]# sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrd --max-time=180 --max-requests=100000000 --num-threads=16 --init-rng=on --file-num=16 --file-extra-flags=direct --file-fsync-freq=0 --file-block-size=16384 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16
Initializing random number generator from timer.


Extra file open flags: 16384
16 files, 128Mb each
2Gb total file size
Block size 16Kb
Number of random requests for random IO: 100000000
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 read test
Threads started!
Time limit exceeded, exiting...
(last message repeated 15 times)
Done.

Operations performed:  314382 Read, 0 Write, 0 Other = 314382 Total
Read 4.7971Gb  Written 0b  Total transferred 4.7971Gb  (27.288Mb/sec)
 174⑥43 Requests/sec executed

Test execution summary:
total time:                          180.0138s
total number of events:              314382
total time taken by event execution: 2879.5979
per-request statistics:
     min:                                  0.26ms
     avg:                                  9.16ms
     max:                                131.24ms
     approx.  95 percentile:              25.96ms

Threads fairness:
events (avg/stddev):           1964⑧8750/13⑧91
execution time (avg/stddev):   179.9749/0.00

[root@monsrv bin]# sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrd --max-time=180 --max-requests=100000000 --num-threads=16 --init-rng=on --file-num=16 --file-extra-flags=direct --file-fsync-freq=0 --file-block-size=16384 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16
Initializing random number generator from timer.


Extra file open flags: 16384
16 files, 128Mb each
2Gb total file size
Block size 16Kb
Number of random requests for random IO: 100000000
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 read test
Threads started!
Time limit exceeded, exiting...
(last message repeated 15 times)
Done.

Operations performed:  313704 Read, 0 Write, 0 Other = 313704 Total
Read 4.7867Gb  Written 0b  Total transferred 4.7867Gb  (27.229Mb/sec)
 1742.62 Requests/sec executed

Test execution summary:
total time:                          180.0182s
total number of events:              313704
total time taken by event execution: 2879.6401
per-request statistics:
     min:                                  0.25ms
     avg:                                  9.18ms
     max:                                121.35ms
     approx.  95 percentile:              26.06ms

Threads fairness:
events (avg/stddev):           1960⑥5000/8⑤96
execution time (avg/stddev):   179.9775/0.00

测试完成后,需要把测试文件给删掉.

[root@monsrv bin]# sysbench --test=fileio --file-num=16 --file-total-size=2G cleanup
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Removing test files...
[root@monsrv bin]# ls -lrth
total 300K
-rwxr-xr-x 1 root root 293K Oct 15 16:20 sysbench
[root@monsrv bin]# sysbench --test=cpu help
sysbench 0.4.12:  multi-threaded system evaluation benchmark

cpu options:
  --cpu-max-prime=N      upper limit for primes generator [10000]
[root@monsrv bin]# sysbench  --test=memory help
sysbench 0.4.12:  multi-threaded system evaluation benchmark

memory options:
  --memory-block-size=SIZE    size of memory block for test [1K]
  --memory-total-size=SIZE    total size of data to transfer [100G]
  --memory-scope=STRING       memory access scope {global,local} [global]
  --memory-hugetlb=[on|off]   allocate memory from HugeTLB pool [off]
  --memory-oper=STRING        type of memory operations {read, write, none} [write]
  --memory-access-mode=STRING memory access mode {seq,rnd} [seq]
[root@monsrv bin]#  sysbench  --test=threads help
sysbench 0.4.12:  multi-threaded system evaluation benchmark

threads options:
  --thread-yields=N      number of yields to do per request [1000]
  --thread-locks=N       number of locks per thread [8]

参数详解:?

[root@monsrv bin]# sysbench  --test=mutex help 
sysbench 0.4.12:  multi-threaded system evaluation benchmark

mutex options:
  --mutex-num=N        total size of mutex array [4096]
  --mutex-locks=N      number of mutex locks to do per thread [50000]
  --mutex-loops=N      number of empty loops to do inside mutex lock [10000]
[root@monsrv bin]# sysbench --test=oltp help 
sysbench 0.4.12:  multi-threaded system evaluation benchmark

oltp options:
  --oltp-test-mode=STRING         test type to use {simple,complex,nontrx,sp} [complex]
  --oltp-reconnect-mode=STRING    reconnect mode {session,transaction,query,random} [session]
  --oltp-sp-name=STRING           name of store procedure to call in SP test mode []
  --oltp-read-only=[on|off]       generate only 'read' queries (do not modify database) [off]
  --oltp-skip-trx=[on|off]        skip BEGIN/COMMIT statements [off]
  --oltp-range-size=N             range size for range queries [100]
  --oltp-point-selects=N          number of point selects [10]
  --oltp-simple-ranges=N          number of simple ranges [1]
  --oltp-sum-ranges=N             number of sum ranges [1]
  --oltp-order-ranges=N           number of ordered ranges [1]
  --oltp-distinct-ranges=N        number of distinct ranges [1]
  --oltp-index-updates=N          number of index update [1]
  --oltp-non-index-updates=N      number of non-index updates [1]
  --oltp-nontrx-mode=STRING       mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select]
  --oltp-auto-inc=[on|off]        whether AUTO_INCREMENT (or equivalent) should be used on id column [on]
  --oltp-connect-delay=N          time in microseconds to sleep after connection to database [10000]
  --oltp-user-delay-min=N         minimum time in microseconds to sleep after each request [0]
  --oltp-user-delay-max=N         maximum time in microseconds to sleep after each request [0]
  --oltp-table-name=STRING        name of test table [sbtest]
  --oltp-table-size=N             number of records in test table [10000]
  --oltp-dist-type=STRING         random numbers distribution {uniform,gaussian,special} [special]
  --oltp-dist-iter=N              number of iterations used for numbers generation [12]
  --oltp-dist-pct=N               percentage of values to be treated as 'special' (for special distribution) [1]
  --oltp-dist-res=N               percentage of 'special' values to use (for special distribution) [75]

General database options:

  --db-driver=STRING  specifies database driver to use ('help' to get list of available drivers)
  --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]


Compiled-in database drivers:
  mysql - MySQL driver

mysql options:
  --mysql-host=[LIST,...]       MySQL server host [localhost]
  --mysql-port=N                MySQL server port [3306]
  --mysql-socket=STRING         MySQL socket
  --mysql-user=STRING           MySQL user [sbtest]
  --mysql-password=STRING       MySQL password []
  --mysql-db=STRING             MySQL database name [sbtest]
  --mysql-table-engine=STRING   storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb]
  --mysql-engine-trx=STRING     whether storage engine used is transactional or not {yes,no,auto} [auto]
  --mysql-ssl=[on|off]          use SSL connections, if available in the client library [off]
  --myisam-max-rows=N           max-rows parameter for MyISAM tables [1000000]
  --mysql-create-options=STRING additional options passed to CREATE TABLE []
[root@monsrv ~]# sysbench --test=oltp --num-threads=1 --max-requests=80000 --oltp-test-mode=complex --db-driver=mysql --mysql-db=sbtest --mysql-host=192.168.0.155 --mysql-port=1234 --mysql-user=root --mysql-password=aostarit --oltp-nontrx-mode=select --db-ps-mode=disable prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Creating table 'sbtest'...
Creating 10000 records in table 'sbtest'...
[root@monsrv ~]# sysbench --test=oltp --num-threads=1 --max-requests=80000 --oltp-test-mode=complex --db-driver=mysql --mysql-db=sbtest --mysql-host=192.168.0.155 --mysql-port=1234 --mysql-user=root --mysql-password=aostarit --oltp-nontrx-mode=select --db-ps-mode=disable run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 80000
Threads started!
Done.

OLTP test statistics:
    read:                            1120000
    write:                           400000
    other:                           160000
    total:                           1680000
transactions:                        80000  (42.98 per sec.)
deadlocks:                           0      (0.00 per sec.)
read/write requests:                 1520000 (81⑥54 per sec.)
other operations:                    160000 (8⑤95 per sec.)

Test execution summary:
total time:                          1861.5174s
total number of events:              80000
total time taken by event execution: 1860.8692
per-request statistics:
     min:                                 18.08ms
     avg:                                 23.26ms
     max:                                886.62ms
     approx.  95 percentile:              34.32ms

Threads fairness:
events (avg/stddev):           80000.0000/0.00
execution time (avg/stddev):   1860.8692/0.00

[root@monsrv ~]# 

最后就是清除

以上就是土嘎嘎小编为大家整理的sysbench的安装与使用_with MySQL)相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章