2016-04-14 140 views
4

序言:我是hadoop/hive的新手。已經安裝了獨立的hadoop,現在正試圖讓蜂巢工作。我不斷收到有關初始化Metastore的錯誤,似乎無法弄清楚如何解決。 (2.7.2 Hadoop的蜂房和2.0)Hadoop Metastore不會初始化

HADOOP_HOME AND HIVE_HOME設置

ubuntu15-laptop: ~ $>echo $HADOOP_HOME 
/usr/hadoop/hadoop-2.7.2 

ubuntu15-laptop: ~ $>echo $HIVE_HOME 
/usr/hive 

HDFS正在

ubuntu15-laptop: ~ $>hadoop fs -ls/
Found 2 items 
drwxrwxr-x - testuser supergroup   0 2016-04-13 21:37 /tmp 
drwxrwxr-x - testuser supergroup   0 2016-04-13 21:38 /user 

ubuntu15-laptop: ~ $>hadoop fs -ls /user 
Found 1 items 
drwxrwxr-x - testuser supergroup   0 2016-04-13 21:38 /user/hive 

ubuntu15-laptop: ~ $>hadoop fs -ls /user/hive 
Found 1 items 
drwxrwxr-x - testuser supergroup   0 2016-04-13 21:38 /user/hive/warehouse 

ubuntu15-laptop: ~ $>groups 
testuser adm cdrom sudo dip plugdev lpadmin sambashare 

蜂房不工作。說我需要初始化我metastore

ubuntu15-laptop: ~ $>hive 

Logging initialized using configuration in 
jar:file:/usr/hive/lib/hive-common-2.0.0.jar!/hive-log4j2.properties 
Exception in thread "main" java.lang.RuntimeException: Hive metastore database 
is not initialized. Please use schematool (e.g. ./schematool -initSchema 
-dbType ...) to create the schema. If needed, don't forget to include the 
option to auto-create the underlying database in your JDBC connection string 
(e.g. ?createDatabaseIfNotExist=true for mysql) 

,所以我嘗試初始化它的Postgres期運用 - 但schematool嘗試使用derby

ubuntu15-laptop: ~ $>schematool -initSchema -dbType postgres 
Metastore connection URL: jdbc:derby:;databaseName=metastore_db;create=true 
Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver 
Metastore connection User: APP 
Starting metastore schema initialization to 2.0.0 
Initialization script hive-schema-2.0.0.postgres.sql 
Error: Syntax error: Encountered "statement_timeout" at line 1, column 5. 
(state=42X01,code=30000) 
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization 
FAILED! Metastore state would be inconsistent !! 
*** schemaTool failed *** 

,所以我改變蜂房的site.xml使用Postgres的驅動程序等但因爲我不 安裝驅動程序,它失敗

ubuntu15-laptop: ~ $>cp /usr/hive/conf/hive-site.xml.templ /usr/hive/conf/hive-site.xml 
ubuntu15-laptop: ~ $>schematool -initSchema -dbType postgres 
Metastore connection URL: jdbc:postgresql://localhost:5432/hivedb 
Metastore Connection Driver : org.postgresql.Driver 
Metastore connection User: 123456 
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver 
*** schemaTool failed *** 

於是我嘗試用德比 首先移動蜂巢-site.xml中出的T他的方式再這樣默認是德比

ubuntu15-laptop: ~ $>mv /usr/hive/conf/hive-site.xml /usr/hive/conf/hive-site.xml.templ 

然後我嘗試用德比再次intializing但它似乎已經 每個錯誤初始化「錯誤:函數‘NUCLEUS_ASCII’已經存在」

ubuntu15-laptop: ~ $>schematool -initSchema -dbType derby 
Metastore connection URL: jdbc:derby:;databaseName=metastore_db;create=true 
Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver 
Metastore connection User: APP 
Starting metastore schema initialization to 2.0.0 
Initialization script hive-schema-2.0.0.derby.sql 
Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000) 
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization 
FAILED! Metastore state would be inconsistent !! 
*** schemaTool failed *** 

我我已經在這裏呆了兩天了。任何幫助將非常感激。

回答

9

所以......

這是發生了什麼事。

安裝配置單元后,我所做的第一件事是運行配置單元,嘗試創建/初始化metastore_db,但顯然沒有正確實施。對初次運行,我得到這個錯誤:

Exception in thread "main" java.lang.RuntimeException: Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, don't forget to include the option to auto-create the underlying database in your JDBC connection string (e.g. ?createDatabaseIfNotExist=true for mysql) 

運行蜂巢,即使失敗了,創造了從我跑蜂巢目錄中的metastore_db目錄:

ubuntu15-laptop: ~ $>ls -l |grep meta 
drwxrwxr-x 5 testuser testuser 4096 Apr 14 12:44 metastore_db 

所以,當我再嘗試運行

ubuntu15-laptop: ~ $>schematool -initSchema -dbType derby 

Metastore已經存在,但不是完整的形式。

Soooooo答案是:

  1. 在運行首次蜂巢,運行

    schematool -initSchema -dbType德比

  2. 如果您已經運行蜂巢,然後試着initSchema及其失敗:

    mv metastore_db metastore_db.tmp

  3. 重新運行

    schematool -initSchema -dbType德比

  4. 運行蜂巢再次

**另外值得注意的:如果你更改目錄,上面創建的metastore_db不會被發現!我確信有一個很好的理由,我還不知道,因爲我今天真的第一次嘗試使用蜂巢。 Ahhh這裏有關於此的信息:metastore_db created wherever I run Hive

+0

此外,如果您對hive-site.xml中的javax.jdo.option.ConnectionURL進行了更改,metastore_db將顯示在您指定的目錄中,而不是$ HIVE_HOME中。 – midtownguru

+0

Rebecca,你已經提出了postgresql的問題,但在回答中似乎你已經得到了德比的安慰。有了postgresql,你可以使用schematool嗎? –

+0

這是解決此問題的好方法。在我的Mac 10.12.2中,我通過brew安裝配置單元,遇到了很多問題。 mv metastore_db metastore_db.tmp; schematool -initSchema -dbType derby; hive;是一個很好的解決方法 – Windyground