Presto连接Hive

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

内容简介:版权声明:本文为博主原创文章,未经博主允许不得转载。 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)

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

查看所有标签

猜你喜欢:

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

Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

Lincoln Stein、Doug MacEachern / O'Reilly Media, Inc. / 1999-03 / USD 39.95

Apache is the most popular Web server on the Internet because it is free, reliable, and extensible. The availability of the source code and the modular design of Apache makes it possible to extend Web......一起来看看 《Writing Apache Modules with Perl and C》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码