(二)presto安装并集成hive

目的是实现superset前端数据展示,presto作为后台查询引擎,查询hive中数据
前面的文章:(一)Superset安装 https://blog.csdn.net/Alongpo/article/details/89316827
安装presto:
1.下载presto:
官网地址: https://prestodb.github.io/
下载地址页面: https://prestodb.github.io/docs/current/installation/deployment.html
下载地址这个是我写文档是的最新版为0.218,我安装的是0.196,因为这个还是孵化的项目,所以更新的比较快:https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.218/presto-server-0.218.tar.gz
(二)presto安装并集成hive_第1张图片
架构图:

(二)presto安装并集成hive_第2张图片
2.解压下载的文件,我的版本是0.196,我安装的位置是在/usr/local/bigdata
在这里插入图片描述
(二)presto安装并集成hive_第3张图片
准备文件:
presto-haddoop-xml是我自己创建的文件夹:里面包含的是hadoop集群的 core-site.xml嗨哟 hdfs-site.xml
catalog是(自建)中的是 hive.properties (自建) 作用是配置连接hadoop和hive的信息

  1. 配置文件
    (配置如下几个文件,至于具体含义,看官网,尤其是query.max-memory这种参数,根据自己集群的信息来调节,我的机器的配置是 16cores,32G)
    hive.properties配置信息
connector.name=hive-hadoop2
hive.metastore.uri=thrift://hive-thrift-ip:9083     ## hive thriftserver的地址,端口,这个要看自己集群中hive的元数据信息的地址
hive.config.resources=/usr/local/bigdata/presto-haddoop-xml/core-site.xml,/usr/local/bigdata/presto-haddoop-xml/hdfs-site.xml    ##这个就是连接hadoop的core和hdfs-site.xml文件的位置

presto的集群也是主从式的,主节点和从节点的区别就是config.properties这个配置文件,其他的都差不多

config.properties(master节点配置)

coordinator=true
node-scheduler.include-coordinator=false
http-server.http.port=18082
query.max-memory=12GB
query.max-memory-per-node=2GB
#query.max-total-memory-per-node=2GB
discovery-server.enabled=true
discovery.uri=http://prestoMaster:18082     ##这个ip地址是master节点的ip地址,最好用ip

config.properties(slave节点配置)

coordinator=false
http-server.http.port=18082
query.max-memory=12GB
query.max-memory-per-node=2GB
#query.max-total-memory-per-node=2GB
discovery.uri=http://prestoMaster:18082     ##这个ip笛子是master节点的ip地址,最好用ip

jvm.config

-server
-Xmx8G
-XX:+UseG1GC
-XX:G1HeapRegionSize=64M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p
-DHADOOP_USER_NAME=admin

log.properties


com.facebook.presto=DEBUG

node.properties (这个我列出了两个角色的node.properties,分别是 master节点还有一个slave节点)

node.environment=production
node.id=prestoMaster    ##主机名
node.data-dir=/usr/local/bigdata/presto/data

node.environment=production
node.id=prestoslave01   ##主机名
node.data-dir=/usr/local/bigdata/presto/data

4.(测试)启动

cd /usr/local/bigdata/presto-server-0.196/bin
./presto --server prestoMaster:18082 --catalog hive --schema default    (这个的--server是根据config.properties文件中的discovery.uri 属性来定的)

presto在启动客户端之后

show schemas;   == show databases;
use oneschema;  == use onedatabase;
show tables;

如果table过多的话,就会不自动退出,点q就可以退出到客户端中
(二)presto安装并集成hive_第4张图片
5.启动后台程序

 cd /usr/local/bigdata/presto-server-0.196/bin
./launch start<后台运行>
./launcher restart
./launch stop 
./launch status 查看状态
./launch run<前台运行>

日志的位置就是在这里: /usr/local/bigdata/presto/data/var/log
前段界面的访问地址:http://prestoMaster-ip:18082 我们公司生产环境还有办公环境不互通,所以需要运维进行地址映射,如果不需要映射的就是这个访问的地址。
(二)presto安装并集成hive_第5张图片
6.presto查询导出文件,查询文件
实现功能:用hive库 中的ods数据库,查询sql.sql中的内容,以csv的方式输出,重定向到log.txt
–help查找对应的命令格式

 ./presto --server prestoMaster:18082 --catalog hive --schema ods --output-format CSV --file sql.sql > log.txt

sql.sql中的文件内容就是查询的sql,这个是实现类似于 hive -f sql.sql 这个功能。

你可能感兴趣的:(presto,presto安装,presto,hive,presto集成hive,presto,superset)