下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划

2024-03-13 05:28

本文主要是介绍下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划

  • 一、什么是BenchmarkSQL
  • 二、下载BenchmarkSQL
  • 三、使用BenchmarkSQL查看OceanBase 的执行计划

一、什么是BenchmarkSQL

在这里插入图片描述

BenchmarkSQL是一个开源的数据库基准测试工具,可以用来评估数据库系统的性能,支持多种常见的数据库系统,包括EnterpriseDB、PostgreSQL、Oracle、Sybase、SQL Server、MySQL、HsqlDB、Derby/JavaDB和FireBird等。它的官网是:https://sourceforge.net/projects/benchmarksql/。

在国内的生产实践中,外键约束已经较少使用,但BenchmarkSQL的实现仍然广泛采用了外键约束,以符合TPC-C的要求。它的Order逻辑由4个SELECT、3个INSERT、2个UPDATE组成,和在微服务中不用匿名块和存储过程实现的逻辑高度匹配。

二、下载BenchmarkSQL

  1. 点击此链接跳转官方网站下载:https://sourceforge.net/projects/benchmarksql/
    在这里插入图片描述

  2. 上传至linux
    在这里插入图片描述

    这里使用的传输工具为:SecureCRT9
    安装步骤见此文:SecureCRT9汉化版安装
    也可关注文末公众号:数据探索者007 回复01获取

  3. 减压文件

    [oceanbase@localhost ~]$ ls
    benchmarksql-5.0.zip  myoceanbase  mysql_test
    [oceanbase@localhost ~]$ unzip benchmarksql-5.0.zip 
    Archive:  benchmarksql-5.0.zip
    6036b15716cf8c142465ac8092d53a777d609684creating: benchmarksql-5.0/extracting: benchmarksql-5.0/.gitignore  inflating: benchmarksql-5.0/HOW-TO-RUN.txt  inflating: benchmarksql-5.0/README.md  inflating: benchmarksql-5.0/build.xml  creating: benchmarksql-5.0/doc/creating: benchmarksql-5.0/doc/src/inflating: benchmarksql-5.0/doc/src/TimedDriver.odt  creating: benchmarksql-5.0/lib/extracting: benchmarksql-5.0/lib/.gitignore  inflating: benchmarksql-5.0/lib/apache-log4j-extras-1.1.jar  creating: benchmarksql-5.0/lib/firebird/inflating: benchmarksql-5.0/lib/firebird/connector-api-1.5.jar  inflating: benchmarksql-5.0/lib/firebird/jaybird-2.2.9.jar  inflating: benchmarksql-5.0/lib/log4j-1.2.17.jar  creating: benchmarksql-5.0/lib/oracle/extracting: benchmarksql-5.0/lib/oracle/.gitignore  inflating: benchmarksql-5.0/lib/oracle/README.txt  creating: benchmarksql-5.0/lib/postgres/inflating: benchmarksql-5.0/lib/postgres/postgresql-9.3-1102.jdbc41.jar  creating: benchmarksql-5.0/run/extracting: benchmarksql-5.0/run/.gitignore  inflating: benchmarksql-5.0/run/funcs.sh  inflating: benchmarksql-5.0/run/generateGraphs.sh  inflating: benchmarksql-5.0/run/generateReport.sh  inflating: benchmarksql-5.0/run/log4j.properties  creating: benchmarksql-5.0/run/misc/inflating: benchmarksql-5.0/run/misc/blk_device_iops.R  inflating: benchmarksql-5.0/run/misc/blk_device_kbps.R  inflating: benchmarksql-5.0/run/misc/cpu_utilization.R  inflating: benchmarksql-5.0/run/misc/dirty_buffers.R  inflating: benchmarksql-5.0/run/misc/latency.R  inflating: benchmarksql-5.0/run/misc/net_device_iops.R  inflating: benchmarksql-5.0/run/misc/net_device_kbps.R  inflating: benchmarksql-5.0/run/misc/os_collector_linux.py  inflating: benchmarksql-5.0/run/misc/tpm_nopm.R  inflating: benchmarksql-5.0/run/props.fb  inflating: benchmarksql-5.0/run/props.ora  inflating: benchmarksql-5.0/run/props.pg  inflating: benchmarksql-5.0/run/runBenchmark.sh  inflating: benchmarksql-5.0/run/runDatabaseBuild.sh  inflating: benchmarksql-5.0/run/runDatabaseDestroy.sh  inflating: benchmarksql-5.0/run/runLoader.sh  inflating: benchmarksql-5.0/run/runSQL.sh  creating: benchmarksql-5.0/run/sql.common/inflating: benchmarksql-5.0/run/sql.common/buildFinish.sql  inflating: benchmarksql-5.0/run/sql.common/foreignKeys.sql  inflating: benchmarksql-5.0/run/sql.common/indexCreates.sql  inflating: benchmarksql-5.0/run/sql.common/indexDrops.sql  inflating: benchmarksql-5.0/run/sql.common/tableCreates.sql  inflating: benchmarksql-5.0/run/sql.common/tableDrops.sql  inflating: benchmarksql-5.0/run/sql.common/tableTruncates.sql  creating: benchmarksql-5.0/run/sql.firebird/inflating: benchmarksql-5.0/run/sql.firebird/extraHistID.sql  creating: benchmarksql-5.0/run/sql.oracle/inflating: benchmarksql-5.0/run/sql.oracle/extraHistID.sql  creating: benchmarksql-5.0/run/sql.postgres/inflating: benchmarksql-5.0/run/sql.postgres/buildFinish.sql  inflating: benchmarksql-5.0/run/sql.postgres/extraHistID.sql  inflating: benchmarksql-5.0/run/sql.postgres/tableCopies.sql  creating: benchmarksql-5.0/src/creating: benchmarksql-5.0/src/LoadData/inflating: benchmarksql-5.0/src/LoadData/LoadData.java  inflating: benchmarksql-5.0/src/LoadData/LoadDataWorker.java  creating: benchmarksql-5.0/src/OSCollector/inflating: benchmarksql-5.0/src/OSCollector/OSCollector.java  creating: benchmarksql-5.0/src/client/inflating: benchmarksql-5.0/src/client/jTPCC.java  inflating: benchmarksql-5.0/src/client/jTPCCConfig.java  inflating: benchmarksql-5.0/src/client/jTPCCConnection.java  inflating: benchmarksql-5.0/src/client/jTPCCRandom.java  inflating: benchmarksql-5.0/src/client/jTPCCTData.java  inflating: benchmarksql-5.0/src/client/jTPCCTerminal.java  inflating: benchmarksql-5.0/src/client/jTPCCUtil.java  creating: benchmarksql-5.0/src/jdbc/inflating: benchmarksql-5.0/src/jdbc/ExecJDBC.java  
    [oceanbase@localhost ~]$ ls
    benchmarksql-5.0  benchmarksql-5.0.zip  myoceanbase  mysql_test
    [oceanbase@localhost ~]$ 
    [oceanbase@localhost ~]$ tree benchmarksql-5.0
    benchmarksql-5.0
    ├── build.xml
    ├── doc
    │   └── src
    │       └── TimedDriver.odt
    ├── HOW-TO-RUN.txt
    ├── lib
    │   ├── apache-log4j-extras-1.1.jar
    │   ├── firebird
    │   │   ├── connector-api-1.5.jar
    │   │   └── jaybird-2.2.9.jar
    │   ├── log4j-1.2.17.jar
    │   ├── oracle
    │   │   └── README.txt
    │   └── postgres
    │       └── postgresql-9.3-1102.jdbc41.jar
    ├── README.md
    ├── run
    │   ├── funcs.sh
    │   ├── generateGraphs.sh
    │   ├── generateReport.sh
    │   ├── log4j.properties
    │   ├── misc
    │   │   ├── blk_device_iops.R
    │   │   ├── blk_device_kbps.R
    │   │   ├── cpu_utilization.R
    │   │   ├── dirty_buffers.R
    │   │   ├── latency.R
    │   │   ├── net_device_iops.R
    │   │   ├── net_device_kbps.R
    │   │   ├── os_collector_linux.py
    │   │   └── tpm_nopm.R
    │   ├── props.fb
    │   ├── props.ora
    │   ├── props.pg
    │   ├── runBenchmark.sh
    │   ├── runDatabaseBuild.sh
    │   ├── runDatabaseDestroy.sh
    │   ├── runLoader.sh
    │   ├── runSQL.sh
    │   ├── sql.common
    │   │   ├── buildFinish.sql
    │   │   ├── foreignKeys.sql
    │   │   ├── indexCreates.sql
    │   │   ├── indexDrops.sql
    │   │   ├── tableCreates.sql
    │   │   ├── tableDrops.sql
    │   │   └── tableTruncates.sql
    │   ├── sql.firebird
    │   │   └── extraHistID.sql
    │   ├── sql.oracle
    │   │   └── extraHistID.sql
    │   └── sql.postgres
    │       ├── buildFinish.sql
    │       ├── extraHistID.sql
    │       └── tableCopies.sql
    └── src├── client│   ├── jTPCCConfig.java│   ├── jTPCCConnection.java│   ├── jTPCC.java│   ├── jTPCCRandom.java│   ├── jTPCCTData.java│   ├── jTPCCTerminal.java│   └── jTPCCUtil.java├── jdbc│   └── ExecJDBC.java├── LoadData│   ├── LoadData.java│   └── LoadDataWorker.java└── OSCollector└── OSCollector.java17 directories, 54 files
    [oceanbase@localhost ~]$ 
    
  4. 配置BenchmarkSQL
    使用如下命令进入props.ora 文件进行配置

    [oceanbase@localhost ~]$ vi benchmarksql-5.0/run/props.ora 
    

    具体配置如下:

    db=oracle
    driver=com.alipay.oceanbase.obproxy.mysql.jdbc.Driver
    conn=jdbc:oceanbase://192.168.66.110:2881/benchmark_sql?useUnicode=true&characterEncoding=utf-8
    user=user01@t1
    password=rootrootwarehouses=1
    loadWorkers=4terminals=1
    //To run specified transactions per terminal- runMins must equal zero
    runTxnsPerTerminal=10
    //To run for specified minutes- runTxnsPerTerminal must equal zero
    runMins=0
    //Number of total transactions per minute
    limitTxnsPerMin=300//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
    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
    ~                                                                        
    ~                                                                        
    ~                                                                        
    ~                                                                        
    ~                                            
    

    在这里插入图片描述

三、使用BenchmarkSQL查看OceanBase 的执行计划

  1. 下载ant
    在这里插入图片描述
    设置ant环境

    [root@localhost ~]# vi ~/.bash_profile 
    [root@localhost ~]# source /etc/profile
    [root@localhost ~]# ant -version
    Apache Ant(TM) version 1.9.4 compiled on November 5 2018
    

    在这里插入图片描述
    在对应目录下编译BenchmarkSQL

    [oceanbase@localhost ~]$ cd benchmarksql-5.0
    [oceanbase@localhost benchmarksql-5.0]$ ant
    Buildfile: /home/oceanbase/benchmarksql-5.0/build.xmlinit:[mkdir] Created dir: /home/oceanbase/benchmarksql-5.0/buildcompile:[javac] Compiling 11 source files to /home/oceanbase/benchmarksql-5.0/builddist:[mkdir] Created dir: /home/oceanbase/benchmarksql-5.0/dist[jar] Building jar: /home/oceanbase/benchmarksql-5.0/dist/BenchmarkSQL-5.0.jarBUILD SUCCESSFUL
    Total time: 2 seconds
    
  2. 准备Oceanbase驱动文件
    下载 JDBC 驱动,BenchmarkSQL 是通过 JDBC 连接各个数据库的。此次 OceanBase 的测试租户是 MySQL 类型,所以需要把相关 Jar 包一并放入其中

    Oceanbase驱动文件
    在这里插入图片描述
    下载好后放在benchmarksql-5.0/lib/

  3. 创建建表sql文件
    benchmarksql-5.0/run/sql.common/目录下,使用如下语句:

    vi benchmarksql-5.0/run/sql.common/createTables.sql
    

    createTables.sql文件内容如下:

    CREATE TABLE students (id INT PRIMARY KEY,name VARCHAR(50),age INT,gender ENUM('Male', 'Female')
    );
    CREATE TABLE courses (id INT PRIMARY KEY,name VARCHAR(50)
    );
    CREATE TABLE student_courses (student_id INT,course_id INT,grade INT,FOREIGN KEY (student_id) REFERENCES students(id),FOREIGN KEY (course_id) REFERENCES courses(id)
    );
    
  4. 修改runSQL.sh文件

    [oceanbase@localhost ~]$ cd benchmarksql-5.0/run/
    [oceanbase@localhost run]$ pwd
    /home/oceanbase/benchmarksql-5.0/run
    [oceanbase@localhost run]$ cd
    [oceanbase@localhost ~]$ vi benchmarksql-5.0/run/runSQL.sh 
    [oceanbase@localhost ~]$ 
    
    source /home/oceanbase/benchmarksql-5.0/run/fu1ncs.sh $
    

    在这里插入图片描述

  5. 执行测试:

    [oceanbase@localhost run]$ sh runSQL.sh props.ora sql.common/createTables.sql
    # ------------------------------------------------------------
    # Loading SQL file sql.common/createTables.sql
    # ------------------------------------------------------------
    CREATE TABLE students (
    id INT PRIMARY KEY,
    name VARCHAR(50),
    age INT,
    gender ENUM('Male', 'Female')
    );
    CREATE TABLE courses (
    id INT PRIMARY KEY,
    name VARCHAR(50)
    );
    CREATE TABLE student_courses (
    student_id INT,
    course_id INT,
    grade INT,
    FOREIGN KEY (student_id) REFERENCES students(id),
    FOREIGN KEY (course_id) REFERENCES courses(id)
    );
    [oceanbase@localhost run]$ 
    [oceanbase@localhost run]$
    
    ./runBenchmark.sh props.ora
    

    在这里插入图片描述


更多精彩文章可扫码关注公主号查看:
在这里插入图片描述

这篇关于下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/803762

相关文章

使用Python构建一个Hexo博客发布工具

《使用Python构建一个Hexo博客发布工具》虽然Hexo的命令行工具非常强大,但对于日常的博客撰写和发布过程,我总觉得缺少一个直观的图形界面来简化操作,下面我们就来看看如何使用Python构建一个... 目录引言Hexo博客系统简介设计需求技术选择代码实现主框架界面设计核心功能实现1. 发布文章2. 加

shell编程之函数与数组的使用详解

《shell编程之函数与数组的使用详解》:本文主要介绍shell编程之函数与数组的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录shell函数函数的用法俩个数求和系统资源监控并报警函数函数变量的作用范围函数的参数递归函数shell数组获取数组的长度读取某下的

使用Python开发一个带EPUB转换功能的Markdown编辑器

《使用Python开发一个带EPUB转换功能的Markdown编辑器》Markdown因其简单易用和强大的格式支持,成为了写作者、开发者及内容创作者的首选格式,本文将通过Python开发一个Markd... 目录应用概览代码结构与核心组件1. 初始化与布局 (__init__)2. 工具栏 (setup_t

Python虚拟环境终极(含PyCharm的使用教程)

《Python虚拟环境终极(含PyCharm的使用教程)》:本文主要介绍Python虚拟环境终极(含PyCharm的使用教程),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录一、为什么需要虚拟环境?二、虚拟环境创建方式对比三、命令行创建虚拟环境(venv)3.1 基础命令3

Python Transformer 库安装配置及使用方法

《PythonTransformer库安装配置及使用方法》HuggingFaceTransformers是自然语言处理(NLP)领域最流行的开源库之一,支持基于Transformer架构的预训练模... 目录python 中的 Transformer 库及使用方法一、库的概述二、安装与配置三、基础使用:Pi

关于pandas的read_csv方法使用解读

《关于pandas的read_csv方法使用解读》:本文主要介绍关于pandas的read_csv方法使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录pandas的read_csv方法解读read_csv中的参数基本参数通用解析参数空值处理相关参数时间处理相关

前端下载文件时如何后端返回的文件流一些常见方法

《前端下载文件时如何后端返回的文件流一些常见方法》:本文主要介绍前端下载文件时如何后端返回的文件流一些常见方法,包括使用Blob和URL.createObjectURL创建下载链接,以及处理带有C... 目录1. 使用 Blob 和 URL.createObjectURL 创建下载链接例子:使用 Blob

使用Node.js制作图片上传服务的详细教程

《使用Node.js制作图片上传服务的详细教程》在现代Web应用开发中,图片上传是一项常见且重要的功能,借助Node.js强大的生态系统,我们可以轻松搭建高效的图片上传服务,本文将深入探讨如何使用No... 目录准备工作搭建 Express 服务器配置 multer 进行图片上传处理图片上传请求完整代码示例

SpringBoot条件注解核心作用与使用场景详解

《SpringBoot条件注解核心作用与使用场景详解》SpringBoot的条件注解为开发者提供了强大的动态配置能力,理解其原理和适用场景是构建灵活、可扩展应用的关键,本文将系统梳理所有常用的条件注... 目录引言一、条件注解的核心机制二、SpringBoot内置条件注解详解1、@ConditionalOn

Python中使用正则表达式精准匹配IP地址的案例

《Python中使用正则表达式精准匹配IP地址的案例》Python的正则表达式(re模块)是完成这个任务的利器,但你知道怎么写才能准确匹配各种合法的IP地址吗,今天我们就来详细探讨这个问题,感兴趣的朋... 目录为什么需要IP正则表达式?IP地址的基本结构基础正则表达式写法精确匹配0-255的数字验证IP地