2017-05-13 68 views
1

我的理解是Derby在当前目录中创建文件。但是那里没有。无法使用Brew安装中的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! 
+0

你可能要看看蜂巢配置文件。这应该告诉你它在哪里被初始化。 – HSchmale

+0

啊啊..一直在做蜂巢。你可以做出回答 – javadba

回答

1

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

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

schematool -initSchema -dbType derby 

,然后你可以运行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,所以如果你不小心再次初始化DB前跑hive,以删除它:

rm -Rf /usr/local/var/hive 
1

你可能要看看蜂巢配置文件。这应该告诉你它在哪里被初始化。

+0

so *** actually *** ..我重新从头开始安装配置单元 - 这意味着没有可用的配置文件(只有'.template')。上述错误*仍然会发生。还有什么想法? – javadba

+0

@javadba它可以连接到内存数据库吗?然后,一旦事务完成,它将转储到磁盘。 – HSchmale

+0

不是答案。什么文件?哪里?什么参数? –

相关问题