立即注册 登录
About云-梭伦科技 返回首页

muyannian的个人空间 https://www.aboutyun.com/?440 [收藏] [复制] [分享] [RSS]

日志

Hive Failed to connect to the MetaStore Server 解决方案

已有 2487 次阅读2014-12-10 14:29

1、最近在自学hive。安装hive及使用hive自带数据库可以正常运行。但是呢我想使用mysql作为后台数据库。因此要进行一翻配置。根据网上的文档,配置后,使用命令

Java代码  收藏代码
  1. show databases  

 时,报错。错误信息是:

Java代码  收藏代码
  1. Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient  

 再看hive.log 日志记录:

Java代码  收藏代码
  1. 2013-06-01 11:52:16,379 WARN  hive.metastore (HiveMetaStoreClient.java:open(285)) - Failed to connect to the MetaStore Server...  
  2. 2013-06-01 11:52:17,382 WARN  hive.metastore (HiveMetaStoreClient.java:open(285)) - Failed to connect to the MetaStore Server...  
  3. 2013-06-01 11:52:18,383 WARN  hive.metastore (HiveMetaStoreClient.java:open(285)) - Failed to connect to the MetaStore Server...  
  4. 2013-06-01 11:52:19,386 WARN  hive.metastore (HiveMetaStoreClient.java:open(285)) - Failed to connect to the MetaStore Server...  
  5. 2013-06-01 11:52:20,387 WARN  hive.metastore (HiveMetaStoreClient.java:open(285)) - Failed to connect to the MetaStore Server...  
  6. 2013-06-01 11:52:21,392 ERROR exec.Task (SessionState.java:printError(401)) - FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient  
  7. org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient  

 

日志信息可以看出是:不能connect to metaStore server的问题。

我的解决方案是:

1)先检查mysql 链接jdbc使用到的启动 JAR是否放到 hive/lib 下面。

2)在hive运行的服务器,使得mysql命令行,看能否成功链接到mysql服务器。我的hive有mysql运行在同一台机器上,使用root用户登陆mysql,创建帐户(hive),赋予权限后,hive 还是不能登录,根据错误信息,在网上找到的问题原因是:mysql库中的user表中存在user 为空的记录,解决方案是:删除user表中user字段为空的记录。最后不能要忘了运行:flush privileges 命令。确认hive账户可以在运行hive服务的机器上登录mysql服务器;

3)正确配置hive-site.xml。

4)我遇到的问题是:配置完 hive-site.xml后,运行 show tables ,同样报上述错误。再次检查hive-site.xml 配置,发现:

Xml代码  收藏代码
  1. <property>  
  2.   <name>hive.metastore.uris</name>  
  3.   <value>thrift://xxxxxxxx</value>  
  4.   <description>Thrift uri for the remote metastore. Used by metastore client to connect to remote metastore.</description>  
  5. </property>  

 我不知道这个配置是干什么用的。果断清空value的值。再次运行show databases命令。成功!!!!

5)再次提醒读者朋友们:当你们的错误信息与上述错误相似时,请认真检查 hive.metastore.uris 的value 配置是否正确。建义新手不要配置。

最后与大家分享我的hive-site.xml配置:

Xml代码  收藏代码
  1. <property>  
  2.   <name>javax.jdo.option.ConnectionURL</name>  
  3.   <value>jdbc:mysql://127.0.0.1:3306/metastore_db?createDatabaseIfNotExist=true</value>  
  4.   <description>JDBC connect string for a JDBC metastore</description>  
  5. </property>  
  6.   
  7. <property>  
  8.   <name>javax.jdo.option.ConnectionDriverName</name>  
  9.   <value>com.mysql.jdbc.Driver</value>  
  10.   <description>Driver class name for a JDBC metastore</description>  
  11. </property>  
  12.   
  13. <property>  
  14.   <name>javax.jdo.option.ConnectionUserName</name>  
  15.   <value>hive</value>  
  16.   <description>username to use against metastore database</description>  
  17. </property>  
  18.   
  19. <property>  
  20.   <name>javax.jdo.option.ConnectionPassword</name>  
  21.   <value>a123</value>  
  22.   <description>password to use against metastore database</description>  
  23. </property>  

 

新手只需要配置上述四处及可。


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

关闭

推荐上一条 /2 下一条