Hive启动失败:java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.Sessio

错误日志如下:
[hadoop@master hive1.0.0]$ bin/hive

Logging initialized using configuration in file:/opt/modules/hive1.0.0/conf/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/modules/hadoop-2.6.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/modules/hive1.0.0/lib/hive-jdbc-1.0.0-standalone.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.slf4j.impl.Log4jLoggerFactory]
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
	at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)
	at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:626)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:570)
	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:497)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
	at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1453)
	at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMetaStoreClient.java:63)
	at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:73)
	at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:2664)
	at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:2683)
	at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:425)
	... 8 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1451)
	... 13 more
Caused by: javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://master:3306/hive?characterEncoding=UTF-8, username = hive. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

      从日志文件可以看出,该错误出现的原因是未能成功开启到数据库的链接。而这又是由于我们的数据库没有启动/成功启动所导致的。由于Hive配置的元数据在MySQL里面,而且MySQL是和集群的Namenode安装在一台机器上的。而我们的集群被重启了,而MySQL又没有启动,所以就出了以上问题。

以上就是博主为大家介绍的这一板块的主要内容,这都是博主自己的学习过程,希望能给大家带来一定的指导作用,有用的还望大家点个支持,如果对你没用也望包涵,有错误烦请指出。如有期待可关注博主以第一时间获取更新哦,谢谢! 

 版权声明:本文为博主原创文章,未经博主允许不得转载。


### 解决Hive中 `Unable to instantiate` 的异常问题 遇到 `FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient` 错误通常意味着 Hive 无法实例化会话元存储客户端。这可能是由于多种原因引起的,包括但不限于配置不正确、依赖库缺失或版本兼容性问题。 #### 配置调整 一种常见的解决方案是进入 `hive/conf` 文件夹并编辑 `hive-site.xml` 文件。具体操作为注释掉可能导致冲突的参数设置[^4]: ```xml <!-- <property> <name>hive.metastore.warehouse.dir</name> <value>/user/hive/warehouse</value> </property> --> ``` 另一种有效的方法是在 `hive-site.xml` 中添加特定属性来指定 Metastore URI: ```xml <property> <name>hive.metastore.uris</name> <value>thrift://hive服务器的IP地址:9083</value> </property> ``` 上述更改有助于确保 Hive 客户端能够正确连接到远程Metastore服务[^5]。 #### 数据库重置尝试 如果之前的操作未能解决问题,则可以考虑清理现有的 MySQL 元数据库 (metastore),然后通过命令 `schematool -initSchema -dbType mysql` 来重新初始化它。不过需要注意的是,在执行此操作前应备份现有数据以防意外丢失。 #### 版本一致性检查 确认所使用的 HadoopHive 组件之间的版本相互匹配也很重要。不同版本之间可能存在API变化或其他差异,这些都可能引发此类错误。因此建议查阅官方文档以获取推荐搭配列表,并据此调整环境中的软件版本[^1]。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值