本文章向大家介绍Docker安装Presto连接Hive,主要包括Docker安装Presto连接Hive使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
1、简介Presto 是一个开源分布式 SQL 查询引擎,用于针对从千兆字节到 PB 级的各种规模的数据源运行交互式分析查询。Presto 允许查询数据所在的位置,包括 Hive、Cassandra、关系数据库甚至专有数据存储。单个 Presto 查询可以组合来自多个来源的数据,从而允许对整个组织进行分析。
2、下载安装 1)下载镜像docker pull starburstdata/presto
下载过程:
Last login: Tue Jun 14 10:58:46 on ttys001 zxf@localhost ~ % docker pull starburstdata/presto Using default tag: latest latest: Pulling from starburstdata/presto 2d473b07cdd5: Pull complete 54c6b866b90d: Pull complete 9a2bdd16fa83: Pull complete 547ac96cdcb8: Pull complete f341031b4ad5: Pull complete ec9d1adc03e7: Pull complete 12b2f706192d: Pull complete d5e53479b75a: Pull complete Digest: sha256:8500cab845f47aef2a89be9500350b88b7061e587d272e64ddbc94f0ce2cf8ed Status: Downloaded newer image for starburstdata/presto:latest docker.io/starburstdata/presto:latest zxf@localhost ~ %2)下载presto客户端jar文件
因为pull下来的镜像是server,是没有presto-cli命令的,所以需要下载presto-cli-0.260.1-executable.jar,然后将下载好的jar包拉入Linux系统中。
下载完成后,run容器:
#端口号为8080,请自行修改,名字为presto
docker run -d -p 8080:8080 --name presto starburstdata/presto
将客户端jar包拷贝到容器中的bin目录下:
docker cp [客户端jar包所在的linux路径] [容器名]:/bin
如:
zxf@localhost Downloads % docker cp /Users/zxf/Downloads/presto-cli-0.260.1-executable.jar presto:/bin3)将hadoop配置拷贝到容器
进入到hadoop配置文件目录,将core-site.xml和hdfs-site.xml复制到容器中
cd ${HADOOP_HOME}/etc/hadoop
docker cp core-site.xml presto:/usr/lib/presto/etc/
docker cp hdfs-site.xml presto:/usr/lib/presto/etc/
我的不是装本地,远程连接,所以找到
进入容器(以下不标注都是在容器中进行的操作):
#以root用户进入容器,防止没有权限操作文件
docker exec --user=root -it presto /bin/bash
将客户端jar包改名并赋予可执行权限:
cd bin mv presto-cli-0.260.1-executable.jar presto-cli chmod a+x presto-cli4)新增hive.properties配置文件
进入配置文件目录,创建hive配置文件:
cd /usr/lib/presto/etc/catalog vi hive.properties
hive.properties:
#连接名,固定 connector.name=hive-hadoop2 #hive元数据uri,在hive-site.xml里能够找到,请自行修改ip和端口 hive.metastore.uri=thrift://dsmaster:19083 #hive配置的资源 core-site.xml和hdfs-site.xml,请根据自己集群中的配置文件路径进行修改,中间用逗号隔开 hive.config.resources=/usr/lib/presto/etc/core-site.xml,/usr/lib/presto/etc/hdfs-site.xml
wq保存退出
其中,元数据可以去ambari上看
5)重启容器(在linux命令行下):重启前检查下3个文件权限(core-site.xml、hdfs-site.xml和hive.properties)
[root@e640f5a2d205 bin]# cd /usr/lib/presto/etc/catalog/ [root@e640f5a2d205 catalog]# ls -l total 20 -rw-r--r-- 1 501 games 401 Jun 14 07:16 hive.properties -rw-r--r-- 1 presto root 19 Dec 17 2020 jmx.properties -rw-r--r-- 1 presto root 22 Dec 17 2020 memory.properties -rw-r--r-- 1 presto root 45 Dec 17 2020 tpcds.properties -rw-r--r-- 1 presto root 43 Dec 17 2020 tpch.properties [root@e640f5a2d205 catalog]# chown presto:root hive.properties [root@e640f5a2d205 catalog]# ls -l total 20 -rw-r--r-- 1 presto root 401 Jun 14 07:16 hive.properties -rw-r--r-- 1 presto root 19 Dec 17 2020 jmx.properties -rw-r--r-- 1 presto root 22 Dec 17 2020 memory.properties -rw-r--r-- 1 presto root 45 Dec 17 2020 tpcds.properties -rw-r--r-- 1 presto root 43 Dec 17 2020 tpch.properties [root@e640f5a2d205 catalog]# cd .. [root@e640f5a2d205 etc]# ll total 36 drwxr-xr-x 1 presto root 4096 Jun 14 07:20 catalog -rw-r--r-- 1 presto root 178 Dec 17 2020 config.properties -rw-r--r-- 1 501 games 4655 Jun 14 03:52 core-site.xml -rw-r--r-- 1 501 games 6941 Jun 14 04:01 hdfs-site.xml -rw-r--r-- 1 presto root 295 Dec 17 2020 jvm.config -rw-r--r-- 1 presto root 57 Dec 17 2020 log.properties -rw-r--r-- 1 presto root 85 Dec 17 2020 node.properties [root@e640f5a2d205 etc]# chown presto:root * [root@e640f5a2d205 etc]# ls -l total 36 drwxr-xr-x 1 presto root 4096 Jun 14 07:20 catalog -rw-r--r-- 1 presto root 178 Dec 17 2020 config.properties -rw-r--r-- 1 presto root 4655 Jun 14 03:52 core-site.xml -rw-r--r-- 1 presto root 6941 Jun 14 04:01 hdfs-site.xml -rw-r--r-- 1 presto root 295 Dec 17 2020 jvm.config -rw-r--r-- 1 presto root 57 Dec 17 2020 log.properties -rw-r--r-- 1 presto root 85 Dec 17 2020 node.properties
docker restart presto3、测试连接
进入容器:
#以root用户进入容器,防止没有权限操作文件
docker exec --user=root -it presto /bin/bash
#进入bin目录
cd bin
#执行命令行脚本并测试hive连接,连接到hive配置文件,数据库是default
[root@e640f5a2d205 /]# cd bin
[root@e640f5a2d205 bin]# ./presto-cli --server localhost:8080 --catalog hive --schema default
presto:default> show tables;
Table
-----------------------
buss
sdm_info_1
t_sys
t_sys_data_permission
t_user
(5 rows)
Query 20220614_073624_00009_wd2j6, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0:01 [5 rows, 131B] [3 rows/s, 88B/s]
presto:default>
#换test看看
presto:default>exit
[root@e640f5a2d205 bin]# ./presto-cli --server localhost:8080 --catalog hive --schema test
presto:test> show tables;
Table
------------
buss
newtable
sdm_info_1
(3 rows)
Query 20220614_073524_00006_wd2j6, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0:04 [3 rows, 64B] [0 rows/s, 16B/s]
presto:test>
说明:要是连不上,检查/etc/hosts,有做集群的,要都带上,如:
192.168.1.86 dsmaster
192.168.1.87 dsslave1
192.168.1.88 dsslave2
hive环境搭建可参考,小编整理的详细安装过程,有问题可以留言,谢谢!
Ambari安装和配置详细步骤_小慌慌的博客-CSDN博客_ambari安装目录一、准备环境二、修改主机名和hosts文件八、安装ambari九、系统配置十、实例演示一、准备环境1、服务器准备至少3台我这边准备了3台:192.168.1.86(master)192.168.1.87(slave1)192.168.1.88(slave2)2、在(master上):mkdir -p /var/www/html3、ambari依赖包准备,上传到主节点master的/var/www/html路径下(本次选择的amb..https://blog.csdn.net/whowhowhoisimportant/article/details/120096424?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165519242616782425118312%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165519242616782425118312&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-120096424-null-null.nonecase&utm_term=amb&spm=1018.2226.3001.4450



