34 大数据项目之电商数仓(即席查询之Presto)

第 1 章 Presto

1.1Presto 简介

1.1.1Presto 概念

在这里插入图片描述

1.1.2Presto 架构

在这里插入图片描述

1.1.3Presto 优缺点

在这里插入图片描述

1.1.4Presto、Impala 性能比较

https://blog.csdn.net/u012551524/article/details/79124532
测试结论:Impala 性能稍领先于 Presto,但是 Presto 在数据源支持上非常丰富,包括

Hive、图数据库、传统关系型数据库、Redis 等。

1.2Presto 安装

1.2.1Presto Server 安装

0)官网地址

https://prestodb.github.io/ 

1)下载地址

https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.196/presto-server-0.19 6.tar.gz

2)将 presto-server-0.196.tar.gz 导入 dw1 的/opt/software 目录下,并解压到/opt/module 目录
3)修改名称为 presto
4)进入到/opt/module/presto 目录,并创建存储数据文件夹

 mkdir data

5)进入到/opt/module/presto 目录,并创建存储配置文件文件夹

mkdir etc

6)配置在/opt/module/presto/etc 目录下添加 jvm.config 配置文件

vim jvm.config
添加如下内容
-server
-Xmx16G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError

7)Presto 可以支持多个数据源,在 Presto 里面叫 catalog,这里我们配置支持 Hive 的数据源,配置一个 Hive 的 catalog

[dw@dw1 etc]$ mkdir catalog
[dw@dw1 catalog]$ vim hive.properties
添加如下内容
connector.name=hive-hadoop2   # hadoop的版本
hive.metastore.uri=thrift://dw1:9083

8)将 dw1 上的 presto 分发到 dw2、dw3

xsync presto

9)分发之后,分别进入 dw1、dw2、dw3 三台主机的/opt/module/presto/etc的路径。配置 node 属性,node id 每个节点都不一样。

[dw@dw1etc]$vim node.properties
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=/opt/module/presto/data

[dw@dw2 etc]$vim node.properties
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-fffffffffffe
node.data-dir=/opt/module/presto/data

[dw@dw3 etc]$vim node.properties
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-fffffffffffd
node.data-dir=/opt/module/presto/data

10)Presto 是由一个 coordinator 节点和多个 worker 节点组成。在 dw1 上配置成

coordinator,在 dw2、dw3 上配置为 worker。

(1)dw1 上配置 coordinator 节点
[dw@dw1 etc]$ vim config.properties
添加内容如下
coordinator=true
node-scheduler.include-coordinator=false
http-server.http.port=8881
query.max-memory=50GB
discovery-server.enabled=true
discovery.uri=http://dw1:8881

(2)dw2、dw3上配置 worker 节点(dw3一样所以忽略)
[dw@dw2 etc]$ vim config.properties
添加内容如下
coordinator=false
http-server.http.port=8881
query.max-memory=50GB
discovery.uri=http://dw1:8881

11)在 dw1 的/opt/module/hive 目录下,启动 Hive Metastore,用 dw角色

[dw@dw1 hive]$ nohup bin/hive --service metastore >/dev/null 2>&1 &

12)分别在 dw1、dw2、dw3上启动 Presto Server
(1)前台启动 Presto,控制台显示日志

[dw@dw1 presto]$ bin/launcher run
[dw@dw2 presto]$ bin/launcher run
[dw@dw3 presto]$ bin/launcher run

(2)后台启动 Presto

[dw@dw1 presto]$ bin/launcher start
[dw@dw2 presto]$ bin/launcher start
[dw@dw3 presto]$ bin/launcher start
xcall.sh /opt/module/presto/bin/launcher start 群起

13)日志查看路径/opt/module/presto/data/var/log
在这里插入图片描述

1.2.2Presto 命令行Client 安装

1)下载 Presto 的客户端

https://repo1.maven.org/maven2/com/facebook/presto/presto-cli/0.196/presto-cli-0.196-executable.jar

2)将 presto-cli-0.196-executable.jar 上传到 dw1 的/opt/module/presto 文件夹下
3)修改文件名称 mv presto-cli-0.196-executable.jar prestocli
4)增加执行权限

chmod +x prestocli  

5)启动 prestocli

./prestocli --server dw1:8881 --catalog hive --schema default   /或者通过java -jar执行

6)Presto 命令行操作

Presto 的命令行操作,相当于 Hive 命令行操作。每个表必须要加上 schema。
例如:
show schema;
use gmall;
select * from dwd_start_log limit;

无法查询lzo文件,需要改源码,可以支持parquet后的lzo文件
presto默认无法查询dwd中列式存储并lzo压缩的表,需要将lzo的jar包添加到presto主目录下plugin内对应的数据源里(hive-hadoop2)并分发给集群之后,重启persto集群

1.2.3Presto 可视化Client 安装

1)将 yanagishima-18.0.zip 上传到 dw1 的/opt/module 目录
2)解压缩 yanagishima

unzip yanagishima-18.0.zip
cd yanagishima-18.0

3)进入到/opt/module/yanagishima-18.0/conf 文件夹,编写 yanagishima.properties 配置

尾部追加如下内容
jetty.port=7080
presto.datasources=dw1-presto
presto.coordinator.server.dw1-presto=http://dw1:8881
catalog.dw1-presto=hive
schema.dw1-presto=default
sql.query.engines=presto

4)在/opt/module/yanagishima-18.0 路径下启动 yanagishima

[dw@dw1 yanagishima-18.0]$ nohup bin/yanagishima-start.sh >y.log 2>&1 &

在这里插入图片描述
5)启动 web 页面

http://dw1:7080

在这里插入图片描述
注意:不能写“;”号

1.3Presto 优化之数据存储

在这里插入图片描述
在这里插入图片描述

1.4Presto 优化之查询SQL

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
广播join,大表切分,小表广播
hash join 大表对大表

1.5注意事项

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值