首先下载安装sysbench:

sudo apt-get install sysbench -y

查看一下sysbench版本是多少:

zifeiy@zifeiy-S1-Series:~$ sysbench --version
sysbench 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 prepare
sysbench 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 run
sysbench 1.0.11 (using system LuaJIT 2.1.0-beta3) Running the test with following options:
Number of threads: 128
Report intermediate results every 10 second(s)
Initializing random number generator from current time Initializing 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.00
SQL 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: 290145 Latency (ms):
min: 1.36
avg: 52.94
max: 1248.60
95th percentile: 130.13
sum: 15361679.30 Threads 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 cleanup
sysbench 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'...

ubuntu 18.04使用sysbench测试MySQL性能的更多相关文章

  1. Ubuntu 18.04上安装Apache, MySQL, PHP, LAMP

    1.安装 Apache $ sudo apt update && sudo apt install apache2 中间会遇到停顿询问是否继续, 输入 y 然后 回车. 2.测试 Ap ...

  2. sysbench 测试mysql性能

    ===== #1sysbench --test=oltp --oltp-table-size=10000 --mysql-db=test --mysql-user=root --mysql-passw ...

  3. Ubuntu 18.04 使用Systemd管理MySQL 5.6

    转自:https://blog.csdn.net/skykingf/article/details/45225981 如何用Systemd管理 general 包安装的MySQL呢? 首先看看yum安 ...

  4. Ubuntu 18.04 下如何配置mysql 及 配置远程连接

    首先是大家都知道的老三套,啥也不说上来就放三个大招: sudo apt-get install mysql-server sudo apt isntall mysql-client sudo apt ...

  5. Ubuntu 18.04上安装 phpMyAdmin

    我们将安装 phpMyAdmin 在 Ubuntu18.04 上配合 Apache 一起工作. 在安装 phpMyAdmin 之前需要已经安装了LAMP栈并提供了web页面. 如果没有安装可以参照 U ...

  6. Ubuntu 18.04 安装MySQL

    最近在写东西的时候,需要用到MySQL,在网上查了一下,都说Ubuntu18.04不能安装MySQL5.7.22, 总觉的不可能,所以自己就研究了一下,然后分享给大家 工具/原料   VMware W ...

  7. 记录在Ubuntu 18.04系统中安装Apache, MySQL和PHP环境

    虽然我们在Linux VPS.服务器安装WEB环境比较方便,可以选择面板或者一键包,但是有些我们需要深入学习的网友不会选择一键安装,而是会尝试编译安装.这样可以学到一些内在的技术.一般我们较为习惯选择 ...

  8. Ubuntu 18.04 系统配置 NPM环境和mysql数据库问题解决

    Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境. Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高效. 今天我就为大家 使用 Ubun ...

  9. 在Ubuntu 18.04 安装 MySQL 8.0

    在Ubuntu 18.04 安装 MySQL 8.0 ① 登入 mysql 官网,在官网中下载 deb 包,点击该链接,即可下载. https://dev.mysql.com/downloads/re ...

随机推荐

  1. placeholder这个属性 input

    input是一个很常见的标签,大家使用的也很常见,但是我在具体的工作中发现要想完美的使用这个标签还是任重而道远,下面是我碰到的几个问题. 1.我们在使用这个标签的时候会习惯的加上placeholder ...

  2. Kubernetes 学习12 kubernetes 存储卷

    一.概述 1.我们此前讲过根据应用本身是否需要持久存储数据以及某一次请求和之前的请求是否有联系,可以分为四类应用 a.有状态,要存储 b.有状态,无持久存储 c.无状态,要存储 d.无状态,无持久存储 ...

  3. (尚003).Vue_模板语法

    1.双大括号表达式 2.指令一:强制数据绑定 3.指令二;绑定事件监听 test003.html<!DOCTYPE html><html lang="en"> ...

  4. 系统字体放大导致rem布局错乱,解决方案,已通过测试

    如果你用rem没遇到过坑,那只能说明你 too young too simple; (function (doc, win) { var resizeEvt = 'orientationchange' ...

  5. pyy整队 线段树

    pyy整队 线段树 问题描述: 众所周知pyy当了班长,服务于民.一天体育课,趁体育老师还没来,pyy让班里n个同学先排好 队.老师不在,同学们开始玩起了手机.站在队伍前端玩手机,前面的人少了,谁都顶 ...

  6. AUC,ROC我看到的最透彻的讲解

      版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/u013385925/article/d ...

  7. BAT 电脑名 用户名

    @echo offecho 当前盘符:%~d0echo 当前登陆用户:%username%echo 当前盘符和路径:%~dp0echo 当前盘符和路径的短文件名格式:%~sdp0echo 当前批处理全 ...

  8. NPAPI绘图和事件处理

    https://developer.mozilla.org/en-US/docs/Plugins/Guide/Drawing_and_Event_Handling 本章介绍如何确定插件实例是窗口化还是 ...

  9. cv2.warpAffine 参数详解

    本文链接:https://blog.csdn.net/qq878594585/article/details/81838260本文为作者原创文章,未经同意严禁转载! opencv中的仿射变换在pyth ...

  10. arcpy arcgis python实例教程--原点夹角距离定义线(坐标正算)

    arcpy arcgis python实例教程--原点夹角距离定义线(坐标正算) 商务合作,科技咨询,版权转让:向日葵,135-4855__4328,xiexiaokui#qq.com 此地理处理工具 ...