无法使用Brew安装中的Derby初始化配置单元

jav*_*dba 1 hive derby

据我所知,Derby在当前目录中创建文件.但那里没有.

所以,我曾试图做hive使用初始化Derby:但..似乎还有就是 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)
Run Code Online (Sandbox Code Playgroud)

那么..它在哪里?

更新 我已经重新安装了从无到有蜂巢 使用

  brew reinstall hive
Run Code Online (Sandbox Code Playgroud)

并发生同样的错误.

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

找到了一个非os/x的答案 - 但在其他情况下相似 - 这个问题可以在这里发挥作用:

/sf/answers/2801242741/

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!
Run Code Online (Sandbox Code Playgroud)

Dan*_*tov 6

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

你需要做的(唯一immediatellybrew install hive)是初始化数据库:

schematool -initSchema -dbType derby
Run Code Online (Sandbox Code Playgroud)

然后你可以运行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
Run Code Online (Sandbox Code Playgroud)

由于数据库是半创建的,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 !!
Run Code Online (Sandbox Code Playgroud)

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

rm -Rf metastore_db
Run Code Online (Sandbox Code Playgroud)

并再次运行initilization命令.

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

jdbc:derby:;databaseName=metastore_db;create=true
Run Code Online (Sandbox Code Playgroud)

要解决此问题,请将文件创建/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>
Run Code Online (Sandbox Code Playgroud)

并像以前一样重新创建数据库.现在数据库已经存在/usr/local/var/hive,因此如果您hive在初始化数据库之前再次意外运行,请使用以下命令将其删除:

rm -Rf /usr/local/var/hive
Run Code Online (Sandbox Code Playgroud)

  • 优秀的解决方案 - 这应该被赞成并添加到 hive 的 brew 安装文档中 (2认同)