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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 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     --平均执行时间/标准偏差
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
25天前
Mybatis+mysql动态分页查询数据案例——测试类HouseDaoMybatisImplTest)
Mybatis+mysql动态分页查询数据案例——测试类HouseDaoMybatisImplTest)
20 1
|
25天前
|
Java 关系型数据库 数据库连接
Mybatis+MySQL动态分页查询数据经典案例(含代码以及测试)
Mybatis+MySQL动态分页查询数据经典案例(含代码以及测试)
24 1
|
1月前
|
监控 关系型数据库 MySQL
Flink CDC产品常见问题之使用3.0测试mysql到starrocks启动报错如何解决
Flink CDC(Change Data Capture)是一个基于Apache Flink的实时数据变更捕获库,用于实现数据库的实时同步和变更流的处理;在本汇总中,我们组织了关于Flink CDC产品在实践中用户经常提出的问题及其解答,目的是辅助用户更好地理解和应用这一技术,优化实时数据处理流程。
|
2月前
|
关系型数据库 MySQL Java
Mysql专栏 - 线上调优与压力测试
Mysql专栏 - 线上调优与压力测试
85 0
|
4月前
|
关系型数据库 MySQL Shell
MySQL【实践 01】Linux 环境 MySQL 数据库备份 shell 脚本(脚本源码及说明+定时任务配置+数据库恢复测试)粘贴可以
MySQL【实践 01】Linux 环境 MySQL 数据库备份 shell 脚本(脚本源码及说明+定时任务配置+数据库恢复测试)粘贴可以
50 0
|
11天前
|
关系型数据库 MySQL 数据库
mysql卸载、下载、安装(window版本)
mysql卸载、下载、安装(window版本)
|
1月前
|
关系型数据库 MySQL 数据库连接
关于MySQL-ODBC的zip包安装方法
关于MySQL-ODBC的zip包安装方法
|
29天前
|
关系型数据库 MySQL 数据库
rds安装数据库客户端工具
安装阿里云RDS的数据库客户端涉及在本地安装对应类型(如MySQL、PostgreSQL)的客户端工具。对于MySQL,可选择MySQL Command-Line Client或图形化工具如Navicat,安装后输入RDS实例的连接参数进行连接。对于PostgreSQL,可以使用`psql`命令行工具或图形化客户端如PgAdmin。首先从阿里云控制台获取连接信息,然后按照官方文档安装客户端,最后配置客户端连接以确保遵循安全指引。
82 1
|
24天前
|
Ubuntu 关系型数据库 MySQL
Ubuntu 中apt 安装MySQL数据库
Ubuntu 中apt 安装MySQL数据库
66 0
|
3天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
12 0