-
sysbenchd 安装
sysbench在各平台的安装可以在github上找到,目前是1.0.17版本。
目前我通过Mac的homebrew进行安装的版本为1.0.16。通过homebrew安装发现了一些使用上的问题,没有通过压缩包进行unzip操作后的config文件进行一些配置;在对MySQL进行OLTP测试时,网上大多教程上的OLTP指令调用无法正确执行,可能是网上大多版本低于1.0(多为0.5)的缘故,也可能是brew的文件结构与压缩包的结构不同,已通过使用绝对地址的方式成功进行了对MySQL进行OLTP。
-
sysbench的常见用法
sysbench可以对机器的硬件进行测试,比如CPU、内存、文件读写、线程处理、锁等,也可以对MySQL数据库进行测试,比自带的MySQLslap更加强大。
--threads=N number of threads to use [default 0] # --num-threads has been deprecated
--evens=N limit for total number of events[default 0]
--time=N limit for total execution time in seconds[default 10] # --max-time has been deprecated
--forced-shutdown=STRING number of seconds to wait after --time limit before forcing shutdown, or 'off' to disable[default off]
--thread-stack-size=SIZE size of stack per thread [64K]
--rate=N average transactions rate. 0 for unlimited rate [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. []
--debug[=on|off] print more debugging info [off]
--validate[=on|off] perform validation checks where possible [off]
--help[=on|off] print help and exit [off]
--version[=on|off] print version and exit [off]
--config-file=FILENAME File containing command line options
Pseudo-Random Numbers Generator options:
--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. When 0, the current time is used as a RNG seed. [0]
--rand-pareto-h=N parameter h for pareto distribution [0.2]
Log options:
--verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]
--percentile=N percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95]
--histogram[=on|off] print latency histogram in report [off]
General database options:
--db-driver=STRING specifies database driver to use ('help' to get list of available drivers) [mysql]
--db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]
--db-debug[=on|off] print database-specific debug information [off]
ompiled-in database drivers:
mysql - MySQL driver
mysql options:
--mysql-host=[LIST,...] MySQL server host [localhost]
--mysql-port=[LIST,...] MySQL server port [3306]
--mysql-socket=[LIST,...] MySQL socket
--mysql-user=STRING MySQL user [sbtest]
--mysql-password=STRING MySQL password []
--mysql-db=STRING MySQL database name [sbtest]
--mysql-ssl[=on|off] use SSL connections, if available in the client library [off]
--mysql-ssl-cipher=STRING use specific cipher for SSL connections []
--mysql-compression[=on|off] use compression, if available in the client library [off]
--mysql-debug[=on|off] trace all client library calls [off]
--mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]
--mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off]
-
sysbench使用中发现的问题
- 前文提到的对MySQL进行OLTP测试时,无法像对CPU、内存等进行
sysbench CPU|memory
操作,而是需要在brew的文件中找到有关于OLTP的lua文件,进行sysbench lua文件地址
才能进行OLTP。 - 在对测试项目进行选择是,
--test
参数已经不再使用了,会报出no such built-in test, file or module
的错误。 - 在对文件IO进行测试时,最好将测试大小设定为超过内存大小。以保证测试的准确性,避免文件全部进入缓存中。
-
几个例子
对文件随机读写进行测试
首先准备好测试数据(例子为10Gb),这是sysbench的必备操作之一
然后执行run操作,进行测试
在run操作后,会得到一系列的测试数据。
最后执行cleanup操作,将测试数据清除掉。
对MySQL进行OLTP
首先找到OLTP的lua文件,然后准备数据(例子中为10个表,每张表100万行数据)
然后进行run操作,最终得到测试数据