2014-03-28 127 views
26

我已经在链接上配置了我的Hive:http://www.youtube.com/watch?v=Dqo1ahdBK_A,但在Hive中创建表时出现以下错误。我正在使用hadoop-1.2.1和hive-0.12.0。java.lang.RuntimeException:无法实例化org.apache.hadoop.hive.metastore.HiveMetaStoreClient

hive> create table employee(emp_id int,name string,salary double); 
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient 

回答

37

看起来像您的metastore问题。如果您正在使用默认配置单元metastore嵌入式德比。如果出现异常退出,锁定文件将在那里。如果删除锁定文件这个问题将得到解决

rm metastore_db/*.lck 
+0

这对我有效!谢谢 –

+1

我每次使用pyspark时都要运行rm命令,为什么? – user1532587

+0

不建议使用默认的derby数据库作为配置单元后端,使用derby作为Hive后端,一次只能建立一个会话。最好的选择是解决这个问题是使用MySQL/Postgres/Oracle服务器作为Hive后端而不是德比。 – sachin

0

重新启动虚拟机或系统也应解除锁定。

8

这可能是一个问题,像所描述的sachinjose或连接问题的metastore。以调试模式运行蜂巢控制台,像这样:

hive -hiveconf hive.root.logger=DEBUG,console

然后执行一个简单的查询像show tables;看看会发生什么。我在重新启动namenode后遇到了这个问题,这是由于在配置文件中设置了错误的主机(ec2在重新启动时生成新的专用IP /主机名)。

0

这可能归因于多个“metastore_db”。删除从$ HIVE_HOME/bin文件夹“metastore_db”,重启Hadoop集群和开放的蜂巢外壳

3

从控制台运行此命令:

./hive -hiveconf hive.root.logger=DEBUG,console 

现在运行

show databases; 

如果你看到下面的异常:

java.sql.SQLException: A read-only user or a user in a read-only database is not permitted to disable read-only mode on a connection. 

这意味着有一些权限问题与metastore_db。您需要更改完整文件夹的权限。我以hdfs用户身份运行我的配置单元。因此,我在hive目录中使用了命令

chown -R hdfs:hadoop * 

。这解决了这个问题。

0

作为一个新手我得到了同样的一套错误。
发现我的例子namenode中的一个守护进程没有启动。 在安装hadoop时,让它成为遵循命令的习惯是明智的:
ps -ef | grep“namenode”
ps -ef | grep“datanode”
ps -ef | grep“tracker”

如果任何守护进程不工作,需要检查相关日志。

1
rm metastore_db/*.lck 

它也适用于我。 它可以在您的home/user目录中找到。您可以使用locate命令来查找它: locate metastore_db

删除锁定文件后,关闭当前会话。 在新会话中调用配置单元外壳

0

如果它在本地计算机上,看起来您已经使用配置单元shell /会话打开了另一个终端。您只能使用嵌入式德比数据库进行一个会话。关闭所有其他配置单元会话并尝试。

2
hive> show databases; 
FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient 
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask 

要解决此问题,请先启动hadoop服务。

$ start-all.sh 

然后我跑

hive> show database; 

它工作正常的我。

1

make hive.metastore.schema.verification = false在hive-site.xml文件中 这个错误将被删除。在我的情况下,它运作良好。

-1

我面临同样的问题 - 使用下面的步骤来解决它:

  1. 创建一个文件蜂巢-site.xml中,输入详细信息(本地/生产模式)。请确保以下位置中存在的/ home/Hadoop的/ bhishm /仓库

    例子:

    <?xml version="1.0"?> 
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> 
    <configuration> 
    <property> 
        <name>hive.metastore.warehouse.dir</name> 
        <value>/home/hadoop/bhishm/warehouse</value> 
        <description> 
        Local or HDFS directory where Hive keeps table contents. 
        </description> 
    </property> 
    <property> 
        <name>hive.metastore.local</name> 
        <value>true</value> 
        <description> 
        Use false if a production metastore server is used. 
        </description> 
    </property> 
    <property> 
        <name>javax.jdo.option.ConnectionURL</name> 
        <value>jdbc:derby:;databaseName=/home/hadoop/bhishm/warehouse/metastore_db;create=true</value> 
        <description> 
        The JDBC connection URL. 
        </description> 
    </property> 
    </configuration> 
    
  2. 编辑hive-env.sh - >添加Java路径作为第一线减少内存使用后:

    实施例:

    # Hive Client memory usage can be an issue if a large number of clients 
    # are running at the same time. The flags below have been useful in 
    # reducing memory usage: 
    
    # The java implementation to use. Required. 
    
    export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk 
    
  3. 运行蜂巢查询。

0

删除hive-site.xml中的代码并将此代码粘贴到hive-site.xml中。

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- 
Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE file distributed with 
this work for additional information regarding copyright ownership. 
The ASF licenses this file to You under the Apache License, Version 2.0 
(the "License"); you may not use this file except in compliance with 
the License. You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. 
--> 
<configuration> 
<property> 
<name>javax.jdo.option.ConnectionURL</name> 
<value>jdbc:derby:;databaseName=/home/hadoop/Desktop/apache-hive-2.1.1-bin/metastore_db;create=true</value> 
<description> 
JDBC connect string for a JDBC metastore. 
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. 
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database. 
</description> 
</property> 
<property> 
<name>hive.metastore.warehouse.dir</name> 
<value>/user/hive/warehouse</value> 
<description>location of default database for the warehouse</description> 
</property> 
<property> 
<name>hive.metastore.uris</name> 
<value/> 
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description> 
</property> 
<property> 
<name>javax.jdo.option.ConnectionDriverName</name> 
<value>org.apache.derby.jdbc.EmbeddedDriver</value> 
<description>Driver class name for a JDBC metastore</description> 
</property> 
<property> 
<name>javax.jdo.PersistenceManagerFactoryClass</name> 
<value>org.datanucleus.api.jdo.JDOPersistenceManagerFactory</value> 
<description>class implementing the jdo persistence</description> 
</property> 
</configuration> 
相关问题