博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ubuntu 18.04使用sysbench测试MySQL性能
阅读量:4652 次
发布时间:2019-06-09

本文共 6540 字,大约阅读时间需要 21 分钟。

首先下载安装sysbench:

sudo apt-get install sysbench -y

查看一下sysbench版本是多少:

zifeiy@zifeiy-S1-Series:~$ sysbench --versionsysbench 1.0.11

这个版本根一些书上的比较旧的版本稍有一些参数不一样,要注意。

在MySQL中新建一个名为testdb的database:

mysql> CREATE DATABASE IF NOT EXISTS testdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;Query OK, 1 row affected, 2 warnings (0.05 sec)

执行如下命令进行测试:

sysbench /usr/share/sysbench/oltp_write_only.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=testdb --db-driver=mysql --tables=10 --table_size=1000000 --report-interval=10 --threads=128 --time=120 prepare|run|cleanup

也就是分三步走:

1.准备数据

sysbench /usr/share/sysbench/oltp_write_only.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=testdb --db-driver=mysql --tables=10 --table_size=1000000 --report-interval=10 --threads=128 --time=120 prepare

显示信息:

zifeiy@zifeiy-S1-Series:~$ sysbench /usr/share/sysbench/oltp_write_only.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=testdb --db-driver=mysql --tables=10 --table_size=1000000 --report-interval=10 --threads=128 --time=120 preparesysbench 1.0.11 (using system LuaJIT 2.1.0-beta3)Initializing worker threads...Creating table 'sbtest1'...Creating table 'sbtest6'...Creating table 'sbtest7'...Creating table 'sbtest9'...Creating table 'sbtest2'...Creating table 'sbtest8'...Creating table 'sbtest4'...Creating table 'sbtest5'...Creating table 'sbtest10'...Creating table 'sbtest3'...Inserting 1000000 records into 'sbtest7'Inserting 1000000 records into 'sbtest4'Inserting 1000000 records into 'sbtest8'Inserting 1000000 records into 'sbtest2'Inserting 1000000 records into 'sbtest9'Inserting 1000000 records into 'sbtest6'Inserting 1000000 records into 'sbtest3'Inserting 1000000 records into 'sbtest10'Inserting 1000000 records into 'sbtest1'Inserting 1000000 records into 'sbtest5'Creating a secondary index on 'sbtest10'...Creating a secondary index on 'sbtest8'...Creating a secondary index on 'sbtest2'...Creating a secondary index on 'sbtest7'...Creating a secondary index on 'sbtest3'...Creating a secondary index on 'sbtest5'...Creating a secondary index on 'sbtest6'...Creating a secondary index on 'sbtest1'...Creating a secondary index on 'sbtest4'...Creating a secondary index on 'sbtest9'...

2.运行以测试

sysbench /usr/share/sysbench/oltp_write_only.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=testdb --db-driver=mysql --tables=10 --table_size=1000000 --report-interval=10 --threads=128 --time=120 run

显示信息:

zifeiy@zifeiy-S1-Series:~$ sysbench /usr/share/sysbench/oltp_write_only.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=testdb --db-driver=mysql --tables=10 --table_size=1000000 --report-interval=10 --threads=128 --time=120 runsysbench 1.0.11 (using system LuaJIT 2.1.0-beta3)Running the test with following options:Number of threads: 128Report intermediate results every 10 second(s)Initializing random number generator from current timeInitializing worker threads...Threads started![ 10s ] thds: 128 tps: 630.48 qps: 3826.40 (r/w/o: 0.00/2552.33/1274.07) lat (ms,95%): 580.02 err/s: 0.30 reconn/s: 0.00[ 20s ] thds: 128 tps: 1911.67 qps: 11457.64 (r/w/o: 0.00/7633.90/3823.75) lat (ms,95%): 189.93 err/s: 0.40 reconn/s: 0.00[ 30s ] thds: 128 tps: 2713.62 qps: 16306.79 (r/w/o: 0.00/10878.86/5427.93) lat (ms,95%): 114.72 err/s: 0.70 reconn/s: 0.00[ 40s ] thds: 128 tps: 2571.20 qps: 15423.28 (r/w/o: 0.00/10280.98/5142.29) lat (ms,95%): 118.92 err/s: 1.00 reconn/s: 0.00[ 50s ] thds: 128 tps: 2658.13 qps: 15944.05 (r/w/o: 0.00/10625.50/5318.55) lat (ms,95%): 108.68 err/s: 1.30 reconn/s: 0.00[ 60s ] thds: 128 tps: 2601.99 qps: 15597.92 (r/w/o: 0.00/10395.75/5202.17) lat (ms,95%): 110.66 err/s: 1.00 reconn/s: 0.00[ 70s ] thds: 128 tps: 2666.24 qps: 16016.36 (r/w/o: 0.00/10679.08/5337.29) lat (ms,95%): 112.67 err/s: 1.90 reconn/s: 0.00[ 80s ] thds: 128 tps: 2403.12 qps: 14405.61 (r/w/o: 0.00/9599.07/4806.54) lat (ms,95%): 130.13 err/s: 0.60 reconn/s: 0.00[ 90s ] thds: 128 tps: 2846.27 qps: 17099.03 (r/w/o: 0.00/11405.19/5693.84) lat (ms,95%): 102.97 err/s: 1.00 reconn/s: 0.00[ 100s ] thds: 128 tps: 2759.08 qps: 16561.49 (r/w/o: 0.00/11042.22/5519.26) lat (ms,95%): 118.92 err/s: 1.10 reconn/s: 0.00[ 110s ] thds: 128 tps: 2668.21 qps: 16006.77 (r/w/o: 0.00/10671.75/5335.02) lat (ms,95%): 112.67 err/s: 1.00 reconn/s: 0.00[ 120s ] thds: 128 tps: 2571.56 qps: 15433.17 (r/w/o: 0.00/10286.65/5146.52) lat (ms,95%): 118.92 err/s: 1.10 reconn/s: 0.00SQL statistics:    queries performed:        read:                            0        write:                           1160697        other:                           580404        total:                           1741101    transactions:                        290145 (2417.05 per sec.)    queries:                             1741101 (14504.22 per sec.)    ignored errors:                      114    (0.95 per sec.)    reconnects:                          0      (0.00 per sec.)General statistics:    total time:                          120.0394s    total number of events:              290145Latency (ms):         min:                                  1.36         avg:                                 52.94         max:                               1248.60         95th percentile:                    130.13         sum:                            15361679.30Threads fairness:    events (avg/stddev):           2266.7578/46.19    execution time (avg/stddev):   120.0131/0.01

3.清理数据

sysbench /usr/share/sysbench/oltp_write_only.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=testdb --db-driver=mysql --tables=10 --table_size=1000000 --report-interval=10 --threads=128 --time=120 cleanup

(电脑崩了一次~~重启)

显示信息:

zifeiy@zifeiy-S1-Series:~$ sysbench /usr/share/sysbench/oltp_write_only.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=password --mysql-db=testdb --db-driver=mysql --tables=10 --table_size=1000000 --report-interval=10 --threads=128 --time=120 cleanupsysbench 1.0.11 (using system LuaJIT 2.1.0-beta3)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'...Dropping table 'sbtest10'...

转载于:https://www.cnblogs.com/zifeiy/p/10271348.html

你可能感兴趣的文章
CentOS或Redhat上装memcached (包括64位系统)
查看>>
C 字符串数组排序
查看>>
ios开发学习--列表(Table)效果源码分享--系列教程4
查看>>
Modified判断Tedit TMemo类型的文件是否修改过
查看>>
python基础-对象
查看>>
如何使函数不生成执行代码
查看>>
MySQL 数据库设计 笔记与总结(3)物理设计
查看>>
第5周团队作业1:项目建议
查看>>
抠图划线
查看>>
HDU 4897 Little Devil I(树链剖分)(2014 Multi-University Training Contest 4)
查看>>
jmeter 参数化学习笔记
查看>>
Convert the AScii to SAC file
查看>>
PAT (Basic Level) Practise 1002. 写出这个数
查看>>
SxsTrace
查看>>
How to correctly use preventDefault(), stopPropagation(), or return false; on events
查看>>
How to: Update an .edmx File when the Database Changes
查看>>
纯CSS3绘制的猫咪老师——献给喜欢CSS3及《夏目友人帐》的你
查看>>
Mysql卸载
查看>>
Android事件分发机制
查看>>
linux之sleep
查看>>