Presto 安裝部署


1.版本選型

hadoop-3.1.3

hive-3.1.2

presto-0.233.1

2.Presto 簡介

詳細參考:https://prestodb.github.io/docs/current/connector.html

2.1 Presto 優勢

多數據源,支持SQL,自定義擴展Connector

混合計算(同一種數據源的不同庫 or表;將多個數據源的數據進行合並)

低延遲,高並發,純內存計算引擎,高性能

2.2 Presto 架構

# presto提供插件化的connector來支持外部數據查詢,原生支持hive、cassandra、elasticsearch、kafka、kudu、mongodb、mysql、redis等眾多外部數據源;
1.coordinator(master):負責meta管理,worker管理;接收查詢請求,解析SQL生成執行計划
2.worker:執行任務的節點,負責計算和讀寫
3.connector:連接器(Hadoop相關組件的連接器,RDBMS連接器)
4.discovery service:內嵌在coordinator節點中,也可以單獨部署,用於節點心跳;worker節點啟動后向discovery service服務注冊,coordinator通過discovery service獲取注冊的worker節點

2.3 Presto數據模型

presto采取三層表結構:
catalog 對應某一類數據源,例如hive的數據,或mysql的數據
schema 對應mysql中的數據庫
table 對應mysql中的表

2.4 Presto 執行過程

1、coordinator接到SQL后,通過SQL語法解析器把SQL語法解析變成一個抽象的語法樹AST(描述最原始的用戶需求),只是進行語法解析如果有錯誤此環節暴露
2、語法符合SQL語法,會經過一個邏輯查詢計划器組件,通過connector 查詢metadata中schema 列名 列類型等,將之與抽象語法數對應起來,生成一個物理的語法樹節點 如果有類型錯誤會在此步報錯
3、如果通過,會得到一個邏輯的查詢計划,將其分發到分布式的邏輯計划器里,進行分布式解析,最后轉化為一個個task
4、在每個task里面,會將位置信息解析出來,交給執行的plan,由plan將task分給worker執行

3.Presto 安裝

server:https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.233.1/presto-server-0.233.1.tar.gz

client:https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.223.1/presto-cli-0.223.1.jar

3.1 安裝

#server
tar -zxvf /opt/software/presto/presto-server-0.233.1.tar.gz -C /opt/module/presto-0.233.1/

#1.把 presto-cli-0.223.1.jar 復制到 /opt/module/presto-0.233.1/presto-server-0.233.1/bin 目錄下
cp /opt/software/presto/presto-cli-0.223.1.jar  /opt/module/presto-0.233.1/presto-server-0.233.1/bin

#2.presto-cli-0.223.1.jar 重命名 presto 
mv /opt/module/presto-0.233.1/presto-server-0.233.1/bin/presto-cli-0.223.1.jar /opt/module/presto-0.233.1/presto-server-0.233.1/bin/presto

#3.增加 presto 的執行權限
chmod +x /opt/module/presto-0.233.1/presto-server-0.233.1/bin/presto

3.2 配置 Presto

1.配置數據目錄
#最好安裝在 presto server 安裝目錄外
mkdir /opt/module/presto-0.233.1/data
2.創建配置文件
#1.在 presto server 安裝目錄 /opt/module/presto-0.233.1/presto-server-0.233.1 創建 etc 文件夾
mkdir /opt/module/presto-0.233.1/presto-server-0.233.1/etc

#2.在 /opt/module/presto-0.233.1/presto-server-0.233.1/etc 下創建 config.properties,jvm.properties,node.properties,log.properties 文件
vim config.properties

coordinator=true   #work節點需要填寫false
node-scheduler.include-coordinator=false  #是否允許在coordinator上調度節點只負責調度時node-scheduler.include-coordinator設置為false,調度節點也作為worker時node-scheduler.include-coordinator設置為true
http-server.http.port=8085
query.max-memory=1GB
query.max-memory-per-node=512MB
query.max-total-memory-per-node=512MB
discovery-server.enabled=true    #Presto 通過Discovery 服務來找到集群中所有的節點,每一個Presto實例都會在啟動的時候將自己注冊到discovery服務;  注意:worker 節點不需要配 discovery-server.enabled
discovery.uri=http://hadoop101:8085  #Discovery server的URI。由於啟用了Presto coordinator內嵌的Discovery 服務,因此這個uri就是Presto coordinator的uri


vim jvm.config  (Presto集群coordinator和worker的JVM配置是一致的)

-server
-Xmx2G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError


vim node.properties

node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff01  #每個節點需要不同
node.data-dir=/opt/module/presto-0.233.1/data


vim log.properties

com.facebook.presto=DEBUG

3.3 配置 connector

#1.在 /opt/module/presto-0.233.1/presto-server-0.233.1/etc 創建 catalog 目錄
mkdir /opt/module/presto-0.233.1/presto-server-0.233.1/etc/catalog

#2.在 catalog 目錄下 創建 hive connector
vim hive.properties
connector.name=hive-hadoop2  #注意 connector.name 只能是 hive-hadoop2 
hive.metastore.uri=thrift://hadoop101:9083
hive.config.resources=/etc/hadoop/core-site.xml,/etc/hadoop/hdfs-site.xml

#3.在 catalog 目錄下 創建 mysql connector
vim mysql.properties

connector.name=mysql
connection-url=jdbc:mysql://hadoop101:3306
connection-user=root
connection-password=123456

4.啟動 presto

注意:Presto requires Java 8u151+,需要jdk 1.8.151 以上,否則 PrestoServer 進程會自動死亡

#后台啟動 (日志在 數據目錄 /opt/module/presto-0.233.1/data/var/log)
/opt/module/presto-0.233.1/presto-server-0.233.1/bin/launcher start

#調試啟動
/opt/module/presto-0.233.1/presto-server-0.233.1/bin/launcher --verbose run

4。1 訪問 presto webui http://hadoop101:8085

5.測試

5.1 啟動 presto cli

#在 presto server 安裝目錄下執行
./bin/presto --server hadoop101:8085
# 查看連接的數據源
show catalogs;

#查看 mysql 中的庫
show schemas from mysql;

#查詢 Hive
select * from hive.default.student limit 1;

#查詢 mysql
select * from mysql.test.maxwell_test limit 1;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM