hive报错SemanticException org.apache.hadoop.hive.ql.metadata.HiveException

本文介绍了解决Hive2在执行特定操作时报错的方法。通过在配置文件hive-site.xml中添加datanucleus.schema.autoCreateAll=true属性,并重新初始化元数据,可以成功创建数据库。

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

启动hive没有问题,但是当执行show tables或者create database xxx时,报错

hive> create database spark;
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

问题:hive2需要初始化元数据

解决方案:

在hive的配置文件hive-site.xml添加如下配置:

<property>
    <name>datanucleus.schema.autoCreateAll</name>
    <value>true</value>
</property>

在mysql删除原来的hive

drop database hive;

初始化元数据

schematool -initSchema -dbType mysql

重启hive

[root@mini1 hive]#  bin/hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/apps/apache-hive-2.3.4-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/apps/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/root/apps/apache-hive-2.3.4-bin/lib/hive-common-2.3.4.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> create database spark;
OK
Time taken: 7.379 seconds
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值