【问题标题】:Hadoop Metastore Will Not InitializeHadoop Metastore 不会初始化
【发布时间】:2016-08-06 06:32:33
【问题描述】:

序言:我是 hadoop / hive 的新手。已经安装了独立的 hadoop,现在正试图让 hive 工作。我不断收到有关初始化元存储的错误,似乎无法弄清楚如何解决。 (hadoop 2.7.2 和 hive 2.0)

HADOOP_HOME 和 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

蜂巢不工作。说我需要初始化我的元存储

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 ***

所以我将 hive-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 ***

所以我尝试使用德比 首先将 hive-site.xml 再次移开,因此默认为 derby

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

然后我尝试用 derby 再次初始化,但它似乎已经是 根据错误“错误:FUNCTION '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 ***

我已经在这两天了。任何帮助将不胜感激。

【问题讨论】:

    标签: hive derby metastore


    【解决方案1】:

    所以..

    这就是发生的事情。

    安装 hive 后,我做的第一件事是运行 hive,它试图创建/初始化 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)
    

    运行 hive,即使它失败了,在我运行 hive 的目录中创建了一个 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
    

    元存储已经存在,但不完整。

    答案是:

    1. 在你第一次运行 hive 之前,运行

      schematool -initSchema -dbType 德比

    2. 如果您已经运行 hive,然后尝试 initSchema 并且失败:

      mv metastore_db metastore_db.tmp

    3. 重新运行

      schematool -initSchema -dbType 德比

    4. 再次运行 hive

    **另外注意:如果你改变目录,上面创建的 metastore_db 将找不到!我确信这有一个我还不知道的充分理由,因为我今天确实是第一次尝试使用 hive。啊,这是有关此的信息:metastore_db created wherever I run Hive

    【讨论】:

    • 另外,如果您对 hive-site.xml 中的 javax.jdo.option.ConnectionURL 进行更改,metastore_db 将出现在您指定的目录中,而不是 $HIVE_HOME 中。
    • Rebecca,你对 postgresql 提出了问题,但在回答中你似乎对 Derby 感到满意。使用 postgresql 你可以使用 schematool 吗?
    • 这是解决这个问题的好方法。在我的 Mac 10.12.2 中,我通过 brew 安装 hive,遇到了很多问题。 mv metastore_db metastore_db.tmp;schematool -initSchema -dbType derby;hive;是解决问题的好方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-04
    相关资源
    最近更新 更多