首页 > 数据库 >通过 Sysbench 在低配置低数据基础上分别压测 MySQL 和 TiDB,实际结果 TiDB 出乎我的想象。

通过 Sysbench 在低配置低数据基础上分别压测 MySQL 和 TiDB,实际结果 TiDB 出乎我的想象。

时间:2023-12-18 14:00:45浏览次数:41  
标签:oltp 压测 local TiDB -- usr MySQL config sysbench

作者: tidb菜鸟一只



背景

最近要上一个新项目,原来提供的是一个主从mysql数据库,两台16C64G的主机(还有个预发环境也是mysql主从,2个4C8G主机),感觉不是很靠谱,所以想要切换成tidb,所以对两边进行了压测(包括预发),两边磁盘都是垃圾机械盘,性能不说了,但是两边都垃圾,对比数据还是比较靠谱的。



实践过程



下载

通过 https://github.com/akopytov/sysbench/releases 下载源码

\# ls -lh sysbench-1.0.20.tar.gz 

\-rw-r--r-- 1 root root 1.5M Apr 27 17:12 sysbench-1.0.20.tar.gz

\# tar -zxf sysbench-1.0.20.tar.gz 

\# ls sysbench-1.0.20

autogen.sh    COPYING    m4            README.md        scripts  third\_party

ChangeLog    debian      Makefile.am    README-Oracle.md  snap

config        doc        missing        README-WIN.txt    src

configure.ac  install-sh  mkinstalldirs  rpm              tests
  • CentOS7.9下安装sysbench版本1.0.20,支持MySQL

yum -y install make automake libtool pkgconfig libaio-devel

  • 如果本身openssl版本高,安装mariadb-devel报错

<!---->

  • 直接下载新版的mariadb来安装

 

Judy-1.0.5-8.el7.x86\_64.rpm

 thrift-0.9.1-15.el7.x86\_64.rpm

 mariadb-10.4.32-rhel-7-x86\_64-rpms.tar

rpm -e mariadb-libs-5.5.68-1.el7.x86\_64 --nodeps

rpm -e mariadb-5.5.68-1.el7.x86\_64 --nodeps

rpm -ivh  Judy-1.0.5-8.el7.x86\_64.rpm

rpm -ivh    thrift-0.9.1-15.el7.x86\_64.rpm

tar -xvf  mariadb-10.4.32-rhel-7-x86\_64-rpms.tar

cd mariadb-10.4.32-rhel-7-x86\_64-rpms

yum localinstall \*.rpm -y

cd sysbench-1.0.20

\# yum install mariadb mariadb-devel
  • 不安装MySQL和MySQL Dev包,make时会出现如下报错:
drv\_mysql.c:37:19: fatal error: mysql.h: No such file or directory

\#include \<mysql.h>

\# ./autogen.sh

\# ./configure --prefix=/usr/local/sysbench --with-mysql 

\# make -j

\# make install

\# ls /usr/local/sysbench/

bin  share

\# /usr/local/sysbench/bin/sysbench --version

sysbench 1.0.20
  • tidb需要set global tidb_disable_txn_auto_retry = off;

set global tidb\_prepared\_plan\_cache\_size=1000;  

  • mysql需要 set global max_prepared_stmt_count=1048576;

其他全部用默认参数,不做修改。



调整

调整 Sysbench 脚本创建索引的顺序。Sysbench 按照“建表->插入数据->创建索引”的顺序导入数据。对于 TiDB 而言,该方式会花费更多的导入时间。你可以通过调整顺序来加速数据的导入。

假设使用的 Sysbench 版本为 1.0.20,可以通过以下两种方式来修改:

  1. 直接下载为 TiDB 修改好的 oltp_common.lua 文件,覆盖 /usr/local/sysbench/share/sysbench/oltp_common.lua 文件。

<!---->

  1. 将 /usr/local/sysbench/share/sysbench/oltp_common.lua 的第 235-240 行移动到第 198 行以后。

分别配置mysql和tidb的配置文件

vi config

mysql-host=\*.\*.\*.\*

mysql-port=3806

mysql-user=root

mysql-password=\*\*\*\*\*\*

mysql-db=sbtest

time=600

threads=100

report-interval=10

db-driver=mysql



测试过程

首先压预发和tidb,只压4张表每张10W数据,准备数据

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=4 --table-size=100000 prepare



数据预热与统计信息收集

数据预热可将磁盘中的数据载入内存的 block cache 中,预热后的数据对系统整体的性能有较大的改善,建议在每次重启集群后进行一次数据预热。

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=4 --table-size=100000 prewarm



Point select 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=4 --table-size=100000 --db-ps-mode=auto --rand-type=uniform run



Update index 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_update_index --tables=4--table-size=100000 --db-ps-mode=auto --rand-type=uniform run



Read Write 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_write  --tables=4--table-size=100000 --db-ps-mode=auto --rand-type=uniform run



Read-only 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_only --tables=4--table-size=100000 --db-ps-mode=auto --rand-type=uniform run



清理

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_write  --tables=4--table-size=100000 --db-ps-mode=auto --rand-type=uniform cleanup



结果截图

通过 Sysbench 在低配置低数据基础上分别压测 MySQL 和 TiDB,实际结果 TiDB 出乎我的想象。_mysql



然后压生产和预发,16张表每张50W数据,准备数据

/usr/local/sysbench/bin/sysbench --config-file=config oltp\_point\_select --tables=16 --table-size=500000 prepare



数据预热与统计信息收集

数据预热可将磁盘中的数据载入内存的 block cache 中,预热后的数据对系统整体的性能有较大的改善,建议在每次重启集群后进行一次数据预热。

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=16 --table-size=500000 prewarm



Point select 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=16 --table-size=500000 --db-ps-mode=auto --rand-type=uniform run



Update index 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_update_index --tables=16--table-size=500000 --db-ps-mode=auto --rand-type=uniform run



Read Write 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_write  --tables=16--table-size=500000 --db-ps-mode=auto --rand-type=uniform run



Read-only 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_only --tables=16--table-size=500000 --db-ps-mode=auto --rand-type=uniform run



清理

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_write  --tables=16--table-size=500000 --db-ps-mode=auto --rand-type=uniform cleanup



结果截图

通过 Sysbench 在低配置低数据基础上分别压测 MySQL 和 TiDB,实际结果 TiDB 出乎我的想象。_测试命令_02



最后本来想再压下生产和tidb的,但是由于生产在用,就没压了,只是单压tidb,看看数据量级上来之后tidb的性能如何。

16张表每张1000W数据,准备数据

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=16 --table-size=10000000 prepare



数据预热与统计信息收集

数据预热可将磁盘中的数据载入内存的 block cache 中,预热后的数据对系统整体的性能有较大的改善,建议在每次重启集群后进行一次数据预热。

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=16 --table-size=10000000 prewarm



Point select 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_point_select --tables=16 --table-size=10000000 --db-ps-mode=auto --rand-type=uniform run



Update index 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_update_index --tables=16--table-size=10000000 --db-ps-mode=auto --rand-type=uniform run



Read Write 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_write  --tables=16--table-size=10000000 --db-ps-mode=auto --rand-type=uniform run



Read-only 测试命令

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_only --tables=16--table-size=10000000 --db-ps-mode=auto --rand-type=uniform run



清理

/usr/local/sysbench/bin/sysbench --config-file=config oltp_read_write  --tables=16--table-size=10000000 --db-ps-mode=auto --rand-type=uniform cleanup



结果截图

通过 Sysbench 在低配置低数据基础上分别压测 MySQL 和 TiDB,实际结果 TiDB 出乎我的想象。_mysql_03



结论

本来觉得在低配置,低数据量的情况下,tidb并不比mysql占优的,实际出乎我的想象。

标签:oltp,压测,local,TiDB,--,usr,MySQL,config,sysbench
From: https://blog.51cto.com/tidb/8873053

相关文章

  • 基于php+mysql的一个开源IT资产管理系统——CAT:v1.0.5
    来自作者的一段为提高管理效率,良好发展开源的理想。   来一杯咖啡与茶,为IT运维从业者减轻管理负担,提升管理效率,从繁重无序的工作中解压出来,利用剩余时间多喝一杯休息一下。这是一个专为IT运维从业者打造的一站式解决方案平台,包含资产管理、工单、工作流、仓储等功能模......
  • MySQL 8.0 OCP 36
    Choosethebestanswer.YouwishtostoretheusernameandpasswordforaclientconnectiontoMySQLserverinafileonalocalfilesystem.您希望将MySQL服务器的用户名和密码存储在本地文件系统的文件中。Whichisthebestwaytoencryptthefile?加密文件的......
  • MySQL 8 手动安装后无法启动的问题解决
    首先的自我检讨与自我批评,最近有点懒,知识的更新慢,最近在更换系统到ubuntu22.04,废弃centos ,同时MYSQL都在8以上,之前MySQL都是在CENTOS7.5上安装,并且也都自动化安装,基本上没有问题,但到了ubuntu22.04基于对于系统的不熟悉,产生很多的问题。今天就梳理一下,转换了系统对于M......
  • mysql 5.7和8.0 yum安装
    安装环境Centos7.61.下载mysql源安装包$wgethttp://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm2.安装mysql源$yumlocalinstallmysql57-community-release-el7-8.noarch.rpm3.检查mysql源是否安装成功$yumrepolistenabled|grep"mysql.-comm......
  • mysql在使用myisam引擎的情况下如何提升查询速度
    MyISAM是MySQL的一种存储引擎,它在某些情况下可能比其他存储引擎(例如InnoDB)慢。但是,仍然有一些方法可以优化MyISAM表的查询速度:索引优化:为经常用于查询的列和WHERE子句中的列添加索引。使用复合索引来覆盖多个列,但要注意索引的列顺序。定期使用 OPTIMIZETABLE 命令来重新......
  • ABP-VNext 用户权限管理系统实战01---AuthServer服务迁移数据库到mysql
    一、从github上获取源码后修改命名空间下载dome后修改解决方案名为Bridge。 二、默认是连接sqlserver的,需要修改为可以连接mysql修改appsettings.json文件的ConnectionStrings参数,准备一个可以连接的mysql,新建数据库bridge{"ConnectionStrings":{"Default":"Se......
  • MySQL运维6-Mycat垂直分库
    一、垂直分库场景场景:在业务系统中,涉及一下表结构,但是由于用户与订单每天都会产生大量的数据,单台服务器的数据存储以及处理能力是有限的,可以对数据库表进行拆分,原有数据库如下说明1:整个业务系统中的表,大致分为四个,商品信息类的表,订单相关的表,用户相关表及省市区相......
  • springboot连接mysql出现的SSL问题
    1、连接配置spring:datasource:username:rootpassword:rooturl:jdbc:mysql://192.168.0.1:3307/admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghaidriver-class-name:com.mysql.cj.jdbc.Driver出现SSL连接问题2、解......
  • MySQL8.0 OCP 34
    Choosefour.WhichfouraretypesofinformationstoredintheMySQLdatadictionary?MySQL数据字典中存储的哪四种信息类型?A)serverruntimeconfigurationB)serverconfigurationrollbackC)performancemetricsD)storedproceduredefinitions存储过程定义E)I......
  • Mysql 修改账号密码
    修改普通账号密码,登入之后执行:SETPASSWORD=PASSWORD('新密码'); http://dev.mysql.com/doc/refman/5.7/en/set-password.html 修改/设置root账号密码: https://blog.csdn.net/hdxx2022/article/details/132082376方法一,登入root之后执行:ALTERUSER'root'@'%'IDENTIFI......