sysBench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。sysbench提供如下测试:
(1)CPU性能
(2)磁盘IO性能
(3)调度程序性能
(4)内存分配及传输速度?
(5)POSIX线程性能
(6)数据库性能(OLTP基准测试)??????
sysbench支持?MySQL、PostgreSQL、Oracle?数据库。
Build构建依赖安装:
yum -y install make automake libtool pkgconfig libaio-devel
yum -y install mariadb-devel openssl-devel
yum -y install postgresql-devel
源码下载:git clone https://github.com/akopytov/sysbench.git
生成配置工具:autogen.sh
配置选项:
–with-pgsql:支持PostgreSQL
–with-oracle:支持Oracle
–without-mysql:无MySQL支持
configure [options]
编译:make -j
安装:make install
sysbench [options]... [testname] [command]
testname是sysbench要执行的测试类型,可选项包括fileio、cpu、memory、threads、mutex,可以使用–test参数指定。
command是sysbench要执行的命令,包括prepare、run、cleanup,prepare为测试准备数据,run执行正式测试,cleanup在测试完成后对数据库进行清理。
sysbench通用参数选项如下:
–threads: 线程数,若设置为2,则sysbench会启动2个线程,同时分别进行素数的计算,默认值为1。
–time: 运行时长,单位秒。若设置为5,则sysbench会在5秒内循环进行素数计算,每完成一轮就是一个event,默认值为10。
–events: event上限次数,若设置为100,则表示当完成100次event后,即使时间富余也停止运行。默认值为0,则表示不限event次数。
–forced-shutdown=STRING:超时强制中断,默认为off。 --thread-stack-size=SIZE:线程栈大小,默认64K
–thread-init-timeout=N:线程初始化等待时间,默认为30秒
–rate=N:平均事务率,0表示不限制,默认为0。
–report-interval=N:测试进度报告输出的时间间隔,0表示关闭,默认为0。
–report-checkpoints=[LIST,…]:转储完全统计信息并在指定时间点复位所有计数器,参数是逗号分隔值的列表,表示从必须执行报告检查点的测试开始所经过的时间(以秒为单位)。 默认情况下,报告检查点处于关闭状态[off]。
–debug[=on|off]:打印调试信息,默认为off
–validate[=on|off]:尽可能执行验证检查,默认为off。
–help[=on|off]:打印help信息并退出,默认为off
–version[=on|off]:打印版本信息并退出,默认为off
–config-file=FILENAME:命令行选项文件
–luajit-cmd=STRING:执行LuaJIT控制命令
sysbench --test=cpu help
–cpu-max-prime:素数生成数量的上限,若设置为3,则表示2、3、5(要计算1-5共5次),默认值为10000。
sysbench cpu --cpu-max-prime=20000 --threads=8 --time=30 run
Prime numbers limit: 20000,每个线程产生的素数上限均为2000
events per second: 650.7,所有线程每秒完成了650.74次event
total time: 10.0017s,共耗时10秒
total number of events: 6510,10秒内所有线程一共完成了6510次event
min: 3.03,完成1次event的最少耗时3.03秒
avg: 3.07,所有event的平均耗时3.07毫秒
max: 3.27,完成1次event的最多耗时3.27毫秒
95th percentile: 3.13, 95%次event在3.13秒毫秒内完成
sum: 19999.91,每个线程耗时10秒,2个线程叠加耗时就是20秒
events (avg/stddev): 3255.0000/44.00 // 平均每个线程完成3255次event,标准差为44
execution time (avg/stddev): 10.0000/0.00 // 每个线程平均耗时10秒,标准差为0
sysbench --test=oltp help
–oltp-test-mode=STRING:测试模式,simple、complex、nontrx、sp,默认为complex。
–oltp-reconnect-mode=STRING:重连接模式,session不使用重连接,transaction在每次事务结束后重连接,query在每个SQL语句执行完重连接,random对于每个事务随机选择重连接模式,默认为session。
–oltp-sp-name=STRING:存储过程名称,默认为空
–oltp-read-only=[on|off]:只读模式。Update、delete、insert语句不可执行,默认为off
–oltp-skip-trx=[on|off]:省略begin/commit语句,默认为off。
–oltp-range-size=N:查询范围,默认为100。–oltp-point-selects=N:number of point selects [10]
–oltp-simple-ranges=N????????? number of simple ranges [1]
–oltp-sum-ranges=N???????????? number of sum ranges [1]
–oltp-order-ranges=N?????????? number of ordered ranges [1]
–oltp-distinct-ranges=N??????? number of distinct ranges [1]
–oltp-index-updates=N????????? number of index update [1]
–oltp-non-index-updates=N????? number of non-index updates [1]
–oltp-nontrx-mode=STRING???查询类型对于非事务执行模式{select, update_key, update_nokey, insert, delete} [select]
–oltp-auto-inc=[on|off]????? AUTO_INCREMENT是否开启。默认是on
–oltp-connect-delay=N?????在多少微秒后连接数据库。默认是10000
–oltp-user-delay-min=N????每个请求最短等待时间。单位是ms。默认是0
–oltp-user-delay-max=N????每个请求最长等待时间。单位是ms。默认是0
–oltp-table-name=STRING??测试时使用到的表名。默认是sbtest
–oltp-table-size=N?????????测试表的记录数。默认是10000
–oltp-dist-type=STRING????分布的随机数{uniform(均匀分布),Gaussian(高斯分布),special(空间分布)}。默认是special
–oltp-dist-iter=N????产生数的迭代次数。默认是12
–oltp-dist-pct=N????值的百分比被视为’special’ (for special distribution)。默认是1
–oltp-dist-res=N????‘special’的百分比值。默认是75
/usr/share/sysbench/bulk_insert.lua
/usr/share/sysbench/oltp_common.lua
/usr/share/sysbench/oltp_delete.lua
/usr/share/sysbench/oltp_insert.lua
/usr/share/sysbench/oltp_point_select.lua
/usr/share/sysbench/oltp_read_only.lua
/usr/share/sysbench/oltp_read_write.lua
/usr/share/sysbench/oltp_update_index.lua
/usr/share/sysbench/oltp_update_non_index.lua
/usr/share/sysbench/oltp_write_only.lua
/usr/share/sysbench/select_random_points.lua
/usr/share/sysbench/select_random_ranges.lua
sysbench ./tests/include/oltp_legacy/oltp.lua --mysql-host=192.168.10.10 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --oltp-test-mode=complex --oltp-tables-count=10 --oltp-table-size=100000 --threads=10 --time=120 --report-interval=10 prepare
执行模式为complex,使用了10个表,每个表有10万条数据,客户端的并发线程数为10,执行时间为120秒,每10秒生成一次报告。
sysbench ./tests/include/oltp_legacy/oltp.lua --mysql-host=192.168.10.10 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --oltp-test-mode=complex --oltp-tables-count=10 --oltp-table-size=100000 --threads=10 --time=120 --report-interval=10 run >> /home/test/mysysbench.log
sysbench ./tests/include/oltp_legacy/oltp.lua --mysql-host=192.168.10.10 --mysql-port=3306 --mysql-user=root --mysql-password=123456 cleanup
# su - mysql
$ mysqld &
...
$ mysql -uroot -proot2023
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.30-22 Percona Server (GPL), Release 22, Revision 7e301439b65
Copyright (c) 2009-2022 Percona LLC and/or its affiliates
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
准备连接用户和数据库test
--创建可以远程连接的root用户
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)
mysql> create user 'root'@'%' identified with mysql_native_password by 'root2023';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)
--准备test数据库
$ mysql -h<MYSQL_IP地址> -P3306 -uroot -proot2023
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.30-22 Percona Server (GPL), Release 22, Revision 7e301439b65
Copyright (c) 2009-2022 Percona LLC and/or its affiliates
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database test;
Query OK, 1 row affected (0.01 sec)
场景:4张表,每张表个10万行,16线程 - 点查 oltp_point_select
--表准备
# cd share/sysbench
# sysbench --threads=16 --time=60 --report-interval=1 oltp_common.lua --mysql-host=66.3.125.125 --mysql-port=3306 --mysql-user=root --mysql-password=root2023 \
--mysql-db=test --tables=4 --table-size=100000 prepare
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Initializing worker threads...
Creating table 'sbtest2'...
Creating table 'sbtest1'...
Creating table 'sbtest4'...
Creating table 'sbtest3'...
Inserting 100000 records into 'sbtest1'
Inserting 100000 records into 'sbtest2'
Inserting 100000 records into 'sbtest3'
Inserting 100000 records into 'sbtest4'
Creating a secondary index on 'sbtest1'...
Creating a secondary index on 'sbtest4'...
Creating a secondary index on 'sbtest3'...
Creating a secondary index on 'sbtest2'...
--连接数据库确认
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| sbtest1 |
| sbtest2 |
| sbtest3 |
| sbtest4 |
+----------------+
4 rows in set (0.00 sec)
mysql> select count(*) from test1;
ERROR 1146 (42S02): Table 'test.test1' doesn't exist
mysql> select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
| 100000 |
+----------+
1 row in set (0.01 sec)
mysql> desc sbtest2;
+-------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| k | int | NO | MUL | 0 | |
| c | char(120) | NO | | | |
| pad | char(60) | NO | | | |
+-------+-----------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
mysql> show create table sbtest3;
+---------+------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+------------------------------------------------------------------------------------------------------------------------------------+
| sbtest3 | CREATE TABLE `sbtest3` (
`id` int NOT NULL AUTO_INCREMENT,
`k` int NOT NULL DEFAULT '0',
`c` char(120) NOT NULL DEFAULT '',
`pad` char(60) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `k_3` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=100001 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+---------+------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select * from sbtest4 limit 5;
+----+-------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
| id | k | c | pad |
+----+-------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
| 1 | 50303 | 18034632456-32298647298-82351096178-60420120042-90070228681-93395382793-96740777141-18710455882-88896678134-41810932745 | 43683718329-48150560094-43449649167-51455516141-06448225399 |
| 2 | 50450 | 69708345057-48265944193-91002879830-11554672482-35576538285-03657113365-90301319612-18462263634-56608104414-27254248188 | 05603373460-16140454933-50476449060-04937808333-32421752305 |
| 3 | 50940 | 04940100707-79196214653-69899219520-16993366471-57789899414-92525293502-62890351877-80720493586-13749767421-91023911663 | 67126402466-45286595358-58204691523-62355769941-06673789329 |
| 4 | 49974 | 00224676656-38003697255-44184401985-68851502665-32480635416-18445090402-63317915144-45481704416-01982644758-64592914637 | 77377062042-10834277926-21379893425-70248821993-50926412030 |
| 5 | 49825 | 62628403457-54953268488-99818997311-93464095661-99772044635-92164943209-17521494984-21945783042-38536244491-28083888401 | 55908867377-87072757393-05794355403-55852568630-13599576089 |
+----+-------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
5 rows in set (0.00 sec)
--60秒点查测试
# sysbench --threads=16 --time=60 --report-interval=1 oltp_point_select --mysql-host=66.3.125.125 --mysql-port=3306 --mysql-user=root --mysql-password=root2023 \
--mysql-db=test --tables=4 --table-size=100000 run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 16
Report intermediate results every 1 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
--此处结果内容主要包含: 时间计数(1s意为1秒)、thds为线程数、tps为每秒事务数、qps为每秒查询数、r/w/o分别代表每秒的读/写/其他操作数
--lat(ms, 95%)时95%操作的耗时-单位为毫秒、err/s是每秒的错误数、reconn/s是每秒的重连数
[ 1s ] thds: 16 tps: 26905.31 qps: 26905.31 (r/w/o: 26905.31/0.00/0.00) lat (ms,95%): 0.65 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 16 tps: 29389.04 qps: 29389.04 (r/w/o: 29389.04/0.00/0.00) lat (ms,95%): 0.72 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 16 tps: 30498.78 qps: 30498.78 (r/w/o: 30498.78/0.00/0.00) lat (ms,95%): 0.68 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 16 tps: 22776.97 qps: 22776.97 (r/w/o: 22776.97/0.00/0.00) lat (ms,95%): 1.27 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 16 tps: 30643.61 qps: 30643.61 (r/w/o: 30643.61/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 16 tps: 22722.25 qps: 22722.25 (r/w/o: 22722.25/0.00/0.00) lat (ms,95%): 1.21 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 16 tps: 31585.17 qps: 31585.17 (r/w/o: 31585.17/0.00/0.00) lat (ms,95%): 0.64 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 16 tps: 30296.85 qps: 30296.85 (r/w/o: 30296.85/0.00/0.00) lat (ms,95%): 0.68 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 16 tps: 23705.46 qps: 23705.46 (r/w/o: 23705.46/0.00/0.00) lat (ms,95%): 0.90 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 16 tps: 30879.22 qps: 30879.22 (r/w/o: 30879.22/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 11s ] thds: 16 tps: 22564.61 qps: 22564.61 (r/w/o: 22564.61/0.00/0.00) lat (ms,95%): 0.95 err/s: 0.00 reconn/s: 0.00
[ 12s ] thds: 16 tps: 30561.08 qps: 30561.08 (r/w/o: 30561.08/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 13s ] thds: 16 tps: 28261.06 qps: 28261.06 (r/w/o: 28261.06/0.00/0.00) lat (ms,95%): 0.73 err/s: 0.00 reconn/s: 0.00
[ 14s ] thds: 16 tps: 21548.61 qps: 21548.61 (r/w/o: 21548.61/0.00/0.00) lat (ms,95%): 1.18 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 16 tps: 27673.56 qps: 27673.56 (r/w/o: 27673.56/0.00/0.00) lat (ms,95%): 0.74 err/s: 0.00 reconn/s: 0.00
[ 16s ] thds: 16 tps: 20636.60 qps: 20636.60 (r/w/o: 20636.60/0.00/0.00) lat (ms,95%): 1.27 err/s: 0.00 reconn/s: 0.00
[ 17s ] thds: 16 tps: 27885.83 qps: 27885.83 (r/w/o: 27885.83/0.00/0.00) lat (ms,95%): 0.73 err/s: 0.00 reconn/s: 0.00
[ 18s ] thds: 16 tps: 28684.66 qps: 28685.66 (r/w/o: 28685.66/0.00/0.00) lat (ms,95%): 0.74 err/s: 0.00 reconn/s: 0.00
[ 19s ] thds: 16 tps: 25480.74 qps: 25479.74 (r/w/o: 25479.74/0.00/0.00) lat (ms,95%): 0.84 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 16 tps: 30483.03 qps: 30483.03 (r/w/o: 30483.03/0.00/0.00) lat (ms,95%): 0.68 err/s: 0.00 reconn/s: 0.00
[ 21s ] thds: 16 tps: 22042.51 qps: 22042.51 (r/w/o: 22042.51/0.00/0.00) lat (ms,95%): 1.25 err/s: 0.00 reconn/s: 0.00
[ 22s ] thds: 16 tps: 30604.82 qps: 30604.82 (r/w/o: 30604.82/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 23s ] thds: 16 tps: 29589.29 qps: 29589.29 (r/w/o: 29589.29/0.00/0.00) lat (ms,95%): 0.70 err/s: 0.00 reconn/s: 0.00
[ 24s ] thds: 16 tps: 24282.99 qps: 24282.99 (r/w/o: 24282.99/0.00/0.00) lat (ms,95%): 0.86 err/s: 0.00 reconn/s: 0.00
[ 25s ] thds: 16 tps: 31246.92 qps: 31246.92 (r/w/o: 31246.92/0.00/0.00) lat (ms,95%): 0.64 err/s: 0.00 reconn/s: 0.00
[ 26s ] thds: 16 tps: 22876.61 qps: 22876.61 (r/w/o: 22876.61/0.00/0.00) lat (ms,95%): 1.08 err/s: 0.00 reconn/s: 0.00
[ 27s ] thds: 16 tps: 31529.39 qps: 31529.39 (r/w/o: 31529.39/0.00/0.00) lat (ms,95%): 0.64 err/s: 0.00 reconn/s: 0.00
[ 28s ] thds: 16 tps: 29517.51 qps: 29517.51 (r/w/o: 29517.51/0.00/0.00) lat (ms,95%): 0.69 err/s: 0.00 reconn/s: 0.00
[ 29s ] thds: 16 tps: 26343.56 qps: 26343.56 (r/w/o: 26343.56/0.00/0.00) lat (ms,95%): 0.89 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 16 tps: 31113.37 qps: 31113.37 (r/w/o: 31113.37/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 31s ] thds: 16 tps: 24066.86 qps: 24066.86 (r/w/o: 24066.86/0.00/0.00) lat (ms,95%): 0.83 err/s: 0.00 reconn/s: 0.00
[ 32s ] thds: 16 tps: 30315.40 qps: 30315.40 (r/w/o: 30315.40/0.00/0.00) lat (ms,95%): 0.68 err/s: 0.00 reconn/s: 0.00
[ 33s ] thds: 16 tps: 29995.12 qps: 29995.12 (r/w/o: 29995.12/0.00/0.00) lat (ms,95%): 0.69 err/s: 0.00 reconn/s: 0.00
[ 34s ] thds: 16 tps: 23322.28 qps: 23322.28 (r/w/o: 23322.28/0.00/0.00) lat (ms,95%): 0.94 err/s: 0.00 reconn/s: 0.00
[ 35s ] thds: 16 tps: 30676.67 qps: 30677.67 (r/w/o: 30677.67/0.00/0.00) lat (ms,95%): 0.65 err/s: 0.00 reconn/s: 0.00
[ 36s ] thds: 16 tps: 23831.21 qps: 23831.21 (r/w/o: 23831.21/0.00/0.00) lat (ms,95%): 1.01 err/s: 0.00 reconn/s: 0.00
[ 37s ] thds: 16 tps: 31442.98 qps: 31441.98 (r/w/o: 31441.98/0.00/0.00) lat (ms,95%): 0.64 err/s: 0.00 reconn/s: 0.00
[ 38s ] thds: 16 tps: 29257.83 qps: 29257.83 (r/w/o: 29257.83/0.00/0.00) lat (ms,95%): 0.69 err/s: 0.00 reconn/s: 0.00
[ 39s ] thds: 16 tps: 24508.15 qps: 24508.15 (r/w/o: 24508.15/0.00/0.00) lat (ms,95%): 0.99 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 16 tps: 30816.09 qps: 30816.09 (r/w/o: 30816.09/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 41s ] thds: 16 tps: 23236.84 qps: 23236.84 (r/w/o: 23236.84/0.00/0.00) lat (ms,95%): 0.95 err/s: 0.00 reconn/s: 0.00
[ 42s ] thds: 16 tps: 29849.10 qps: 29849.10 (r/w/o: 29849.10/0.00/0.00) lat (ms,95%): 0.70 err/s: 0.00 reconn/s: 0.00
[ 43s ] thds: 16 tps: 29130.52 qps: 29130.52 (r/w/o: 29130.52/0.00/0.00) lat (ms,95%): 0.73 err/s: 0.00 reconn/s: 0.00
[ 44s ] thds: 16 tps: 23340.17 qps: 23340.17 (r/w/o: 23340.17/0.00/0.00) lat (ms,95%): 0.86 err/s: 0.00 reconn/s: 0.00
[ 45s ] thds: 16 tps: 29494.52 qps: 29494.52 (r/w/o: 29494.52/0.00/0.00) lat (ms,95%): 0.69 err/s: 0.00 reconn/s: 0.00
[ 46s ] thds: 16 tps: 22966.11 qps: 22966.11 (r/w/o: 22966.11/0.00/0.00) lat (ms,95%): 0.83 err/s: 0.00 reconn/s: 0.00
[ 47s ] thds: 16 tps: 30129.21 qps: 30129.21 (r/w/o: 30129.21/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 48s ] thds: 16 tps: 29165.29 qps: 29165.29 (r/w/o: 29165.29/0.00/0.00) lat (ms,95%): 0.70 err/s: 0.00 reconn/s: 0.00
[ 49s ] thds: 16 tps: 23268.56 qps: 23268.56 (r/w/o: 23268.56/0.00/0.00) lat (ms,95%): 0.97 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 16 tps: 30788.20 qps: 30788.20 (r/w/o: 30788.20/0.00/0.00) lat (ms,95%): 0.65 err/s: 0.00 reconn/s: 0.00
[ 51s ] thds: 16 tps: 19082.94 qps: 19082.94 (r/w/o: 19082.94/0.00/0.00) lat (ms,95%): 2.03 err/s: 0.00 reconn/s: 0.00
[ 52s ] thds: 16 tps: 29830.84 qps: 29830.84 (r/w/o: 29830.84/0.00/0.00) lat (ms,95%): 0.72 err/s: 0.00 reconn/s: 0.00
[ 53s ] thds: 16 tps: 29476.39 qps: 29476.39 (r/w/o: 29476.39/0.00/0.00) lat (ms,95%): 0.70 err/s: 0.00 reconn/s: 0.00
[ 54s ] thds: 16 tps: 23153.58 qps: 23153.58 (r/w/o: 23153.58/0.00/0.00) lat (ms,95%): 0.95 err/s: 0.00 reconn/s: 0.00
[ 55s ] thds: 16 tps: 29153.81 qps: 29153.81 (r/w/o: 29153.81/0.00/0.00) lat (ms,95%): 0.70 err/s: 0.00 reconn/s: 0.00
[ 56s ] thds: 16 tps: 23450.91 qps: 23450.91 (r/w/o: 23450.91/0.00/0.00) lat (ms,95%): 0.90 err/s: 0.00 reconn/s: 0.00
[ 57s ] thds: 16 tps: 30307.30 qps: 30307.30 (r/w/o: 30307.30/0.00/0.00) lat (ms,95%): 0.67 err/s: 0.00 reconn/s: 0.00
[ 58s ] thds: 16 tps: 29204.35 qps: 29204.35 (r/w/o: 29204.35/0.00/0.00) lat (ms,95%): 0.70 err/s: 0.00 reconn/s: 0.00
[ 59s ] thds: 16 tps: 21223.78 qps: 21223.78 (r/w/o: 21223.78/0.00/0.00) lat (ms,95%): 1.18 err/s: 0.00 reconn/s: 0.00
--SQL统计信息,SQL的读/写/其他/总计次数、总事务数及每秒事务数、总查询数及每秒查询数、忽略错误数据、重新数据
SQL statistics:
queries performed:
read: 1637657
write: 0
other: 0
total: 1637657
transactions: 1637657 (27292.23 per sec.)
queries: 1637657 (27292.23 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
--通用统计信息:总时间、总操作数
General statistics:
total time: 60.0026s
total number of events: 1637657
--耗时信息(单位毫秒):最小、平均、最大、95%耗时、总耗时
Latency (ms):
min: 0.35
avg: 0.59
max: 19.81
95th percentile: 0.75
sum: 959077.57
Threads fairness:
events (avg/stddev): 102353.5625/5226.65
execution time (avg/stddev): 59.9423/0.00
场景:4张表,每张表个10万行,16线程 - 读写 oltp_read_write
--60秒读写
# sysbench --threads=16 --time=60 --report-interval=1 oltp_read_write --mysql-host=66.3.125.125 --mysql-port=3306 --mysql-user=root --mysql-password=root2023 \
--mysql-db=test --tables=4 --table-size=100000 run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 16
Report intermediate results every 1 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
--此处结果内容主要包含: 时间计数(1s意为1秒)、thds为线程数、tps为每秒事务数、qps为每秒查询数、r/w/o分别代表每秒的读/写/其他操作数
--lat(ms, 95%)时95%操作的耗时-单位为毫秒、err/s是每秒的错误数、reconn/s是每秒的重连数
[ 1s ] thds: 16 tps: 850.05 qps: 17191.55 (r/w/o: 12053.34/3422.15/1716.06) lat (ms,95%): 27.17 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 16 tps: 811.05 qps: 16189.10 (r/w/o: 11340.77/3227.22/1621.11) lat (ms,95%): 44.17 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 16 tps: 1101.64 qps: 22027.85 (r/w/o: 15419.00/4404.57/2204.28) lat (ms,95%): 16.71 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 16 tps: 1075.49 qps: 21530.73 (r/w/o: 15073.81/4305.95/2150.97) lat (ms,95%): 17.32 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 16 tps: 801.10 qps: 16045.97 (r/w/o: 11236.38/3208.39/1601.20) lat (ms,95%): 52.89 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 16 tps: 1082.76 qps: 21662.30 (r/w/o: 15165.71/4330.06/2166.53) lat (ms,95%): 17.32 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 16 tps: 761.08 qps: 15211.66 (r/w/o: 10649.16/3042.33/1520.17) lat (ms,95%): 49.21 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 16 tps: 1076.98 qps: 21531.62 (r/w/o: 15056.74/4319.92/2154.96) lat (ms,95%): 17.95 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 16 tps: 1066.95 qps: 21302.97 (r/w/o: 14914.28/4254.79/2133.90) lat (ms,95%): 17.63 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 16 tps: 681.07 qps: 13618.31 (r/w/o: 9528.91/2730.26/1359.13) lat (ms,95%): 69.29 err/s: 0.00 reconn/s: 0.00
[ 11s ] thds: 16 tps: 1112.85 qps: 22264.06 (r/w/o: 15586.94/4448.41/2228.71) lat (ms,95%): 17.01 err/s: 0.00 reconn/s: 0.00
[ 12s ] thds: 16 tps: 752.84 qps: 15131.86 (r/w/o: 10579.81/3045.37/1506.69) lat (ms,95%): 58.92 err/s: 0.00 reconn/s: 0.00
[ 13s ] thds: 16 tps: 1098.32 qps: 21904.34 (r/w/o: 15351.44/4356.26/2196.64) lat (ms,95%): 17.32 err/s: 0.00 reconn/s: 0.00
[ 14s ] thds: 16 tps: 970.85 qps: 19442.90 (r/w/o: 13609.83/3891.38/1941.69) lat (ms,95%): 19.29 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 16 tps: 773.18 qps: 15459.62 (r/w/o: 10828.53/3084.72/1546.36) lat (ms,95%): 59.99 err/s: 0.00 reconn/s: 0.00
[ 16s ] thds: 16 tps: 1062.01 qps: 21222.24 (r/w/o: 14842.17/4256.05/2124.02) lat (ms,95%): 19.29 err/s: 0.00 reconn/s: 0.00
[ 17s ] thds: 16 tps: 712.95 qps: 14246.94 (r/w/o: 9980.26/2840.79/1425.89) lat (ms,95%): 59.99 err/s: 0.00 reconn/s: 0.00
[ 18s ] thds: 16 tps: 1053.95 qps: 21143.99 (r/w/o: 14800.29/4235.80/2107.90) lat (ms,95%): 19.65 err/s: 0.00 reconn/s: 0.00
[ 19s ] thds: 16 tps: 1101.93 qps: 22045.65 (r/w/o: 15432.05/4409.73/2203.86) lat (ms,95%): 17.01 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 16 tps: 759.16 qps: 15124.24 (r/w/o: 10587.27/3019.65/1517.32) lat (ms,95%): 61.08 err/s: 0.00 reconn/s: 0.00
[ 21s ] thds: 16 tps: 1095.75 qps: 21946.00 (r/w/o: 15366.50/4388.00/2191.50) lat (ms,95%): 16.71 err/s: 0.00 reconn/s: 0.00
[ 22s ] thds: 16 tps: 756.07 qps: 15209.36 (r/w/o: 10630.95/3065.27/1513.14) lat (ms,95%): 52.89 err/s: 0.00 reconn/s: 0.00
[ 23s ] thds: 16 tps: 1082.06 qps: 21555.26 (r/w/o: 15097.88/4293.25/2164.13) lat (ms,95%): 19.65 err/s: 0.00 reconn/s: 0.00
[ 24s ] thds: 16 tps: 990.90 qps: 19767.95 (r/w/o: 13841.57/3944.59/1981.79) lat (ms,95%): 30.26 err/s: 0.00 reconn/s: 0.00
[ 25s ] thds: 16 tps: 744.12 qps: 14928.48 (r/w/o: 10450.74/2989.50/1488.25) lat (ms,95%): 54.83 err/s: 0.00 reconn/s: 0.00
[ 26s ] thds: 16 tps: 1037.85 qps: 20736.04 (r/w/o: 14510.93/4150.41/2074.70) lat (ms,95%): 21.89 err/s: 0.00 reconn/s: 0.00
[ 27s ] thds: 16 tps: 667.88 qps: 13342.61 (r/w/o: 9335.33/2670.52/1336.76) lat (ms,95%): 69.29 err/s: 0.00 reconn/s: 0.00
[ 28s ] thds: 16 tps: 1070.99 qps: 21434.72 (r/w/o: 15009.80/4282.94/2141.97) lat (ms,95%): 17.95 err/s: 0.00 reconn/s: 0.00
[ 29s ] thds: 16 tps: 1070.16 qps: 21409.29 (r/w/o: 14990.30/4279.66/2139.33) lat (ms,95%): 17.32 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 16 tps: 774.04 qps: 15489.75 (r/w/o: 10836.52/3105.15/1548.07) lat (ms,95%): 62.19 err/s: 0.00 reconn/s: 0.00
[ 31s ] thds: 16 tps: 1107.76 qps: 22127.17 (r/w/o: 15494.62/4418.04/2214.52) lat (ms,95%): 16.71 err/s: 0.00 reconn/s: 0.00
[ 32s ] thds: 16 tps: 777.29 qps: 15545.86 (r/w/o: 10872.10/3117.18/1556.59) lat (ms,95%): 47.47 err/s: 0.00 reconn/s: 0.00
[ 33s ] thds: 16 tps: 1080.79 qps: 21628.88 (r/w/o: 15144.12/4323.18/2161.59) lat (ms,95%): 17.32 err/s: 0.00 reconn/s: 0.00
[ 34s ] thds: 16 tps: 984.89 qps: 19685.82 (r/w/o: 13780.48/3935.57/1969.78) lat (ms,95%): 18.28 err/s: 0.00 reconn/s: 0.00
[ 35s ] thds: 16 tps: 791.22 qps: 15754.48 (r/w/o: 11018.13/3154.90/1581.45) lat (ms,95%): 51.94 err/s: 0.00 reconn/s: 0.00
[ 36s ] thds: 16 tps: 1067.87 qps: 21341.44 (r/w/o: 14931.21/4273.49/2136.74) lat (ms,95%): 19.29 err/s: 0.00 reconn/s: 0.00
[ 37s ] thds: 16 tps: 752.13 qps: 15124.64 (r/w/o: 10607.85/3012.52/1504.26) lat (ms,95%): 52.89 err/s: 0.00 reconn/s: 0.00
[ 38s ] thds: 16 tps: 982.76 qps: 19580.31 (r/w/o: 13690.72/3925.06/1964.53) lat (ms,95%): 32.53 err/s: 0.00 reconn/s: 0.00
[ 39s ] thds: 16 tps: 1110.14 qps: 22319.86 (r/w/o: 15629.00/4469.57/2221.28) lat (ms,95%): 16.41 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 16 tps: 680.97 qps: 13617.32 (r/w/o: 9541.52/2713.86/1361.93) lat (ms,95%): 58.92 err/s: 0.00 reconn/s: 0.00
[ 41s ] thds: 16 tps: 1111.87 qps: 22208.31 (r/w/o: 15549.12/4436.46/2222.73) lat (ms,95%): 16.71 err/s: 0.00 reconn/s: 0.00
[ 42s ] thds: 16 tps: 805.03 qps: 16108.54 (r/w/o: 11267.38/3231.11/1610.05) lat (ms,95%): 37.56 err/s: 0.00 reconn/s: 0.00
[ 43s ] thds: 16 tps: 1045.95 qps: 20910.98 (r/w/o: 14639.28/4179.80/2091.90) lat (ms,95%): 17.95 err/s: 0.00 reconn/s: 0.00
[ 44s ] thds: 16 tps: 1094.33 qps: 21819.55 (r/w/o: 15269.58/4364.31/2185.66) lat (ms,95%): 17.01 err/s: 0.00 reconn/s: 0.00
[ 45s ] thds: 16 tps: 783.97 qps: 15710.35 (r/w/o: 10996.55/3141.87/1571.94) lat (ms,95%): 51.02 err/s: 0.00 reconn/s: 0.00
[ 46s ] thds: 16 tps: 1038.84 qps: 20800.89 (r/w/o: 14565.82/4157.38/2077.69) lat (ms,95%): 20.00 err/s: 0.00 reconn/s: 0.00
[ 47s ] thds: 16 tps: 857.18 qps: 17127.60 (r/w/o: 11987.52/3425.72/1714.36) lat (ms,95%): 42.61 err/s: 0.00 reconn/s: 0.00
[ 48s ] thds: 16 tps: 775.87 qps: 15554.33 (r/w/o: 10891.13/3111.47/1551.73) lat (ms,95%): 24.38 err/s: 0.00 reconn/s: 0.00
[ 49s ] thds: 16 tps: 1065.00 qps: 21241.01 (r/w/o: 14862.01/4249.00/2130.00) lat (ms,95%): 18.95 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 16 tps: 671.06 qps: 13512.29 (r/w/o: 9480.90/2690.26/1341.13) lat (ms,95%): 63.32 err/s: 0.00 reconn/s: 0.00
[ 51s ] thds: 16 tps: 1084.98 qps: 21700.59 (r/w/o: 15188.71/4340.92/2170.96) lat (ms,95%): 17.01 err/s: 0.00 reconn/s: 0.00
[ 52s ] thds: 16 tps: 884.84 qps: 17622.83 (r/w/o: 12318.78/3536.36/1767.68) lat (ms,95%): 31.94 err/s: 0.00 reconn/s: 0.00
[ 53s ] thds: 16 tps: 979.12 qps: 19590.36 (r/w/o: 13714.65/3916.47/1959.24) lat (ms,95%): 28.67 err/s: 0.00 reconn/s: 0.00
[ 54s ] thds: 16 tps: 1097.01 qps: 21962.12 (r/w/o: 15383.09/4384.02/2195.01) lat (ms,95%): 17.01 err/s: 0.00 reconn/s: 0.00
[ 55s ] thds: 16 tps: 780.05 qps: 15610.91 (r/w/o: 10919.63/3131.18/1560.09) lat (ms,95%): 59.99 err/s: 0.00 reconn/s: 0.00
[ 56s ] thds: 16 tps: 1085.05 qps: 21662.94 (r/w/o: 15161.66/4332.19/2169.09) lat (ms,95%): 17.63 err/s: 0.00 reconn/s: 0.00
[ 57s ] thds: 16 tps: 906.00 qps: 18179.06 (r/w/o: 12727.04/3639.01/1813.01) lat (ms,95%): 30.26 err/s: 0.00 reconn/s: 0.00
[ 58s ] thds: 16 tps: 943.95 qps: 18825.03 (r/w/o: 13173.32/3764.81/1886.90) lat (ms,95%): 25.74 err/s: 0.00 reconn/s: 0.00
[ 59s ] thds: 16 tps: 1110.87 qps: 22218.32 (r/w/o: 15554.12/4441.46/2222.73) lat (ms,95%): 17.01 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 16 tps: 796.00 qps: 15868.00 (r/w/o: 11099.00/3177.00/1592.00) lat (ms,95%): 52.89 err/s: 0.00 reconn/s: 0.00
--SQL统计信息,SQL的读/写/其他/总计次数、总事务数及每秒事务数、总查询数及每秒查询数、忽略错误数据、重新数据
SQL statistics:
queries performed:
read: 787738
write: 225068
other: 112534
total: 1125340
transactions: 56267 (937.50 per sec.)
queries: 1125340 (18750.05 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
--通用统计信息:总时间、总操作数
General statistics:
total time: 60.0162s
total number of events: 56267
--耗时信息(单位毫秒):最小、平均、最大、95%耗时、总耗时
Latency (ms):
min: 10.73
avg: 17.06
max: 311.71
95th percentile: 28.67
sum: 960075.64
Threads fairness:
events (avg/stddev): 3516.6875/178.13
execution time (avg/stddev): 60.0047/0.00
--清理
# sysbench --threads=16 --time=60 --report-interval=1 oltp_read_write --mysql-host=66.3.125.125 --mysql-port=3306 --mysql-user=root --mysql-password=root2023 \
--mysql-db=test --tables=4 --table-size=100000 cleanup
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)
关闭数据库
$ mysqladmin shutdown -uroot -proot2023
mysqladmin: [Warning] Using a password on the command line interface can be insecure.