- Apache Presto 教程
- Apache Presto - 首頁
- Apache Presto - 概述
- Apache Presto - 架構
- Apache Presto - 安裝
- Apache Presto - 配置
- Apache Presto - 管理
- Apache Presto - SQL 操作
- Apache Presto - SQL 函式
- Apache Presto - MySQL 聯結器
- Apache Presto - JMX 聯結器
- Apache Presto - HIVE 聯結器
- Apache Presto - KAFKA 聯結器
- Apache Presto - JDBC 介面
- 自定義函式應用
- Apache Presto 有用資源
- Apache Presto - 快速指南
- Apache Presto - 有用資源
- Apache Presto - 討論
Apache Presto - 配置設定
本章將討論 Presto 的配置設定。
Presto 驗證器
Presto 驗證器可用於針對另一個數據庫(例如 MySQL)測試 Presto,或用於測試兩個 Presto 叢集之間的效能。
在 MySQL 中建立資料庫
開啟 MySQL 伺服器並使用以下命令建立資料庫。
create database test
現在您已在伺服器中建立了“test”資料庫。使用以下查詢建立表並載入資料。
CREATE TABLE verifier_queries( id INT NOT NULL AUTO_INCREMENT, suite VARCHAR(256) NOT NULL, name VARCHAR(256), test_catalog VARCHAR(256) NOT NULL, test_schema VARCHAR(256) NOT NULL, test_prequeries TEXT, test_query TEXT NOT NULL, test_postqueries TEXT, test_username VARCHAR(256) NOT NULL default 'verifier-test', test_password VARCHAR(256), control_catalog VARCHAR(256) NOT NULL, control_schema VARCHAR(256) NOT NULL, control_prequeries TEXT, control_query TEXT NOT NULL, control_postqueries TEXT, control_username VARCHAR(256) NOT NULL default 'verifier-test', control_password VARCHAR(256), session_properties_json TEXT, PRIMARY KEY (id) );
新增配置設定
建立一個屬性檔案來配置驗證器 -
$ vi config.properties suite = mysuite query-database = jdbc:mysql://:3306/tutorials?user=root&password=pwd control.gateway = jdbc:presto://:8080 test.gateway = jdbc:presto://:8080 thread-count = 1
這裡,在query-database欄位中,輸入以下詳細資訊 - mysql 資料庫名稱、使用者名稱和密碼。
下載 JAR 檔案
訪問以下連結下載 Presto-verifier jar 檔案,
https://repo1.maven.org/maven2/com/facebook/presto/presto-verifier/0.149/
現在版本“presto-verifier-0.149-executable.jar”已下載到您的機器上。
執行 JAR
使用以下命令執行 JAR 檔案,
$ mv presto-verifier-0.149-executable.jar verifier $ chmod+x verifier
執行驗證器
使用以下命令執行驗證器,
$ ./verifier config.properties
建立表
讓我們使用以下查詢在“test”資料庫中建立一個簡單的表。
create table product(id int not null, name varchar(50))
插入表
建立表後,使用以下查詢插入兩條記錄,
insert into product values(1,’Phone') insert into product values(2,’Television’)
執行驗證器查詢
在驗證器終端 (./verifier config.propeties) 中執行以下示例查詢以檢查驗證器結果。
示例查詢
insert into verifier_queries (suite, test_catalog, test_schema, test_query,
control_catalog, control_schema, control_query) values
('mysuite', 'mysql', 'default', 'select * from mysql.test.product',
'mysql', 'default', 'select * from mysql.test.product');
這裡,select * from mysql.test.product查詢指的是 mysql 目錄,test是資料庫名稱,product是表名稱。透過這種方式,您可以使用 Presto 伺服器訪問 mysql 聯結器。
這裡,兩個相同的 select 查詢相互比較以檢視效能。同樣,您可以執行其他查詢以測試效能結果。您還可以連線兩個 Presto 叢集以檢查效能結果。
廣告