Database pressure measurement tool Sysbench-0.4.12 installation

Recently, the company plans to go to oracle and migrate to mysql cluster. Our technology selection of distributed database middleware chose mycat. This is undoubtedly the preparatory work that needs to be done well. With the help of the operation and maintenance students, the cluster has been set up, and our next task is stress testing. This article simply records the installation and use of the pressure measurement tool Sysbench I have chosen.

Introduction to sysbench

Sysbench is a modular, cross-platform, multi-threaded benchmark test tool, mainly used to evaluate and test database load conditions under various system parameters. It mainly includes the following tests: cpu performance, disk io performance, thread scheduling performance, memory allocation and transmission speed and database performance. Since I am a dba, I focus on the scenario of sysbench testing the database. Currently sysbench supports three data sources: mysql, postgreSQL, and oracle.

test environment

System: Centos-8

Sysbench: sysbench-0.4.12.10, download link: https://github.com/akopytov/sysbench

You can also click to download directly: http://downloads.mysql.com/source/sysbench-0.4.12.10.tar.gz

installation steps

Some dependency installation of sysbench

yum -y install  make automake libtool pkgconfig libaio-devel vim-common
如果没有安装mysql,则需要安装mysql-devel
yum install mysql-devel

Install sysbench

  1. Enter the sysbench source directory
cd /data/sysbench/sysbench-0.4.12

  1. Execute autogen.sh and use it to generate the configure file
./autogen.sh

  1. Execute configure && make && make install to complete the sysbench installation
./configure --prefix=/wls/sysbench/ --build=x86_64 
make && make install

Note: If you do not add --build=x86_64, the following error may be prompted:

checking build system type... Invalid configuration `x86_64-unknown-linux-': machine `x86_64-unknown-linux' not recognized

configure: error: /bin/sh config/config.sub x86_64-unknown-linux- failed

Verify that the installation is successful

[root@05823ea529b0 sysbench-1.0.15]# /wls/sysbench/bin/sysbench --version
sysbench 0.4.12.10
[root@05823ea529b0 sysbench-1.0.15]# ./sysbench --test=cpu run
sysbench 0.4.12.10 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:  1158.09

General statistics:
    total time:                          10.0005s
    total number of events:              11583

Latency (ms):
         min:                                    0.79
         avg:                                    0.86
         max:                                    1.92
         95th percentile:                        1.01
         sum:                                 9985.69

Threads fairness:
    events (avg/stddev):           11583.0000/0.00
    execution time (avg/stddev):   9.9857/0.00

sysbench view help

Usage:
  sysbench [general-options]... --test=<test-name> [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=<name> help' for a list of options for each test.

The process of sysbench stress testing the database

  • The prepare phase is used to prepare, compare to establish the test table, and fill the table with data;
  • This stage of the run phase is the SQL to run the stress test;
  • The cleanup stage is to clear the data, that is, all tables initialized in the prepare stage should be dropped;

The test types in sysbench can be roughly divided into built-in, lua script custom tests

  1. 内置: fileio 、cpu 、memory 、threads 、 mutex
  2. Lua script custom type: sysbench contains some test scripts in the installation directory:
查看帮忙命令:
[root@izwz909ewdz83smewux7a7z bin]# ./sysbench --help
Usage:
  sysbench [general-options]... --test=<test-name> [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=<name> help' for a list of options for each test.

Test mysql through the lua script that comes with sysbench

  1. Generate table file
[root@izwz909ewdz83smewux7a7z bin]# ./sysbench --test=oltp --oltp-num-tables=100000 --oltp-num-tables=10 --mysql-db=sysbench --mysql-user=root --mysql-password='mydb' --mysql-host=localhost --mysql-port=3306 --db-driver=mysql --init-rng=on prepare

  1. Multi-threaded test
[root@izwz909ewdz83smewux7a7z bin]# ./sysbench --test=oltp --oltp-table-size=100000 --mysql-db=sysbench --mysql-user=root --mysql-password='mydb' --mysql-host=localhost --mysql-port=3306 --db-driver=mysql --oltp-read-only=off --max-time=60 --num-threads=8 --report-interval=10 --oltp-dist-type=uniform --max-requests=0 --percentile=99 run
sysbench 0.4.12.10:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 8
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored


Doing OLTP test.
Running mixed OLTP test
Using Uniform distribution
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Using 1 test tables
Threads started!
[  10s] Intermediate results: 8 threads, tps: 582.994023, reads/s: 8233.315586, writes/s: 2940.469852 response time: 48.261058ms (99%)
[  20s] Intermediate results: 8 threads, tps: 589.090480, reads/s: 8248.666697, writes/s: 2945.952392 response time: 35.829896ms (99%)
[  30s] Intermediate results: 8 threads, tps: 487.603128, reads/s: 6829.243810, writes/s: 2439.015647 response time: 65.415122ms (99%)
[  40s] Intermediate results: 8 threads, tps: 487.700557, reads/s: 6830.607800, writes/s: 2439.502786 response time: 78.027721ms (99%)
[  50s] Intermediate results: 8 threads, tps: 478.852588, reads/s: 6703.936228, writes/s: 2394.262939 response time: 71.711459ms (99%)
[  60s] Intermediate results: 8 threads, tps: 510.752034, reads/s: 7150.528473, writes/s: 2553.760169 response time: 43.136643ms (99%)
Time limit exceeded, exiting...
(last message repeated 7 times)
Done.

OLTP test statistics:
    queries performed:
        read:                            440076    读总数
        write:                           157170    写总数
        other:                           62812    他操作总数(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)
        total:                           660058    总数
    transactions:                        31378  (522.91 per sec.)    总事务数(每秒事务数)
    deadlocks:                           56     (0.93 per sec.)    
    read/write requests:                 597246 (9953.02 per sec.)    读写总数(每秒读写次数)
    other operations:                    62812  (1046.75 per sec.)

General statistics:
    total time:                          60.0065s    总耗时
    total number of events:              31378    共发生多少事务数
    total time taken by event execution: 479.8756    所有事务耗时相加(不考虑并行因素)
    response time:
         min:                                  3.77ms    最小耗时
         avg:                                 15.29ms    平均耗时
         max:                                180.78ms    最长耗时
         approx.  99 percentile:              58.12ms    超过99%平均耗时

Threads fairness:
    events (avg/stddev):           3922.2500/6.02
    execution time (avg/stddev):   59.9845/0.00

  1. Clean up the test table generated above
[root@izwz909ewdz83smewux7a7z bin]# ./sysbench --test=oltp --oltp-num-tables=100000 --oltp-num-tables=10 --mysql-db=sysbench --mysql-user=root --mysql-password='mydb' --mysql-host=localhost --mysql-port=3306 --db-driver=mysql --init-rng=on cleanup
sysbench 0.4.12.10:  multi-threaded system evaluation benchmark

Dropping table 'sbtest'...
Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
Dropping table 'sbtest9'...
Done.
[root@izwz909ewdz83smewux7a7z bin]# 

Since the above commands are relatively simple, I believe everyone can understand it. If you have any questions, please leave a message and exchange.

After tuning the database, use sysbench to test OLTP to see if TPS will improve.

Note: The sysbench test is only a benchmark test, and does not represent the performance indicators in an actual enterprise environment.

Personal website: http://coderluo.top

Welcome to pay attention to the author's public account: Fall in love with coding , and will regularly share Java technology work, let boring technology swim!

Scan QR code to follow

[This article was first published on this site, please indicate the source for reprinting]: http://coderluo.top/2019/10/13/docker/docker-an-zhuang-centos8-bing-shi-yong-ssh-yuan- cheng-lian-jie/

Guess you like

Origin blog.csdn.net/taurus_7c/article/details/102578285