【问题标题】:Unable to initialize hive with Derby from Brew install无法从 Brew 安装中使用 Derby 初始化 hive
【发布时间】:2017-10-12 09:00:51
【问题描述】:

据我了解,Derby 在当前目录中创建文件。但是那里没有。

所以我曾尝试使用Derby 进行hive 初始化:但是.. 似乎 derby 数据库已经存在。

 schematool --verbose -initSchema -dbType derby


Starting metastore schema initialization to 2.1.0
Initialization script hive-schema-2.1.0.derby.sql
Connecting to jdbc:derby:;databaseName=metastore_db;create=true
Connected to: Apache Derby (version 10.10.2.0 - (1582446))
Driver: Apache Derby Embedded JDBC Driver (version 10.10.2.0 - (1582446))
Transaction isolation: TRANSACTION_READ_COMMITTED
0: jdbc:derby:> !autocommit on
Autocommit status: true
0: jdbc:derby:> CREATE FUNCTION "APP"."NUCLEUS_ASCII" (C CHAR(1)) RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA READS SQL DATA CALLED ON NULL INPUT EXTERNAL NAME 'org.datanucleus.store.rdbms.adapter.DerbySQLFunction.ascii'
Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000)

Closing: 0: jdbc:derby:;databaseName=metastore_db;create=true
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
Underlying cause: java.io.IOException : Schema script failed, errorcode 2
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
    at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:291)
    at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:264)
    at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:505)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.io.IOException: Schema script failed, errorcode 2
    at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java:390)
    at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java:347)
    at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:287)

那么……它在哪里?

更新我已经从头开始重新安装配置单元使用

  brew reinstall hive

同样的错误发生了。

另一个更新鉴于此错误的新方向,现在在另一个问题中回答:

找到了一个非 os/x 的答案——但其他方面类似——问题可以在这里提供:

https://stackoverflow.com/a/40017753/1056563

I installed hive with HomeBrew(MacOS) at /usr/local/Cellar/hive and afer running schematool -dbType derby -initSchema I get the following error message:

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

However, I can't find either metastore_db or metastore_db.tmp folder under install path, so I tried:

find /usr/ -name hive-schema-2.0.0.derby.sql
vi /usr/local/Cellar/hive/2.0.1/libexec/scripts/metastore/upgrade/derby/hive-schema-2.0.0.derby.sql
comment the 'NUCLEUS_ASCII' function and 'NUCLEUS_MATCHES' function
rerun schematool -dbType derby -initSchema, then everything goes well!

【问题讨论】:

  • 您可能需要查看 hive 配置文件。这应该告诉你它在哪里被初始化。
  • 啊是啊.. 做蜂巢有一段时间了。你可以做一个答案

标签: hive derby


【解决方案1】:

Homebrew 安装未配置的 Hive(版本 2.3.1)。默认设置是使用进程内 Derby 数据库(Hive 已经包含所需的库)。

您唯一需要做的(立即brew install hive之后)就是初始化数据库:

schematool -initSchema -dbType derby

然后你可以运行hive,它就会工作。但是,如果您在初始化数据库之前尝试运行hive,Hive 实际上会半创建一个不完整的数据库并且将无法工作:

show tables;
FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

由于数据库是半创建的,schematool 现在也会失败:

Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!

要解决这个问题,您必须删除数据库:

rm -Rf metastore_db

然后再次运行初始化命令。

注意到我从当前目录中删除了 metastore_db?这是另一个问题:Hive 被配置为在当前工作目录中创建和使用 Derby 数据库。这是因为它具有以下“javax.jdo.option.ConnectionURL”的默认值:

jdbc:derby:;databaseName=metastore_db;create=true

要解决这个问题,请创建文件 /usr/local/opt/hive/libexec/conf/hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:derby:/usr/local/var/hive/metastore_db;create=true</value>
  </property>
</configuration>

然后像以前一样重新创建数据库。现在数据库在/usr/local/var/hive,所以如果你在初始化数据库之前再次意外运行hive,删除它:

rm -Rf /usr/local/var/hive

【讨论】:

  • 优秀的解决方案 - 这应该被赞成并添加到 hive 的 brew install 文档中
【解决方案2】:

您可能需要查看 hive 配置文件。这应该告诉你它在哪里被初始化。

【讨论】:

  • so actually .. 我从头开始重新安装 hive - 这意味着甚至没有可用的配置文件(只有 .template)。并且出现上述错误仍然。还有什么想法吗?
  • @javadba 它可以连接到内存数据库吗?然后,一旦事务完成,它就会转储到磁盘。
  • 不是答案。什么文件?在哪里?什么参数?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-01
  • 2015-02-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多