为 Presto 和 AWS S3 设置独立的 Hive Metastore 服务

Setup Standalone Hive Metastore Service For Presto and AWS S3

我工作的环境中有一个 S3 服务用作数据湖,但没有 AWS Athena。我正在尝试设置 Presto 以便能够查询 S3 中的数据,并且我知道我需要通过 Hive Metastore 服务将数据结构定义为 Hive 表。我在 Docker 中部署每个组件,因此我希望容器大小尽可能小。我需要 Hive 的哪些组件才能 运行 Metastore 服务?我实际上并不关心 运行ning Hive,只关心 Metastore。我可以 trim 记下需要的东西吗,或者是否已经有一个预配置的软件包?我无法在网上找到任何不包括下载所有 Hadoop 和 Hive 的内容。我正在尝试做的事情可行吗?

有一个解决方法,您不需要 hive 到 运行 presto。但是我还没有尝试过像 s3 这样的任何分布式文件系统,但是代码表明它应该可以工作(至少对于 HDFS)。在我看来,值得尝试,因为您根本不需要任何新的 docker 图像用于配置单元。

我们的想法是使用内置 FileHiveMetastore。它既没有记录 也不建议在生产中使用 但您可以使用它。模式信息存储在文件系统中的数据旁边。显然,它有利有弊。我不知道你的用例的细节,所以我不知道它是否符合你的需求。

配置:

connector.name=hive-hadoop2
hive.metastore=file
hive.metastore.catalog.dir=file:///tmp/hive_catalog
hive.metastore.user=cox

演示:

presto:tiny> create schema hive.default;
CREATE SCHEMA
presto:tiny> use hive.default;
USE
presto:default> create table t (t bigint);
CREATE TABLE
presto:default> show tables;
 Table
-------
 t
(1 row)

Query 20180223_202609_00009_iuchi, FINISHED, 1 node
Splits: 18 total, 18 done (100.00%)
0:00 [1 rows, 18B] [11 rows/s, 201B/s]

presto:default> insert into t (values 1);
INSERT: 1 row

Query 20180223_202616_00010_iuchi, FINISHED, 1 node
Splits: 51 total, 51 done (100.00%)
0:00 [0 rows, 0B] [0 rows/s, 0B/s]

presto:default> select * from t;
 t
---
 1
(1 row)

完成上述操作后,我在我的机器上找到了以下内容:

/tmp/hive_catalog/
/tmp/hive_catalog/default
/tmp/hive_catalog/default/t
/tmp/hive_catalog/default/t/.prestoPermissions
/tmp/hive_catalog/default/t/.prestoPermissions/user_cox
/tmp/hive_catalog/default/t/.prestoPermissions/.user_cox.crc
/tmp/hive_catalog/default/t/.20180223_202616_00010_iuchi_79dee041-58a3-45ce-b86c-9f14e6260278.crc
/tmp/hive_catalog/default/t/.prestoSchema
/tmp/hive_catalog/default/t/20180223_202616_00010_iuchi_79dee041-58a3-45ce-b86c-9f14e6260278
/tmp/hive_catalog/default/t/..prestoSchema.crc
/tmp/hive_catalog/default/.prestoSchema
/tmp/hive_catalog/default/..prestoSchema.crc

只需要为 Metastore 设置配置单元似乎确实很麻烦。 您是否考虑过改用 AWS glue 数据目录? 这样你就不必管理任何东西。 您可以在此处找到详细信息:https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-presto-glue.html

它现在可以在 Apache Hive 发行版中单独使用 /hive-standalone-metastore-3.0.0/

Beginning in Hive 3.0, the Metastore is released as a separate package and can be run without the rest of Hive. This is referred to as standalone mode.

By default the Metastore is configured for use with Hive, so a few configuration parameters have to be changed in this configuration.

metastore.task.threads.always -> org.apache.hadoop.hive.metastore.events.EventCleanerTask,org.apache.hadoop.hive.metastore.MaterializationsCacheCleanerTask
metastore.expression.proxy -> org.apache.hadoop.hive.metastore.DefaultPartitionExpressionProxy

Link to Docs

我能够使用 Presto SQL amd HMS 3.0 与 AWS S3 集成。如果有帮助,我写了一篇文章。 https://www.linkedin.com/pulse/presto-sql-s3-abhishek-gupta