• BenchmarkSQL对数据库性能测试示例


    BenchmarkSQL对数据库性能测试示例

    最近在做TIDB的上线部署,部署完成后需要对其进行性能测试,所以我们就用了benchmarkSQL这个工具啦

    TiDB文档地址:https://pingcap.com/docs-cn/stable/benchmark/benchmark-tidb-using-tpcc/

    #首先我们需要下载benchmarksql
    
    git clone -b 5.0-mysql-support-opt-2.1 https://github.com/pingcap/benchmarksql.git
    
    #安装好 java , ant
    
    sudo yum install -y java ant
    
    #构建ant
    
    cd benchmarksql
    
    ant
    #远程复制服务命令:(将下载好的benchmarksql通过scp远程复制到指定服务器,如果网络是通的则可以直接SecureFX上传)
    
    scp -r user@10.22.33.44:/home/user/tidb/benchmarksql ./
    

      

    接下来我们就要开始准备测试数据库性能了,这里我们是使用benchmarksql测试tidb (和Mysql类似,所以我们会参考mysql的配置信息来做调整

    1.参考 benchmarksql/run/ props.mysql 配置文件

    db=mysql
    driver=com.mysql.jdbc.Driver
    conn=jdbc:mysql://localhost:4000/tpcc?useSSL=false&useServerPrepStmts=true&useConfigs=maxPerformance&rewriteBatchedStatements=true
    user=root
    password=
    
    warehouses=1
    loadWorkers=4
    
    terminals=1
    //To run specified transactions per terminal- runMins must equal zero
    runTxnsPerTerminal=0
    //To run for specified minutes- runTxnsPerTerminal must equal zero
    runMins=10
    //Number of total transactions per minute
    limitTxnsPerMin=0
    
    //Set to true to run in 4.x compatible mode. Set to false to use the
    //entire configured database evenly.
    terminalWarehouseFixed=true
    
    //The following five values must add up to 100
    //The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
    newOrderWeight=45
    paymentWeight=43
    orderStatusWeight=4
    deliveryWeight=4
    stockLevelWeight=4
    
    // Directory name to create for collecting detailed result data.
    // Comment this out to suppress.
    resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
    //osCollectorScript=./misc/os_collector_linux.py
    //osCollectorInterval=1
    //osCollectorSSHAddr=user@dbhost
    //osCollectorDevices=net_eth0 blk_sda

    配置文件说明:

    Warehouses 代表仓库数,框中的数字表示该表将存放的记录条数,仓库数的调整在测试中能够体现数据库所能支持的数据规模的能力。每个 Warehouse 的数据量,其大小约为 76823.04KB,可以有小量的变化,因为测试过程中将会插入或删除现有记录。可以根据每个Warehouse的数据量,计算测试过程中的数据总量。
    计算公式为:数据总量(KB)≈ Warehouse个数*76823.04KB
    以10个Warehouse的数据量为例计算其数据总量大小约为:768230.4KB
    
    loadWorkers=10   //用于在数据库中初始化数据的加载进程数量,默认为4,实际使用过程中可以根据实际情况调整,加载速度会随worker数量的增加而有所提升
    
    terminals=10  //终端数,即并发客户端数量,通常设置为CPU线程总数的2~6倍
    
    runTxnsPerTerminal=10 //每个终端(terminal)运行的固定事务数量,例如:如果该值设置为10,意味着每个terminal运行10个事务,如果有32个终端,那整体运行320个事务后,测试结束。该参数配置为非0值时,下面的runMins参数必须设置为0
     
    runMins=0    //要测试的整体时间,单位为分钟,如果runMins设置为60,那么测试持续1小时候结束。该值设置为非0值时,runTxnsPerTerminal参数必须设置为0。这两个参数不能同时设置为正整数,如果设置其中一个,另一个必须为0,主要区别是runMins定义时间长度来控制测试时间;runTxnsPerTerminal定义事务总数来控制时间。
    

      

    参考以上配置文件新建我们自己的测试配置文件 benchmark_tidb.properties 并调整参数信息:(需要先新建对应的库信息 在数据库中新建数据库:benchmark_test )

    db=mysql
    driver=com.mysql.cj.jdbc.Driver
    conn=jdbc:mysql://10.55.33.44:4000/benchmark_test
    user=root
    password=
    
    warehouses=40
    loadWorkers=10
    
    terminals=100
    //To run specified transactions per terminal- runMins must equal zero
    runTxnsPerTerminal=0
    //To run for specified minutes- runTxnsPerTerminal must equal zero
    runMins=2
    //Number of total transactions per minute
    limitTxnsPerMin=0
    
    //Set to true to run in 4.x compatible mode. Set to false to use the
    //entire configured database evenly.
    terminalWarehouseFixed=true
    
    //The following five values must add up to 100
    //The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
    newOrderWeight=45
    paymentWeight=43
    orderStatusWeight=4
    deliveryWeight=4
    stockLevelWeight=4
    
    // Directory name to create for collecting detailed result data.
    // Comment this out to suppress.
    resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
    //osCollectorScript=./misc/os_collector_linux.py
    //osCollectorInterval=1
    //osCollectorSSHAddr=user@dbhost
    //osCollectorDevices=net_eth0 blk_sda

    2.开始运行 进入benchmarkSQL的run目录,依次执行以下命令

    ./runSQL.sh benchmark_tidb.properties ./sql.common/tableCreates.sql
    
    .
    /runSQL.sh benchmark_tidb.properties ./sql.common/indexCreates.sql
    .
    /runDatabaseBuild.sh benchmark_tidb.properties
    .
    /runBenchmark.sh benchmark_tidb.properties

    ./runBenchmark.sh benchmark_tidb.properties 执行结果:

    netstat -tlnp  #说明 l:listening  t: tcp    n:number   p:process
    

      

  • 相关阅读:
    搭建非域AlwaysOn win2016+SQL2016
    从0开始搭建SQL Server AlwaysOn 第四篇(配置异地机房节点)
    从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群)
    从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)
    从0开始搭建SQL Server AlwaysOn 第一篇(配置域控)
    四、基于Windows 2012配置SQL Server 2014 AlwaysOn
    三、安装SQLserver 2014(For AlwaysOn)
    二、 Windows 2012配置故障转移(For SQLServer 2014 AlwaysOn)
    Mybatis-SQL语句构建器类及日志
    Mybatis-JavaAPI
  • 原文地址:https://www.cnblogs.com/DFX339/p/13071848.html
Copyright © 2020-2023  润新知