gpt4 book ai didi

azure - 如何使用附加 Azure Blob 存储上的外部 Metastore 创建/访问 Hive 表?

转载 作者:行者123 更新时间:2023-12-03 04:21:25 32 4
gpt4 key购买 nike

我想使用运行 Azure HDInsight 按需群集 (3.6) 的 Azure 数据工厂 (v1) 在 Hive 中执行一些数据转换。

由于 HDInsight On Demand 群集在空闲一段时间后被破坏,并且我希望/需要保留有关 Hive 表的元数据(例如分区),因此我还使用 Azure SQL Server 数据库配置了外部 Hive 元存储。

现在,我希望将所有生产数据存储在一个单独的存储帐户上,而不是一个“默认”帐户,其中数据工厂和 HDInsight 还为日志记录和其他运行时数据创建容器。

所以我有以下资源:

  • 使用 HDInsight On Demand 的数据工厂(作为链接服务)
  • 用于 Hive 元存储的 SQL Server 和数据库(在 HDInsight On Demand 中配置)
  • 数据工厂和 HDInsight On Demand 群集使用的默认存储帐户(blob 存储,通用 v1)
  • 用于数据入口和 Hive 表的附加存储帐户(blob 存储、通用 v1)

数据工厂除外,其位置为North Europe ,所有资源都在同一位置West Europe ,这应该没问题(HDInsight 群集必须与要使用的任何存储帐户位于同一位置)。所有与数据工厂相关的部署都是使用 DataFactoryManagementClient 完成的API。

示例 Hive 脚本(在数据工厂中作为 HiveActivity 部署)如下所示:

CREATE TABLE IF NOT EXISTS example_table (
deviceId string,
createdAt timestamp,
batteryVoltage double,
hardwareVersion string,
softwareVersion string,
)
PARTITIONED BY (year string, month string) -- year and month from createdAt
CLUSTERED BY (deviceId) INTO 256 BUCKETS
STORED AS ORC
LOCATION 'wasb://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f0939f9e8491999e9582b09194949984999f9e919c83849f82919795de929c9f92de939f8295de87999e949f8783de9e9584" rel="noreferrer noopener nofollow">[email protected]</a>/example_table'
TBLPROPERTIES ('transactional'='true');

INSERT INTO TABLE example_table PARTITIONS (year, month) VALUES ("device1", timestamp "2018-01-22 08:57:00", 2.7, "hw1.32.2", "sw0.12.3");

遵循文档 herehere ,这应该相当简单:只需将新的存储帐户添加为附加链接服务(使用 additionalLinkedServiceNames 属性)。

但是,当 Hive 脚本尝试访问存储在该帐户上的表时,这会导致以下异常:

IllegalStateException Error getting FileSystem for wasb : org.apache.hadoop.fs.azure.AzureException: org.apache.hadoop.fs.azure.KeyProviderException: ExitCodeException exitCode=2: Error reading S/MIME message
139827842123416:error:0D06B08E:asn1 encoding routines:ASN1_D2I_READ_BIO:not enough data:a_d2i_fp.c:247:
139827842123416:error:0D0D106E:asn1 encoding routines:B64_READ_ASN1:decode error:asn_mime.c:192:
139827842123416:error:0D0D40CB:asn1 encoding routines:SMIME_read_ASN1:asn1 parse error:asn_mime.c:517:

Some googling told me当 key 提供程序未正确配置时会发生这种情况(即抛出异常,因为它尝试解密 key ,即使 key 未加密)。手动设置后fs.azure.account.keyprovider.<storage_name>.blob.core.windows.netorg.apache.hadoop.fs.azure.SimpleKeyProvider它似乎适用于读取数据并将数据“简单”写入表,但当元存储参与时(创建表,添加新分区,...)再次失败:

ERROR exec.DDLTask: org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(message:Got exception: org.apache.hadoop.fs.azure.AzureException com.microsoft.azure.storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)
at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:783)
at org.apache.hadoop.hive.ql.exec.DDLTask.createTable(DDLTask.java:4434)
at org.apache.hadoop.hive.ql.exec.DDLTask.execute(DDLTask.java:316)
at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:160)
[...]
at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
Caused by: MetaException(message:Got exception: org.apache.hadoop.fs.azure.AzureException com.microsoft.azure.storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_table_with_environment_context_result$create_table_with_environment_context_resultStandardScheme.read(ThriftHiveMetastore.java:38593)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_table_with_environment_context_result$create_table_with_environment_context_resultStandardScheme.read(ThriftHiveMetastore.java:38561)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_table_with_environment_context_result.read(ThriftHiveMetastore.java:38487)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:86)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_create_table_with_environment_context(ThriftHiveMetastore.java:1103)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.create_table_with_environment_context(ThriftHiveMetastore.java:1089)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.create_table_with_environment_context(HiveMetaStoreClient.java:2203)
at org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient.create_table_with_environment_context(SessionHiveMetaStoreClient.java:99)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.createTable(HiveMetaStoreClient.java:736)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.createTable(HiveMetaStoreClient.java:724)
[...]
at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:178)
at com.sun.proxy.$Proxy5.createTable(Unknown Source)
at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:777)
... 24 more

我再次尝试用谷歌搜索,但没有找到可用的东西。我认为这可能与以下事实有关:元存储服务与 Hive 分开运行,并且由于某种原因无法访问配置的存储帐户 key ...但说实话,我认为这一切都应该可以工作无需手动修改 Hadoop/Hive 配置。

所以,我的问题是:我做错了什么以及这应该如何工作?

最佳答案

您需要确保还将 hadoop-azure.jar 和 azure-storage-5.4.0.jar 添加到 hadoop-env.sh 中的 Hadoop 类路径导出中。

导出HADOOP_CLASSPATH=/usr/lib/hadoop-client/hadoop-azure.jar:/usr/lib/hadoop-client/lib/azure-storage-5.4.0.jar:$HADOOP_CLASSPATH

您将需要通过核心站点中的以下参数添加存储 key 。fs.azure.account.key.{storageaccount}.blob.core.windows.net

创建数据库和表时,您需要使用存储帐户和用户 ID 指定位置创建表 {表名}...位置“wasbs://{container}@{storageaccount}.blob.core.windows.net/{filepath}”

如果尝试上述操作后仍然存在问题,请检查存储帐户是 V1 还是 V2。我们遇到了一个问题,V2 存储帐户不适用于我们的 HDP 版本。

关于azure - 如何使用附加 Azure Blob 存储上的外部 Metastore 创建/访问 Hive 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48384813/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com