Presto连接Hive

栏目: 数据库 · 发布时间: 5年前

内容简介:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kongxx/article/details/83409435

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kongxx/article/details/83409435

接前一篇文章,这里只说怎样连接Hive。

配置 Hive Connector

  • etc/catalog/hive.properties
connector.name=hive-hadoop2
hive.metastore.uri=thrift://<hive_metastore_ip>:9083
hive.config.resources=/opt/presto-server-0.211/etc/cluster/core-site.xml,/opt/presto-server-0.211/etc/cluster/hdfs-site.xml

其中 hive.metastore.uri 可以从 hive-site.xml 文件中获取。

将配置复制到其它节点的相同目录下。

hdfs 配置文件

从 hdfs 的环境中复制 core-site.xml 和 hdfs-site.xml 文件到 presto 的 etc/cluster 目录下。

将配置复制到其它节点的相同目录下。

启动 Prestore

分别在两个节点上重新启动 Presto 服务。

在 Hive 中创建数据库、数据表和数据

$ hive

# 创建数据库
hive> create schema test; 

# 查询数据库
hive> show databases;
+---------------------+
|    database_name    |
+---------------------+
| default             |
| information_schema  |
| sys                 |
| test                |
+---------------------+

# 显示数据库中的表
hive> show tables from test;
+-----------+
| tab_name  |
+-----------+
+-----------+

# 创建数据表
hive> CREATE TABLE test.users(id int, username string, password string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
...

# 插入数据
hive> insert into table test.users values (1, 'user1', 'password1'), (2, 'user2', 'password2'), (3, 'user3', 'password3');
...

# 查询数据
hive> select * from test.users;
+-----------+-----------------+-----------------+
| users.id  | users.username  | users.password  |
+-----------+-----------------+-----------------+
| 1         | user1           | password1       |
| 2         | user2           | password2       |
| 3         | user3           | password3       |
+-----------+-----------------+-----------------+

通过 Presto 查询数据

# 启动 presto 命令行
$ ./presto --server bd1:8080 --catalog hive --schema test

# 查询数据库
presto:test> show schemas from hive;
       Schema       
--------------------
 default            
 information_schema 
 sys                
 test               
(4 rows)

# 查询数据表
presto:test> show tables from hive.test;
 Table  
--------
 users  
 users2 
(2 rows)

# 查询数据
presto:test> select * from hive.test.users;
 id | username | password 
----+----------+----------
(0 rows)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Text Algorithms

Text Algorithms

Maxime Crochemore、Wojciech Rytter / Oxford University Press / 1994

This much-needed book on the design of algorithms and data structures for text processing emphasizes both theoretical foundations and practical applications. It is intended to serve both as a textbook......一起来看看 《Text Algorithms》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具