2017-05-13 41 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

不是答案。什麼文件?哪裏?什麼參數? –