2014-03-28 126 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> 
相關問題