sysbench对自装MySQL数据库进行基准测试

摘要:
1、 安装sysbenchwgethttps://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.shchmod+xscript.rp.sh./script.rpm。Shyumnstall ysysbench II。准备测试台系统试验台//基于MySQL驱动程序连接到MySQL数据库--dbdriver=mys

一、 安装sysbench

wget https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh
chmod +x script.rpm.sh
./script.rpm.sh
yum install -y sysbench

二、准备测试表

sysbench 
//基于mysql的驱动去连接mysql数据库
--db-driver=mysql 
//连续访问300秒
--time=300 
//10个线程模拟并发访问
--threads=10 
//每隔1秒输出一下压测情况
--report-interval=1 
//本机
--mysql-host=127.0.0.1 
//端口号:3306
--mysql-port=3306 
//测试用户
--mysql-user=root 
//测试密码
--mysql-password=******* 
//测试数据库
--mysql-db=test_db 
//模拟新建20个表
--tables=20 
//100万条数据 执行oltp数据库的读写测试
--table_size=1000000 oltp_read_write 
//参照这个命令的设置去构造出来我们需要的数据库里的数据
//自动创建20个测试表,每个表里创建100万条测试数据
--db-ps-mode=disable prepare

执行命令:

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare

执行命令之后:

sysbench对自装MySQL数据库进行基准测试第1张

三、开始测试

测试机配置

虚拟机  8vCPUs | 32GB | CentOS7.7 64bit |  MariaDB 10.4.12

1、测试综合TPS

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable run

执行命令后:

sysbench对自装MySQL数据库进行基准测试第2张

thds 压测线程数 | tps 每秒事务数 | qps 每秒请求数 | (r/w/o) 每秒的请求数中读请求个数/写请求个数/其他请求个数 | lat(ms,95%) 95% 的请求延迟都在多少以下 | err/s 错误数 | reconn/s 重连数

测试结果:

SQL statistics:
    queries performed:
        read:                            2468032                      #300s执行了246万读请求
        write:                           705152                       #300s执行了70万写请求
        other:                           352576                       #300s执行了30万其他请求
        total:                           3525760                      #300s执行了共352万请求
    transactions:                        176288 (587.61 per sec.)         #300s执行了共17万次事务(每秒587次事务)
    queries:                             3525760 (11752.14 per sec.)      #300s执行了查询共352万次请求(每秒1.1万次请求)
    ignored errors:                      0      (0.00 per sec.)           #300s忽略错误总数(每秒忽略错误次数)
    reconnects:                          0      (0.00 per sec.)           #300s重连总数(每秒重连次数)

General statistics:
    total time:                          300.0077s                      #总耗时
    total number of events:              176288                       #总发生的事务数

Latency (ms):
         min:                                    4.17                #最小延迟 4.17ms
         avg:                                   17.01                #平均延迟 17.01ms
         max:                                  418.77                #最大延迟 418.77ms
         95th percentile:                       44.98                #95%的请求延迟 44.98ms
         sum:                              2999093.13

Threads fairness:
    events (avg/stddev):           17628.8000/226.93
    execution time (avg/stddev):   299.9093/0.00

2、其他测试

只读性能 oltp_read_only

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_only --db-ps-mode=disable run

删除性能 oltp_delete

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_delete --db-ps-mode=disable run

更新索引字段性能 oltp_update_index

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_index --db-ps-mode=disable run

更新非索引字段性能 oltp_update_non_index

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_non_index --db-ps-mode=disable run

插入性能 oltp_insert

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_insert --db-ps-mode=disable run

写入性能 oltp_write_only

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_write_only --db-ps-mode=disable run

测试完成进行清理 CleanUp

sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable cleanup

免责声明:文章转载自《sysbench对自装MySQL数据库进行基准测试》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Kubernetes 边缘节点抓不到监控指标?试试这个方法!【opencv基础】OpenCV使用Viz模块3D可视化显示下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Docker mysql主从配置

一:Mysql基于Docker的主从复制搭建 1:安装docker,安装步骤可见我之前的文章:Docker-常用基建的安装与部署 docker ps 命令查询当前的容器状态,这就是我们最后要达到的效果。 2:首先拉取mysql官方镜像 bash> docker pull mysql:5.7 演示环境是在同一台服务器上部署。因为docker创建容器时...

Ubuntu16.04中Appium的安装和使用

准备工作 root@ranxf-TEST:/home/ranxf# conda create -n appium python=3.7 root@ranxf-TEST:/home/ranxf# conda info -e # conda environments: # base * /root/anaconda3 ap...

Mysql全文索引的使用

前言 在MySQL 5.6版本以前,只有MyISAM存储引擎支持全文引擎.在5.6版本中,InnoDB加入了对全文索引的支持,但是不支持中文全文索引.在5.7.6版本,MySQL内置了ngram全文解析器,用来支持亚洲语种的分词. 在学习之前,请确认自己的MySQL版本大于5.7.6.我的版本为5.7.20.同时文中的所有操作都基于InnoDB存储引擎....

ios storyboard全解析 (二)

Add Player 最终的设计看上去像下面这样:#接第一部分:原帖地址简书地址 如果你想了解storyboards,那么你来对地方了.在第一篇文章第一篇文章中,你已经学到了Interface Builder的基本用法来创建和连线多个控制器,以及使用在storyboard中可以通过直接创建自定义的tableViewCell.此次storyboard系列教...

SQL Server的链接服务器(MySQL、Oracle、Ms_sql、Access、SYBASE)

一、使用 Microsoft OLE DB Provider For ODBC 链接MySQL安装MySQL的ODBC驱动MyODBC1、为MySQL建立一个ODBC系统数据源,例如:选择数据库为test ,数据源名称为myDSN 2、建立链接数据库EXEC sp_addlinkedserver @server = 'MySQLTest', @srvpro...

Host是如何与EC通信的

第一种方式:遵循ACPI规范完成通信,通过LPC的62h、64h偏移/端口。 此种方式适合host对EC进行读写操作。 EC提供256字节的可被系统读写的RAM空间,EC的资源在该RAM空间映射,通过访问对应偏移(0x00~0xFF),即可操作对应的资源。实际上就是外部RAM的前256字节。EC会将键盘、触摸板、电池、温度传感器等一些设备的状态信息保存在此...