MySQL测试工具 sysbench简单安装使用测试~~-阿里云开发者社区

开发者社区> 化雨u> 正文

MySQL测试工具 sysbench简单安装使用测试~~

简介: sysbench学习使用~
+关注继续查看

1、 sysbench简介
sysbench是一款多线程系统压测工具。它可以根据影响数据库服务性能的各种因素来评估系统的性能。例如,可以用来测试软件I/O、操作系统调度器、内存分配和传输速度、POSIX线程,以及数据库服务器等。Sysbench支持Lua脚本语言,Lua对于各种测试场景的设置可以非常灵活。Sysbench是一种全能测试工具,支持MySQL、操作系统和硬件的硬件测试
虽然mysql默认的有mysqlslap这个性能测试工具,跟sysbench比还是sysbench的功能齐全,测试准确,是最有用的MySQL工具之一。
2、 下载安装
https://dev.mysql.com/downloads/benchmarks.html
或者
wget https://github.com/akopytov/sysbench/archive/1.0.zip -O "sysbench-1.0.zip"

[root@localhost software]# ls
os_zabbix-agent sysbench-0.4.12.14.tar.gz
[root@localhost software]# tar xvf sysbench-0.4.12.14.tar.gz

安装必要的依赖库
[root@localhost sysbench-0.4.12.14]# yum -y install make automake libtool pkgconfig libaio-devel vim-common

开始安装:
[root@localhost software]# cd sysbench-0.4.12.14
[root@localhost sysbench-0.4.12.14]# ls
acinclude.m4 autom4te.cache config.log configure.ac INSTALL m4 Makefile.in README TODO
aclocal.m4 ChangeLog config.status COPYING install-sh Makefile missing README-WIN.txt
autogen.sh config configure doc libtool Makefile.am mkinstalldirs sysbench

遇到报错:
[root@localhost sysbench-0.4.12.14]# ./autogen.sh
./autogen.sh: running `libtoolize --copy --force'
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
./autogen.sh: running `aclocal -I m4'
./autogen.sh: running `autoheader'
./autogen.sh: running `automake -c --foreign --add-missing'
./autogen.sh: running `autoconf'
configure.ac:49: error: possibly undefined macro: AC_LIB_PREFIX

  If this token and others are legitimate, please use m4_pattern_allow.
  See the Autoconf documentation.

Can't execute autoconf
查阅资料,解决方法;
[root@localhost sysbench-0.4.12.14]# cat configure.ac | grep AC_LIB_PREFIX

AC_LIB_PREFIX()

    注释掉这个函数就可以了

[root@localhost sysbench-0.4.12.14]# ./autogen.sh
./autogen.sh: running `libtoolize --copy --force'
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
./autogen.sh: running `aclocal -I m4'
./autogen.sh: running `autoheader'
./autogen.sh: running `automake -c --foreign --add-missing'
./autogen.sh: running `autoconf'
Libtoolized with: libtoolize (GNU libtool) 2.4.2
Automade with: automake (GNU automake) 1.13.4
Configured with: autoconf (GNU Autoconf) 2.69

[root@localhost sysbench-0.4.12.14]# ./configure && make && make install
[root@localhost software]# sysbench --version
sysbench 0.4.12.10
安装完成!
3、 测试MySQL的OLTP基准测试
[root@localhost software]# sysbench --help
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]
--seed-rng=N seed for random number generator, ignored when 0 [0]
--tx-rate=N target transaction rate (tps) [0]
--tx-jitter=N target transaction variation, in microseconds [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

Log options:
--verbosity=N verbosity level {5 - debug, 0 - only critical messages} [4]

--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
oltp - OLTP test

Commands: prepare run cleanup help version

See 'sysbench --test= help' for a list of options for each test.
这里可以看到sysbench支持文件I/O,CPU,内存,线程,mutex互斥锁,OLTP等基准测试
3.1简单生成基准测试表
[root@localhost sysbench-0.4.12.14]# sysbench --test=oltp --oltp-table-size=100000 --mysql-db=test --mysql-user=root --mysql-password='123456' --mysql-socket='/tmp/mysql.sock' prepare
sysbench 0.4.12.10: multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Creating table 'sbtest'...
Creating 100000 records in table 'sbtest'...

各种命令格式都在帮助里面可以找到,默认是MySQL数据库,这里已经创建了一个10万行的测试表

3.2测试结果
[root@localhost sysbench-0.4.12.14]# sysbench --test=oltp --oltp-table-size=100000 --mysql-db=test --mysql-user=root --mysql-password='123456' --mysql-socket='/tmp/mysql.sock' --max-time=60 --oltp-read-only=on --max-requests=100 --num-threads=8 run
sysbench 0.4.12.10: multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 8
Random number generator seed is 0 and will be ignored

Doing OLTP test.
Running mixed OLTP test
Doing read-only 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 100
Using 1 test tables
Threads started!
Done.

OLTP test statistics:

queries performed:
    read:                            1400                   --读总数             
    write:                           0                       --写总数
    other:                           200                    --其他操作                  
    total:                           1600                     --全部
transactions:                        100    (610.21 per sec.)    --事务总数
deadlocks:                           0      (0.00 per sec.)     --死锁
read/write requests:                 1400   (8542.96 per sec.)    --读写请求
other operations:                    200    (1220.42 per sec.)   --其他操作

General statistics: --常规统计

total time:                          0.1639s          --所有时间
total number of events:              100               --所有的事务数
total time taken by event execution: 1.2855              --所有事务耗时相加
response time:        --响应时间
     min:                                  5.48ms        --最小耗时
     avg:                                 12.85ms        --平均耗时
     max:                                 28.09ms       --最大耗时
     approx.  95 percentile:              19.89ms           --超95%平均耗时

Threads fairness:

events (avg/stddev):           12.5000/0.50        --平均处理事务数/标准偏差
execution time (avg/stddev):   0.1607/0.00     --平均执行时间/标准偏差

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Windows系统工具推荐 Sysinternals
在Windows系统开发中有一个必备的开发工具Sysinternals,可以监控系统的各种情况,Sysinternals是鼎鼎大名的工具,纳入微软后,和操作系统也同步进行了更新 官方地址 http://technet.
575 0
使用容器编排工具docker swarm安装clickhouse多机集群
1.首先需要安装docker最新版,docker 目前自带swarm容器编排工具 2.选中一台机器作为master,执行命令sudo docker  swarm init [options] 3,再需要加入集群的集群上执行此命令   4.
3033 0
mysql point类型的简单使用
什么是point类型数据?举个例子如下:POINT(123.462202 41.804471) 首先建立一个表: DROP TABLE IF EXISTS `tb_point`; CREATE TABLE `tb_point` ( `timesta...
1814 0
微软轻量级系统监控工具sysmon原理与实现完全分析(上篇)
作者:浪子_三少 Sysmon是微软的一款轻量级的系统监控工具,最开始是由Sysinternals开发的,后来Sysinternals被微软收购,现在属于Sysinternals系列工具。它通过系统服务和驱动程序实现记录进程创建、文件访问以及网络信息的记录,并把相关的信息写入并展示在windows的日志事件里。经常有安全人员使用这款工具去记录并分析系统进程的活动来识别恶意或者异常活动。而本文讨论
1500 0
何时使用static类(工具类)
一个static类,指全部成员都是static方法构成的,而没有任何成员变量, 也称为Utility class 或者Utility Pattern [参考: Utility Pattern].它可以在程序中直接使用该类的方法,而不用实例化.static class相对单例有更好的性能,原因是它的方法不需要实例方法的动态绑定 (static方法本身不能被复写)。
692 0
安装PageAdmin Cms时候“System.ServiceModel.Activation.HttpModule”错误的解决办法
未能从程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中加载类型“System.ServiceModel.Activation.HttpModule”。
1056 0
+关注
化雨u
智者乐水,仁者乐山
18
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
文娱运维技术
立即下载
《SaaS模式云原生数据仓库应用场景实践》
立即下载
《看见新力量:二》电子书
立即下载