首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hadoop Metastore不会初始化

Hadoop Metastore不会初始化
EN

Stack Overflow用户
提问于 2016-04-14 23:28:27
回答 1查看 10.6K关注 0票数 5

前言:我是hadoop / hive的新手。我已经安装了独立的hadoop,现在我正在尝试让hive工作。我一直收到关于初始化元存储的错误,并且似乎找不到解决方法。(hadoop 2.7.2和hive 2.0)

设置了HADOOP_HOME和HIVE_HOME

代码语言:javascript
复制
ubuntu15-laptop: ~ $>echo $HADOOP_HOME
/usr/hadoop/hadoop-2.7.2

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

hdfs工作正常

代码语言:javascript
复制
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

蜂窝不工作。说我需要初始化我的转移存储

代码语言:javascript
复制
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

代码语言:javascript
复制
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驱动程序等,但是因为我没有安装驱动程序,所以它失败了

代码语言:javascript
复制
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 ***

因此,我尝试使用derby,首先将hive-site.xml移出障碍,因此缺省为derby

代码语言:javascript
复制
ubuntu15-laptop: ~ $>mv /usr/hive/conf/hive-site.xml /usr/hive/conf/hive-site.xml.templ

然后我再次尝试使用derby进行初始化,但似乎已经根据错误" error : FUNCTION 'NUCLEUS_ASCII‘already“进行了初始化。

代码语言:javascript
复制
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 ***

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-15 00:54:27

所以..。

事情是这样的。

安装hive后,我做的第一件事就是运行hive,它试图创建/初始化metastore_db,但显然没有正确完成。在最初的运行中,我得到了这个错误:

代码语言:javascript
复制
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目录:

代码语言:javascript
复制
ubuntu15-laptop: ~ $>ls -l |grep meta
drwxrwxr-x 5 testuser testuser 4096 Apr 14 12:44 metastore_db

所以当我尝试跑步的时候

代码语言:javascript
复制
ubuntu15-laptop: ~ $>schematool -initSchema -dbType derby

转移体已经存在,但不是完整的。

所以答案是:

  1. 在第一次运行配置单元之前,请运行

schematool -initSchema -dbType derby

  • 如果您已经运行了hive,然后尝试initSchema,但它失败了:

mv metastore_db.tmp

  • Re metastore_db运行

schematool -initSchema -dbType derby

  • Run hive Run

**还要注意:如果您更改目录,将找不到上面创建的metastore_db!我确信这有一个我还不知道的很好的原因,因为我今天真的是第一次尝试使用hive。啊,这是关于这个的信息:metastore_db created wherever I run Hive

票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36627597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档