ITPub博客

首页 > 数据库 > MySQL > 测试工具:sysbench

测试工具:sysbench

原创 MySQL 作者:javenzhen 时间:2015-07-19 13:10:13 0 删除 编辑
1、安装

  1. root@pp:/root# mv sysbench-0.5 /usr/local/sysbench
  2. root@pp:/root# cd /usr/local/sysbench/
  3. root@pp:/usr/local/sysbench# ./autogen.sh
  4. root@pp:/usr/local/sysbench# ./configure --with-mysql=/usr/local/percona-mysql --with-mysql-includes=/usr/local/percona-mysql/include --with-mysql-libs=/usr/local/percona-mysql/lib
  5. root@pp:/usr/local/sysbench# make && make install
2、sysbench支持参数

  1. root@pp:/root# sysbench --help
  2. Missing required command argument.
  3. Usage:
  4.   sysbench [general-options]... --test=<test-name> [test-options]... command

  5. General options:
  6.   --num-threads=N number of threads to use [1]
  7.   --max-requests=N limit for total number of requests [10000]
  8.   --max-time=N limit for total execution time in seconds [0]
  9.   --forced-shutdown=STRING amount of time to wait after --max-time before forcing shutdown [off]
  10.   --thread-stack-size=SIZE size of stack per thread [64K]
  11.   --tx-rate=N target transaction rate (tps) [0]
  12.   --report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
  13.   --report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
  14.   --test=STRING test to run
  15.   --debug=[on|off] print more debugging info [off]
  16.   --validate=[on|off] perform validation checks where possible [off]
  17.   --help=[on|off] print help and exit
  18.   --version=[on|off] print version and exit [off]
  19.   --rand-init=[on|off] initialize random number generator [off]
  20.   --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
  21.   --rand-spec-iter=N number of iterations used for numbers generation [12]
  22.   --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
  23.   --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]
  24.   --rand-seed=N seed for random number generator, ignored when 0 [0]
  25.   --rand-pareto-h=N parameter h for pareto distibution [0.2]

  26. Log options:
  27.   --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]
  28.   --percentile=N percentile rank of query response times to count [95]

  29. Compiled-in tests:
  30.   fileio - File I/O test
  31.   cpu - CPU performance test
  32.   memory - Memory functions speed test
  33.   threads - Threads subsystem performance test
  34.   mutex - Mutex performance test

  35. Commands: prepare run cleanup help version

  36. See 'sysbench --test=<name> help' for a list of options for each test.
3、sysbench测试的几个方面

  1. fileio:磁盘IO测试
  2. cpu:cpu性能测试
  3. memory:内存功能和速度测试
  4. threads:线程子系统性能测试
  5. mutex:mutex性能测试
  6. db:数据库基准测试
4、参数详解
4.1、fileio
  1. root@pp:/root# sysbench --test=fileio help
  2. sysbench 0.5: multi-threaded system evaluation benchmark

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

  17. No help available for test 'fileio'.
  1. --file-num=N 代表生成测试文件的数量,默认为128。
  2. --file-block-size=N 测试时所使用文件块的大小,如果想磁盘针对innodb存储引擎进行测试,可以将其设置为16384,即innodb存储引擎页的大小。默认为16384。
  3. --file-total-size=SIZE 创建测试文件的总大小,默认为2G大小。
  4. --file-test-mode=STRING 文件测试模式,包含:seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)
  5. --file-io-mode=STRING 文件操作的模式,sync(同步),async(异步),fastmmap(快速mmap),slowmmap(慢速mmap),默认为sync同步模式。
  6. --file-async-backlog=N 对应每个线程队列的异步操作数,默认为128。
  7. --file-extra-flags=STRING 打开文件时的选项,这是与API相关的参数。
  8. --file-fsync-freq=N 执行fsync()函数的频率。fsync主要是同步磁盘文件,因为可能有系统和磁盘缓冲的关系。 0代表不使用fsync函数。默认值为100。
  9. --file-fsync-all=[on|off] 每执行完一次写操作,就执行一次fsync。默认为off。
  10. --file-fsync-end=[on|off] 在测试结束时执行fsync函数。默认为on。
  11. --file-fsync-mode=STRING 文件同步函数的选择,同样是和API相关的参数,由于多个操作系统对于fdatasync支持不同,因此不建议使用fdatasync。默认为fsync。
  12. --file-merged-requests=N 大多情况下,合并可能的IO的请求数,默认为0。
  13. --file-rw-ratio=N 测试时的读写比例,默认时为1.5,即可3:2。
4.2、cpu

  1. root@pp:/root# sysbench --test=cpu help
  2. sysbench 0.5: multi-threaded system evaluation benchmark

  3. cpu options:
  4.   --cpu-max-prime=N upper limit for primes generator [10000]

  5. No help available for test 'cpu'.
  1. --cpu-max-prime=N 用来选项指定最大的素数,具体参数可以根据CPU的性能来设置,默认为10000
4.3、memory

  1. root@pp:/root# sysbench --test=memory help
  2. sysbench 0.5: multi-threaded system evaluation benchmark

  3. memory options:
  4.   --memory-block-size=SIZE size of memory block for test [1K]
  5.   --memory-total-size=SIZE total size of data to transfer [100G]
  6.   --memory-scope=STRING memory access scope {global,local} [global]
  7.   --memory-hugetlb=[on|off] allocate memory from HugeTLB pool [off]
  8.   --memory-oper=STRING type of memory operations {read, write, none} [write]
  9.   --memory-access-mode=STRING memory access mode {seq,rnd} [seq]

  10. No help available for test 'memory'.
  1.   --memory-block-size=SIZE     测试内存块的大小,默认为1K
  2.   --memory-total-size=SIZE    数据传输的总大小,默认为100G
  3.   --memory-scope=STRING    内存访问的范围,包括全局和本地范围,默认为global
  4.   --memory-hugetlb=[on|off]    是否从HugeTLB池分配内存的开关,默认为off
  5.   --memory-oper=STRING     内存操作的类型,包括read, write, none,默认为write
  6.   --memory-access-mode=STRING    内存访问模式,包括seq,rnd两种模式,默认为seq
4.4、threads

  1. root@pp:/root# sysbench --test=threads help
  2. sysbench 0.5: multi-threaded system evaluation benchmark

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

  6. No help available for test 'threads'.
  1. --thread-yields=N 指定每个请求的压力,默认为1000
  2. --thread-locks=N 指定每个线程的锁数量,默认为8
4.5、mutex

  1. root@pp:/root# sysbench --test=mutex help
  2. sysbench 0.5: multi-threaded system evaluation benchmark

  3. mutex options:
  4.   --mutex-num=N total size of mutex array [4096]
  5.   --mutex-locks=N number of mutex locks to do per thread [50000]
  6.   --mutex-loops=N number of empty loops to do inside mutex lock [10000]

  7. No help available for test 'mutex'.
  1. --mutex-num=N 数组互斥的总大小。默认是4096
  2. --mutex-locks=N 每个线程互斥锁的数量。默认是50000
  3. --mutex-loops=N 内部互斥锁的空循环数量。默认是10000
5、sysbench-0.5的变化

  1. root@pp:/usr/local/sysbench/sysbench/tests/db# ll
  2. total 80
  3. -rw-r--r--. 1 root root 3652 Jun 11 20:10 common.lua
  4. -rw-r--r--. 1 root root 340 Jun 11 20:10 delete.lua
  5. -rw-r--r--. 1 root root 830 Jun 11 20:10 insert.lua
  6. -rw-r--r--. 1 root root 12370 Jul 18 10:40 Makefile
  7. -rw-r--r--. 1 root root 1020 Jun 11 20:10 Makefile.am
  8. -rw-r--r--. 1 root root 11717 Jul 17 22:02 Makefile.in
  9. -rw-r--r--. 1 root root 2959 Jun 11 20:10 oltp.lua
  10. -rw-r--r--. 1 root root 342 Jun 11 20:10 oltp_simple.lua
  11. -rw-r--r--. 1 root root 425 Jun 11 20:10 parallel_prepare.lua
  12. -rw-r--r--. 1 root root 343 Jun 11 20:10 select.lua
  13. -rw-r--r--. 1 root root 3996 Jun 11 20:10 select_random_points.lua
  14. -rw-r--r--. 1 root root 4098 Jun 11 20:10 select_random_ranges.lua
  15. -rw-r--r--. 1 root root 343 Jun 11 20:10 update_index.lua
  16. -rw-r--r--. 1 root root 552 Jun 11 20:10 update_non_index.lua

从sysbench-0.5开始,oltp测试结合了lua脚本,不需要修改源码,通过自定义lua脚本就可以实现不同业务类型的测试。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12219480/viewspace-1739459/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-01-27

  • 博文量
    41
  • 访问量
    93832