`
lalanicer
  • 浏览: 30163 次
社区版块
存档分类
最新评论

MySQL性能测试工具sysbench

 
阅读更多

sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。数据库目前支持MySQL/Oracle/PostgreSQL。本文只是简单演示一下几种测试的用法,后续准备利用sysbench来对MySQL进行一系列的测试。具体的一些参数设置,需要根据不同的测试要求来进行调整。

下载

编译安装

默认支持MySQL,如果需要测试Oracle/PostgreSQL,则在configure时需要加上–with-oracle或者–with-pgsql参数

1 ./configure --prefix=/u01/sysbench \
2 --with-mysql-includes=/opt/mysql/include/mysql \
3 --with-mysql-libs=/opt/mysql/lib/mysql
4  
5 make && make install

参数

01 NinGoo:/u01/sysbench/bin>$sysbench
02 Missing required command argument.
03 Usage:
04   sysbench [general-options]... --test= [test-options]... command
05  
06 General options:
07   --num-threads=N            number of threads to use [1]
08   --max-requests=N           limit for total number of requests [10000]
09   --max-time=N               limit for total execution time in seconds [0]
10   --forced-shutdown=STRING   amount of time to wait after --max-time before forcing shutdown [off]
11   --thread-stack-size=SIZE   size of stack per thread [32K]
12   --init-rng=[on|off]        initialize random number generator [off]
13   --test=STRING              test to run
14   --debug=[on|off]           print more debugging info [off]
15   --validate=[on|off]        perform validation checks where possible [off]
16   --help=[on|off]            print help and exit
17   --version=[on|off]         print version and exit
18  
19 Compiled-in tests:
20   fileio - File I/O test
21   cpu - CPU performance test
22   memory - Memory functions speed test
23   threads - Threads subsystem performance test
24   mutex - Mutex performance test
25   oltp - OLTP test
26  
27 Commands: prepare run cleanup help version
28 See 'sysbench --test= help' for a list of options for each test.

CPU测试
sysbench采用寻找最大素数的方式来测试CPU的性能

01 NinGoo:/u01/sysbench/bin>$sysbench --test=cpu --cpu-max-prime=2000 run
02 sysbench 0.4.12:  multi-threaded system evaluation benchmark
03  
04 Running the test with following options:
05 Number of threads: 1
06  
07 Doing CPU performance benchmark
08  
09 Threads started!
10 Done.
11  
12 Maximum prime number checked in CPU test: 2000
13  
14 Test execution summary:
15     total time:                          2.3996s
16     total number of events:              10000
17     total time taken by event execution: 2.3917
18     per-request statistics:
19          min:                                  0.23ms
20          avg:                                  0.24ms
21          max:                                 27.44ms
22          approx.  95 percentile:               0.24ms
23  
24 Threads fairness:
25     events (avg/stddev):           10000.0000/0.00
26     execution time (avg/stddev):   2.3917/0.00

线程测试

01 NinGoo:/u01/sysbench/bin>$sysbench --test=threads --num-threads=64 --thread-yields=100 \
02 --thread-locks=2 run
03 sysbench 0.4.12:  multi-threaded system evaluation benchmark
04  
05 Running the test with following options:
06 Number of threads: 64
07  
08 Doing thread subsystem performance test
09 Thread yields per test: 100 Locks used: 2
10 Threads started!
11 Done.
12  
13 Test execution summary:
14     total time:                          4.3925s
15     total number of events:              10000
16     total time taken by event execution: 280.4418
17     per-request statistics:
18          min:                                  0.04ms
19          avg:                                 28.04ms
20          max:                                 72.81ms
21          approx.  95 percentile:              52.29ms
22  
23 Threads fairness:
24     events (avg/stddev):           156.2500/1.43
25     execution time (avg/stddev):   4.3819/0.01


文件IO性能测试

首先生成需要的测试文件,文件总大小300M,16个并发线程,随机读写模式。执行完后会在当前目录下生成一堆小文件。

1 NinGoo:/u01/sysbench/bin>$sysbench --test=fileio --num-threads=16  \
2 --file-total-size=300M --file-test-mode=rndrw prepare
3 sysbench 0.4.12:  multi-threaded system evaluation benchmark
4  
5 128 files, 2400Kb each, 300Mb total
6 Creating files for the test...

执行测试

01 NinGoo:/u01/sysbench/bin>$sysbench --test=fileio --num-threads=16  \
02 --file-total-size=300M --file-test-mode=rndrw run
03 sysbench 0.4.12:  multi-threaded system evaluation benchmark
04  
05 Running the test with following options:
06 Number of threads: 16
07  
08 Extra file open flags: 0
09 128 files, 2.3438Mb each
10 300Mb total file size
11 Block size 16Kb
12 Number of random requests for random IO: 10000
13 Read/Write ratio for combined random IO test: 1.50
14 Periodic FSYNC enabled, calling fsync() each 100 requests.
15 Calling fsync() at the end of test, Enabled.
16 Using synchronous I/O mode
17 Doing random r/w test
18 Threads started!
19 Done.
20  
21 Operations performed:  5996 Read, 4004 Write, 12800 Other = 22800 Total
22 Read 93.688Mb  Written 62.562Mb  Total transferred 156.25Mb  (26.713Mb/sec)
23  1709.66 Requests/sec executed
24  
25 Test execution summary:
26     total time:                          5.8491s
27     total number of events:              10000
28     total time taken by event execution: 12.5045
29     per-request statistics:
30          min:                                  0.01ms
31          avg:                                  1.25ms
32          max:                                373.28ms
33          approx.  95 percentile:               0.03ms
34  
35 Threads fairness:
36     events (avg/stddev):           625.0000/109.60
37     execution time (avg/stddev):   0.7815/0.29

清理现场

1 NinGoo:/u01/sysbench/bin>$sysbench --test=fileio --num-threads=16  \
2 --file-total-size=300M --file-test-mode=rndrw cleanup
3 sysbench 0.4.12:  multi-threaded system evaluation benchmark
4  
5 Removing test files...

Mutex测试

01 NinGoo:/u01/sysbench/bin>$sysbench --test=mutex --num-threads=16 \
02 --mutex-num=1024 --mutex-locks=10000 --mutex-loops=5000 run
03 sysbench 0.4.12:  multi-threaded system evaluation benchmark
04  
05 Running the test with following options:
06 Number of threads: 16
07  
08 Doing mutex performance test
09 Threads started!
10 Done.
11  
12 Test execution summary:
13     total time:                          1.1561s
14     total number of events:              16
15     total time taken by event execution: 18.3831
16     per-request statistics:
17          min:                               1084.60ms
18          avg:                               1148.94ms
19          max:                               1153.52ms
20          approx.  95 percentile:         10000000.00ms
21  
22 Threads fairness:
23     events (avg/stddev):           1.0000/0.00
24     execution time (avg/stddev):   1.1489/0.02

内存测试

01 NinGoo:/u01/sysbench/bin>$sysbench --test=memory --num-threads=16 \
02 --memory-block-size=8192 --memory-total-size=1G run
03 sysbench 0.4.12:  multi-threaded system evaluation benchmark
04  
05 Running the test with following options:
06 Number of threads: 16
07  
08 Doing memory operations speed test
09 Memory block size: 8K
10  
11 Memory transfer size: 1024M
12  
13 Memory operations type: write
14 Memory scope type: global
15 Threads started!
16 WARNING: Operation time (0.000000) is less than minimal counted value, counting as 1.000000
17 WARNING: Percentile statistics will be inaccurate
18 Done.
19  
20 Operations performed: 131072 (114162.68 ops/sec)
21  
22 1024.00 MB transferred (891.90 MB/sec)
23  
24 Test execution summary:
25     total time:                          1.1481s
26     total number of events:              131072
27     total time taken by event execution: 16.0448
28     per-request statistics:
29          min:                                  0.00ms
30          avg:                                  0.12ms
31          max:                                  3.60ms
32          approx.  95 percentile:               0.01ms
33  
34 Threads fairness:
35     events (avg/stddev):           8192.0000/192.89
36     execution time (avg/stddev):   1.0028/0.00

MySQL数据库测试
首先需要创建默认的sbtest数据库,或者使用–mysql-db指定一个已经存在的数据库

生成测试数据,引擎为myisam,表大小为1000000条记录

01 NinGoo:/u01/sysbench/bin>$sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \
02 --mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock prepare
03 sysbench 0.4.12:  multi-threaded system evaluation benchmark
04  
05 No DB drivers specified, using mysql
06 Creating table 'sbtest'...
07 Creating 1000000 records in table 'sbtest'...
08  
09 root@sbtest 11:42:18>desc sbtest.sbtest;
10 +-------+------------------+------+-----+---------+----------------+
11 | Field | Type             | Null | Key | Default | Extra          |
12 +-------+------------------+------+-----+---------+----------------+
13 | id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
14 | k     | int(10) unsigned | NO   | MUL | 0       |                |
15 | c     | char(120)        | NO   |     |         |                |
16 | pad   | char(60)         | NO   |     |         |                |
17 +-------+------------------+------+-----+---------+----------------+

执行测试

01 NinGoo:/u01/sysbench/bin>$sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \
02 --mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock run
03 sysbench 0.4.12:  multi-threaded system evaluation benchmark
04  
05 No DB drivers specified, using mysql
06 Running the test with following options:
07 Number of threads: 1
08  
09 Doing OLTP test.
10 Running mixed OLTP test
11 Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
12 Using "LOCK TABLES WRITE" for starting transactions
13 Using auto_inc on the id column
14 Maximum number of requests for OLTP test is limited to 10000
15 Threads started!
16 Done.
17  
18 OLTP test statistics:
19     queries performed:
20         read:                            140000
21         write:                           50000
22         other:                           20000
23         total:                           210000
24     transactions:                        10000  (336.64 per sec.)
25     deadlocks:                           0      (0.00 per sec.)
26     read/write requests:                 190000 (6396.11 per sec.)
27     other operations:                    20000  (673.27 per sec.)
28  
29 Test execution summary:
30     total time:                          29.7056s
31     total number of events:              10000
32     total time taken by event execution: 29.6301
33     per-request statistics:
34          min:                                  2.27ms
35          avg:                                  2.96ms
36          max:                                 43.88ms
37          approx.  95 percentile:               3.36ms
38  
39 Threads fairness:
40     events (avg/stddev):           10000.0000/0.00
41     execution time (avg/stddev):   29.6301/0.00

清理现场

1 NinGoo:/u01/sysbench/bin>$sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \
2 --mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock cleanup
3 sysbench 0.4.12:  multi-threaded system evaluation benchmark
4  
5 No DB drivers specified, using mysql
6 Dropping table 'sbtest'...
7 Done.
分享到:
评论

相关推荐

    MySQL 性能测试工具sysbench安装使用

    ### MySQL 性能测试工具sysbench安装与使用详解 #### 一、Sysbench简介 Sysbench是一款开源的、跨平台的、多线程基准测试工具,用于评估不同系统配置下的数据库负载性能。它支持多种测试模式,包括但不限于CPU运算...

    06-MySQL压力测试工具sysbench1

    MySQL 压力测试工具 sysbench 介绍 sysbench 是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。目前 sysbench 主要支持 MySQL, pgsql, oracle 这 3 种数据库。 ...

    mysql性能测试工具

    mysql 性能测试工具sysbench 0.4.12.10版本

    数据库经典压测工具sysbench双版本 sysbench0.5支持oracle sysbench1.1 支持达梦 附详细文档

    首先,sysbench0.5是针对早期版本的sysbench,它主要专注于MySQL数据库的性能测试,但也提供了对Oracle数据库的支持。sysbench0.5提供了一套全面的测试场景,包括OLTP(在线事务处理)工作负载、读写混合操作以及CPU...

    详解MySQL基准测试和sysbench工具.doc

    数据库的基准测试是对数据库的性能指标进行定量的、可复现的、可对比的测试。基准测试与压力测试 基准测试可以理解为针对系统的一种压力测试。但基准测试不关心业务逻辑,更加简单、直接、易于测试,数据可以由工具...

    性能测试工具sysbench简介

    性能测试工具sysbench简介性能测试工具sysbench简介出处信息sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。数据库目前支持MySQL/Or  您现在的位置:首页-->Oracle...

    mysql-sysbench测试

    mysql-sysbench测试是指使用sysbench工具对mysql数据库进行基准测试,测试包括cpu测试、I/O基准测试和OLTP基准测试等。sysbench是一个开源的基准测试工具,可以模拟不同的负载场景来测试数据库的性能。 sysbench...

    性能测试:sysbench

    mysql性能测试工具:sysbench+资源(autoconf、automake、libtool)

    性能测试sysbench.rar

    在大多数Linux发行版中,sysbench依赖于一些库,如libmysqlclient(如果要进行MySQL性能测试)、Lua等。确保这些依赖已经安装,然后执行: ``` ./configure make sudo make install ``` sysbench的主要功能包括CPU...

    性能测试工具-sysbench.html

    linux性能测试工具-sysbench使用方法,可以mysql读写性能

    MySQL性能优化Workshop_性能测试工具

    ### MySQL性能测试工具详解 #### 一、引言 MySQL作为全球广泛使用的开源关系型数据库管理系统之一,在实际应用中面临着各种性能挑战。为了确保数据库能够高效稳定地运行,进行性能测试变得至关重要。本文将详细...

    MYSQL集群测试

    1. 测试工具介绍:文档提到了mysqlslap、sysbench、supersmack等工具,这些都是用于测试MYSQL性能的工具。 - mysqlslap是一个用于模拟多用户访问MySQL数据库的性能测试工具,它可以用来进行并发读写测试。 - ...

    Mysql基准测试工具-sysbench

    Mysql数据库本身提供了比较优秀的性能测试工具,这里另外介绍下sysbench。Sysbench主要的测试方法有:  之前介绍了相关mysql的性能参数调优,这些天利用基准测试工具对mysql的测试,Jason留下点Memory。  Mysql...

    mysql压力测试工具

    sysbench是一个强大的多线程、多事件驱动的系统和数据库性能测试工具。它不仅可以评估系统的CPU、内存、磁盘I/O等硬件性能,还能针对MySQL数据库进行复杂的基准测试,帮助开发者和DBA优化数据库性能,确保在高并发、...

    sysbench-1.0.19.zip

    sysbench是一个多线程、多事件驱动的性能测试和基准测试工具,主要用于评估和比较数据库系统的性能。在这个sysbench-1.0.19.zip压缩包中,包含的是sysbench的源代码,为用户提供了一种强大的方式来测试MySQL数据库的...

    使用sysbench来测试MySQL性能的详细教程

    sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。 目前sysbench代码托管在launchpad上,项目地址:https://launchpad.net/sysbench(原来的官网 ...

    数据库性能测试之sysbench工具的安装与用法详解

    sysbench是用于多线程性能测试的开源工具,它具有模块化和跨平台的特性,能够测试CPU、内存、磁盘I/O、线程以及数据库的性能。在数据库测试方面,sysbench支持MySQL、Oracle和PostgreSQL这三种常见的关系型数据库...

    统一开发环境mysql5.7.11基准测试文档_基于sysbench测试工具

    - **Sysbench工具简介**:Sysbench是一款专门用于测试MySQL等关系型数据库性能的工具,由多位MySQL专家推荐。它需要编译安装,并通过设置不同的参数来获取关于CPU计算能力、文件I/O能力、OLTP能力等多种性能指标的...

    sysbench-0.4.12

    4. 数据库性能测试:sysbench支持对MySQL和PostgreSQL等数据库进行OLTP(在线事务处理)性能测试,包括插入、更新、删除、读取等操作。 三、使用方法 sysbench-0.4.12的使用通常包括配置、预热、运行测试和分析结果...

Global site tag (gtag.js) - Google Analytics