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

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 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     --平均执行时间/标准偏差
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
21天前
|
测试技术 API
软件测试:Postman 工具的使用。开发及测试均需要掌握的测试工具
这篇文章详细介绍了Postman工具的各个模块功能,包括创建请求、集合、环境、自动化测试等,并解释了如何使用Postman进行GET、POST、PUT和DELETE等常见HTTP请求的测试。
|
1月前
|
关系型数据库 MySQL OLTP
性能工具之 MySQL OLTP Sysbench BenchMark 测试示例
【8月更文挑战第6天】使用 pt-query-digest 工具分析 MySQL 慢日志性能工具之 MySQL OLTP Sysbench BenchMark 测试示例
147 0
性能工具之 MySQL OLTP Sysbench BenchMark 测试示例
|
19天前
|
关系型数据库 MySQL 测试技术
使用docker部署MySQL测试环境
使用docker部署MySQL测试环境
16 0
|
20天前
|
JSON jenkins 测试技术
Python接口自动化测试框架(工具篇)-- 接口测试工具HTTPRUNNER
本文介绍了Python接口自动化测试框架HTTPRunner,包括其安装、使用方法,并通过实际操作演示了如何利用HTTPRunner进行接口测试,同时还探讨了HTTPRunner作为接口自动化测试解决方案的可能性和实用性。
29 0
|
2月前
|
数据库
基于PHP+MYSQL开发制作的趣味测试网站源码
基于PHP+MYSQL开发制作的趣味测试网站源码。可在后台提前设置好缘分, 自己手动在数据库里修改数据,数据库里有就会优先查询数据库的信息, 没设置的话第一次查询缘分都是非常好的 95-99,第二次查就比较差 , 所以如果要你女朋友查询你的名字觉得很好 那就得是她第一反应是查和你的缘分, 如果查的是别人,那不好意思,第二个可能是你。
48 3
|
1月前
|
SQL 缓存 关系型数据库
MySQL配置简单优化与读写测试
MySQL配置简单优化与读写测试
|
2月前
|
JavaScript 测试技术
vue 官方测试工具 unit-jest 实用教程(含实战范例:登录组件的测试)
vue 官方测试工具 unit-jest 实用教程(含实战范例:登录组件的测试)
54 0
|
4月前
|
Web App开发 测试技术 API
自动化测试工具Selenium的深度解析
【5月更文挑战第27天】本文旨在深入剖析自动化测试工具Selenium,探讨其架构、原理及应用。通过对其核心组件、运行机制及在实际项目中的应用案例进行详细解读,以期为软件测试人员提供全面、深入的理解与实践指导。
|
4月前
|
JSON 数据管理 测试技术
自动化测试工具Selenium Grid的深度应用分析深入理解操作系统的内存管理
【5月更文挑战第28天】随着互联网技术的飞速发展,软件测试工作日益复杂化,传统的手工测试已无法满足快速迭代的需求。自动化测试工具Selenium Grid因其分布式执行特性而受到广泛关注。本文旨在深入剖析Selenium Grid的工作原理、配置方法及其在复杂测试场景中的应用优势,为测试工程师提供高效测试解决方案的参考。
|
4月前
|
敏捷开发 监控 IDE
深入理解自动化测试工具Selenium的工作原理与实践应用
【5月更文挑战第26天】 随着敏捷开发和持续集成理念的普及,自动化测试在软件开发生命周期中扮演了至关重要的角色。Selenium作为最流行的自动化测试工具之一,以其开源、跨平台和支持多种编程语言的特性被广泛使用。本文将详细解析Selenium的核心组件,探讨其工作原理,并通过案例分析展示如何高效地实施Selenium进行Web应用的自动化测试。我们将从测试准备到结果分析的全过程,提供一系列实用的策略和最佳实践,帮助读者构建和维护一个健壮的自动化测试环境。

热门文章

最新文章