【运维】hive 终端突然不能使用:Hive Schema version does not match metastore‘s schema version

文章描述了在执行Hive命令时遇到的SemanticException,原因是Hiveschema版本(3.1.0)与metastore的schema版本(1.2.0)不一致。常规排查包括检查元数据库的初始化和hive-site.xml的配置。最终解决方案是通过在hive-site.xml中添加配置禁用版本验证,从而解决命令执行失败的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一. 问题描述

进入hive终端,执行如下命令报错:

hive> show tables;
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException: Unable to instantiate
org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient*

Error “Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient”
字面意思就是无法实例化hive Metastore client端。

 

二. 常规排查

先朝着hive的一些配置入手排查:

1. 元数据库

hive元数据库是否初始化,库是否正常存在,hive的元数据配置在mysql:
在这里插入图片描述

元数据库没有问题,且相关库表也都存在,说明进行了初始化,并且hive元数据没有丢失。

注意:

如果元数据不存在,或者库已经损坏,这可以删除库之后,重新进行初始化:
schematool -dbType mysql -initSchema

 

2. hive-site.xml相关meta连接信息检查

在这里插入图片描述

连接信息ok,到此说明我们在安装、配置hive时是没有问题的,接着分析日志。

 

三. 正解

查看hive运行日志:

MetaException(message:Hive Schema version 3.1.0 does not match metastore's schema version 1.2.0 Metastore is not upgraded or corrupt)
        at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:84)
        at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:93)
        at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:8661)
        at org.apache.hadoop.hive.metastore.HiveMetaStore.newRetryingHMSHandler(HiveMetaStore.java:8656)
        at org.apache.hadoop.hive.metastore.HiveMetaStore.startMetaStore(HiveMetaStore.java:8926)
        at org.apache.hadoop.hive.metastore.HiveMetaStore.main(HiveMetaStore.java:8843)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:239)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:153)
Caused by: MetaException(message:Hive Schema version 3.1.0 does not match metastore's schema version 1.2.0 Metastore is not upgraded or corrupt)
        at org.apache.hadoop.hive.metastore.ObjectStore.checkSchema(ObjectStore.java:9063)
        at org.apache.hadoop.hive.metastore.ObjectStore.verifySchema(ObjectStore.java:9027)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.hive.metastore.RawStoreProxy.invoke(RawStoreProxy.java:97)
        at com.sun.proxy.$Proxy25.verifySchema(Unknown Source)
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMSForConf(HiveMetaStore.java:697)
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMS(HiveMetaStore.java:690)
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultDB(HiveMetaStore.java:767)
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:538)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invokeInternal(RetryingHMSHandler.java:147)
        at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invoke(RetryingHMSHandler.java:108)
        at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:80)
        ... 11 more 

关键信息:

(message:Hive Schema version 3.1.0 does not match metastore’s schema version 1.2.0 Metastore is not upgraded or corrupt)

简单的说,hive schema和metastore的schema版本不一致,通过分析相关堆栈方法:checkSchema、verifySchema,基本可以了解,在执行hive shell命令之前,hive会校验hive schema和metastore的schema的版本,如果版本不一致则直接抛出异常导致命令不可使用。
 

而这个问题是在使用一段时间之后突然出现的,那我们暂时可以认为,hive schema和metastore的schema版本不一致,不会影响hive的正常使用,而这个问题可以:

add below properties in hive-site.xml.

<property>
    <name>hive.metastore.schema.verification</name>
    <value>false</value>
</property>

即配置禁用版本验证来解决问题。

 

配置好之后,重新进入hive,执行命令,问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

roman_日积跬步-终至千里

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值