当基础HDFS群集不再存在时如何从Hive Metastore中删除数据库

时间:2018-11-03 13:51:07

标签: hive hdfs google-cloud-dataproc hive-metastore

我正在使用临时GCP Dataproc集群(Apache Spark 2.2.1,Apache Hadoop 2.8.4和Apache Hive 2.1.1)。这些群集都指向同一个Hive Metastore(托管在Google Cloud SQL实例上)。

我在一个这样的集群上创建了一个数据库,并将其位置设置为“ HDFS:/// database_name”,如下所示:

$ gcloud dataproc jobs submit hive \
    -e "create database db_name LOCATION 'hdfs:///db_name'" \
    --cluster=my-first-ephemeral-cluster --region=europe-west1

my-first-ephemeral-cluster然后被删除,并且与之关联的HDFS。

此后在所有后续群集上弹出以下错误:

u'java.net.UnknownHostException: my-first-ephemeral-cluster-m'

这可能是因为Hive Metastore现在为不存在的位置提供了一个条目。 尝试删除损坏的数据库也不可行:

$ gcloud dataproc jobs submit hive \
    -e 'drop database db_name' \
    --cluster=my-second-ephemeral-cluster --region=europe-west1

Job [4462cb1d-88f2-4e2b-8a86-c342c0ce46ee] submitted.
Waiting for job output...
Connecting to jdbc:hive2://my-second-ephemeral-cluster-m:10000
Connected to: Apache Hive (version 2.1.1)
Driver: Hive JDBC (version 2.1.1)
18/11/03 13:40:04 [main]: WARN jdbc.HiveConnection: Request to set autoCommit to false; Hive does not support autoCommit=false.
Transaction isolation: TRANSACTION_REPEATABLE_READ
Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:java.lang.IllegalArgumentException: java.net.UnknownHostException: my-first-ephemeral-cluster-m) (state=08S01,code=1)
Closing: 0: jdbc:hive2://my-second-ephemeral-cluster-m:10000

原因是主机my-first-ephemeral-cluster-m不再有效。由于更改数据库的位置不是我正在使用的配置单元版本的选项,因此需要一种不同的解决方法来删除该数据库。

2 个答案:

答案 0 :(得分:0)

https://cwiki.apache.org/confluence/display/Hive/Hive+MetaTool

  

Hive MetaTool使管理员可以在服务器上进行 批量更新。   数据库,表和分区记录中的位置字段   metastore(...)
  
  例子(...)
  ./hive --service metatool -updateLocation hdfs://localhost:9000 hdfs://namenode2:8020

但是首先,您需要知道伪HDFS路径以“规范”形式(例如, hdfs://my-first-ephemeral-cluster-m/db_name(如果Google某种程度上遵循Hadoop标准)

答案 1 :(得分:0)

基于我的观点,删除导致错误的Hive Metastore条目的正确方法是在删除群集my-first-ephemeral-cluster(例如,按以下顺序执行的脚本)之前删除数据库:

gcloud dataproc jobs submit hive -e 'drop database db_name' --cluster=my-first-ephemeral-cluster --region=europe-west1
gcloud dataproc clusters delete my-first-ephemeral-cluster  

但是,我发现Cloud SQL proxy的说明用于使用云存储在不同Dataproc集群之间建立共享的配置单元仓库(而不是在本地HDFS中创建配置单元仓库的位置'hdfs:/// db_name') ,这可能会给您一种您想要的行为。