使用TPC-DS對kudu和impala進行基準測試

參考文章:

tpc-ds官網

使用TPC-DS工具生成數據

使用TPC-DS對kudu進行基準測試

tpc-ds測試tidb結果

1. 下載工具

兩種渠道

1.1 官網(建議直接跳過~)

地址:http://www.tpc.org/tpc_documents_current_versions/current_specifications.asp

在信息填寫正確的情況下,無法下載。看網友的解答,需要用谷歌瀏覽器才能下載。嘗試未果。

1.2 github上下載

地址: https://github.com/gregrahn/tpcds-kit.git

ps:官方的包生成sql的時候會報錯,上面這個大神已經修復。

2. 編譯安裝

Make sure the required development tools are installed:

Ubuntu:

sudo apt-get install gcc make flex bison byacc git

CentOS/RHEL:

sudo yum install gcc make flex bison byacc git

Then run the following commands to clone the repo and build the tools:

git clone https://github.com/gregrahn/tpcds-kit.git
cd tpcds-kit/tools
make OS=LINUX

macOS

Make sure the required development tools are installed:

xcode-select --install

Then run the following commands to clone the repo and build the tools:

git clone https://github.com/gregrahn/tpcds-kit.git
cd tpcds-kit/tools
make OS=MACOS

如果生成dsdgen和dsqgen且無報錯,說明編譯成功:

ll *gen

3. 生成SQL 

查詢SQL使用dsqgen生成,主要用於測試數據倉庫的性能,一共99個。詳細用法可以用--help查看幫助信息。這裏不做介紹直接生成。

./dsqgen \
-DIRECTORY ../query_templates/ \
-TEMPLATE "query1.tpl" \
-DIALECT netezza \
-FILTER Y > ../sql/query1.sql

#說明
-DIRECTORY:SQL模板的路徑
-TEMPLATE:SQL模板的名稱
-DIALECT:include query dialect defintions found in <s>.tpl
-FILTER:重定向到標準輸出。

-DIR 生成目錄
-SCALE 數據大小(單位GB)
-DELIMITER 字段分隔符,默認|
-TERMINATE 末尾是否有分隔符,參數 Y或者N

創建表語句

TPC-DS已經提前準備好了創建表相關的SQL文件
文件位於tools目錄下,具體文件如下:
    tpcds.sql            # 創建25張表的sql語句
    tpcds_ri.sql        # 創建表與表之間關係的sql語句
    tpcds_source.sql

注意:不同的庫SQL語法不一樣,需要對應修改 

3.1 循環生成SQL的shell版本

#!/bin/sh
for i in `seq 1 99`
do
./dsqgen \
-DIRECTORY ../query_templates/ \
-TEMPLATE "query${i}.tpl" \
-DIALECT netezza \
-FILTER Y > ../sql/query${i}.sql
done

3.2 循環生成SQL的Python3版

#coding:utf-8
import os
print("generate query sql")
for i in range(1,100):
    tpl = "query"+str(i)+".tpl"
    qsql = "query" +str(i) +".sql"
    #拼接命令
    cmd = "./dsqgen  -DIRECTORY ../query_templates/ "+"-TEMPLATE "+tpl+" -DIALECT netezza -FILTER Y > "+"../sql/"+qsql
    #print(cmd)
    #執行命令
    os.system(cmd)

4. TPC-DS工具的使用

4.1 生成數據

Data generation is done via dsdgen. See dsdgen -help for all options. If you do not run dsdgen from the tools/ directory then you will need to use the option -DISTRIBUTIONS /.../tpcds-kit/tools/tpcds.idx. The output directory (specified via the -DIR option) must exist prior to running dsdgen.

./dsdgen  --help

4.2 TPC-DS目錄說明

  • DIR:數據存放目錄。
  • SCALE:數據量,以GB爲單位。
  • TABLE:生成哪張表的數據,一共有24張表哦。
  • PARALLEL:生成的數據一共分爲多少份,一般生成TB級數據纔會用到。
  • CHILD:當前數據是第幾份,與PARALLEL配對使用。
  • FORCE:強制寫入數據。

4.3 TPC-DS常用命令

生成1G數據

# 1G數據需要2~3min左右
./dsdgen -scale 1 -dir ../data/

查詢數據

Query generation is done via dsqgen. See dsqgen -help for all options.

The following command can be used to generate all 99 queries in numerical order (-QUALIFY) for the 10TB scale factor (-SCALE) using the Netezza dialect template (-DIALECT) with the output going to /tmp/query_0.sql (-OUTPUT_DIR).

dsqgen \
-DIRECTORY ../query_templates \    // SQL模板的路徑
-INPUT ../query_templates/templates.lst \
-VERBOSE Y \
-QUALIFY Y \
-SCALE 10000 \
-DIALECT netezza \
-OUTPUT_DIR /tmp

一些案例 

1TB的TPC-DS數據:

./tpcds-setup.sh 1000

1TP的TPC-H數據: 

./tpch-setup.sh 1000  

100TB的TPC-DS數據:

./tpcds-setup.sh 100000  

30TB文本格式的TPC-DS數據:

FORMAT=textfile ./tpcds-setup 30000

30TB RCFile格式的TPC-DS數據: 

FORMAT=rcfile ./tpcds-setup 30000

5. TPC-DS測試Kudu

5.1 操作步驟

  1. 安裝TPC-DS工具
  2. 初始化測試目錄,使用TPC-DS工具生成測試數據dat文件和查詢語句。
  3. 在HDFS新建目錄,將測試數據dat文件上傳到HDFS中。
  4. 將TPC-DS提供的DDL語句做語法兼容改造。
  5. 準備impala外部表和kudu表的DDL、COUNT、LIMIT語句,整理成SQL文件。準備統計分析(computer status table_name)的SQL語句。
  6. 調用start_tpc_import.sh進行impala外部表的建表,執行kudu內部表ddl,將impala外部表數據導入到kudu內部表,調用統計分析SQL,收集執行結果信息到tpc_ds_test/result目錄查看,具體的SQL文件執行日誌在tpc_ds_test/logs目錄查看。
  7. 整理TPC-DS提供的SQL基準查詢語句,由於有些語法不兼容kudu,需要進行手動調整,最後整理到單獨SQL文件中。
  8. 調用start_kudu_query.sh,執行手動調整過後的TPC—DS的SQL基準查詢。收集執行結果信息到tpc_ds_test/result目錄查看,具體的SQL文件執行日誌在tpc_ds_test/logs目錄查看。

自動化測試腳本地址:https://github.com/linmeibao/tpc_ds_test

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章