1、安装
-
root@pp:/root# mv sysbench-0.5 /usr/local/sysbench
-
root@pp:/root# cd /usr/local/sysbench/
-
root@pp:/usr/local/sysbench# ./autogen.sh
-
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
-
root@pp:/usr/local/sysbench# make && make install
2、sysbench支持参数
-
root@pp:/root# sysbench --help
-
Missing required command argument.
-
Usage:
-
sysbench [general-options]... --test=<test-name> [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 [64K]
-
--tx-rate=N target transaction rate (tps) [0]
-
--report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
-
--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. []
-
--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 [off]
-
--rand-init=[on|off] initialize random number generator [off]
-
--rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]
-
--rand-spec-iter=N number of iterations used for numbers generation [12]
-
--rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1]
-
--rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]
-
--rand-seed=N seed for random number generator, ignored when 0 [0]
-
--rand-pareto-h=N parameter h for pareto distibution [0.2]
-
-
Log options:
-
--verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]
-
--percentile=N percentile rank of query response times to count [95]
-
-
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
-
-
Commands: prepare run cleanup help version
-
-
See 'sysbench --test=<name> help' for a list of options for each test.
3、sysbench测试的几个方面
-
fileio:磁盘IO测试
-
cpu:cpu性能测试
-
memory:内存功能和速度测试
-
threads:线程子系统性能测试
-
mutex:mutex性能测试
-
db:数据库基准测试
4、参数详解
4.1、fileio
-
root@pp:/root# sysbench --test=fileio help
-
sysbench 0.5: 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,mmap} [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]
-
-
No help available for test 'fileio'.
-
--file-num=N 代表生成测试文件的数量,默认为128。
-
--file-block-size=N 测试时所使用文件块的大小,如果想磁盘针对innodb存储引擎进行测试,可以将其设置为16384,即innodb存储引擎页的大小。默认为16384。
-
--file-total-size=SIZE 创建测试文件的总大小,默认为2G大小。
-
--file-test-mode=STRING 文件测试模式,包含:seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)。
-
--file-io-mode=STRING 文件操作的模式,sync(同步),async(异步),fastmmap(快速mmap),slowmmap(慢速mmap),默认为sync同步模式。
-
--file-async-backlog=N 对应每个线程队列的异步操作数,默认为128。
-
--file-extra-flags=STRING 打开文件时的选项,这是与API相关的参数。
-
--file-fsync-freq=N 执行fsync()函数的频率。fsync主要是同步磁盘文件,因为可能有系统和磁盘缓冲的关系。 0代表不使用fsync函数。默认值为100。
-
--file-fsync-all=[on|off] 每执行完一次写操作,就执行一次fsync。默认为off。
-
--file-fsync-end=[on|off] 在测试结束时执行fsync函数。默认为on。
-
--file-fsync-mode=STRING 文件同步函数的选择,同样是和API相关的参数,由于多个操作系统对于fdatasync支持不同,因此不建议使用fdatasync。默认为fsync。
-
--file-merged-requests=N 大多情况下,合并可能的IO的请求数,默认为0。
-
--file-rw-ratio=N 测试时的读写比例,默认时为1.5,即可3:2。
4.2、cpu
-
root@pp:/root# sysbench --test=cpu help
-
sysbench 0.5: multi-threaded system evaluation benchmark
-
-
cpu options:
-
--cpu-max-prime=N upper limit for primes generator [10000]
-
-
No help available for test 'cpu'.
-
--cpu-max-prime=N 用来选项指定最大的素数,具体参数可以根据CPU的性能来设置,默认为10000
4.3、memory
-
root@pp:/root# sysbench --test=memory help
-
sysbench 0.5: 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]
-
-
No help available for test 'memory'.
-
--memory-block-size=SIZE 测试内存块的大小,默认为1K
-
--memory-total-size=SIZE 数据传输的总大小,默认为100G
-
--memory-scope=STRING 内存访问的范围,包括全局和本地范围,默认为global
-
--memory-hugetlb=[on|off] 是否从HugeTLB池分配内存的开关,默认为off
-
--memory-oper=STRING 内存操作的类型,包括read, write, none,默认为write
-
--memory-access-mode=STRING 内存访问模式,包括seq,rnd两种模式,默认为seq
4.4、threads
-
root@pp:/root# sysbench --test=threads help
-
sysbench 0.5: 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]
-
-
No help available for test 'threads'.
-
--thread-yields=N 指定每个请求的压力,默认为1000
-
--thread-locks=N 指定每个线程的锁数量,默认为8
4.5、mutex
-
root@pp:/root# sysbench --test=mutex help
-
sysbench 0.5: 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]
-
-
No help available for test 'mutex'.
-
--mutex-num=N 数组互斥的总大小。默认是4096
-
--mutex-locks=N 每个线程互斥锁的数量。默认是50000
-
--mutex-loops=N 内部互斥锁的空循环数量。默认是10000
5、sysbench-0.5的变化
-
root@pp:/usr/local/sysbench/sysbench/tests/db# ll
-
total 80
-
-rw-r--r--. 1 root root 3652 Jun 11 20:10 common.lua
-
-rw-r--r--. 1 root root 340 Jun 11 20:10 delete.lua
-
-rw-r--r--. 1 root root 830 Jun 11 20:10 insert.lua
-
-rw-r--r--. 1 root root 12370 Jul 18 10:40 Makefile
-
-rw-r--r--. 1 root root 1020 Jun 11 20:10 Makefile.am
-
-rw-r--r--. 1 root root 11717 Jul 17 22:02 Makefile.in
-
-rw-r--r--. 1 root root 2959 Jun 11 20:10 oltp.lua
-
-rw-r--r--. 1 root root 342 Jun 11 20:10 oltp_simple.lua
-
-rw-r--r--. 1 root root 425 Jun 11 20:10 parallel_prepare.lua
-
-rw-r--r--. 1 root root 343 Jun 11 20:10 select.lua
-
-rw-r--r--. 1 root root 3996 Jun 11 20:10 select_random_points.lua
-
-rw-r--r--. 1 root root 4098 Jun 11 20:10 select_random_ranges.lua
-
-rw-r--r--. 1 root root 343 Jun 11 20:10 update_index.lua
-
-rw-r--r--. 1 root root 552 Jun 11 20:10 update_non_index.lua
从sysbench-0.5开始,oltp测试结合了lua脚本,不需要修改源码,通过自定义lua脚本就可以实现不同业务类型的测试。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12219480/viewspace-1739459/
,如需转载,请注明出处,否则将追究法律责任。