So I had tried to do the hive initialization using Derby: but .. it seems there is a derby database already. schematool --verbose -initSchema -dbType derbyStarting metastore schema initialization to 2.1.0Initialization script hive-schema-2.1.0.derby.sqlConnecting to jdbc:derby:;databaseName=metastore_db;create=trueConnected 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_COMMITTED0: jdbc:derby:> !autocommit onAutocommit status: true0: 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=trueorg.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!Underlying cause: java.io.IOException : Schema script failed, errorcode 2org.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)那么..它在哪里?更新我已经重新安装了 hive 使用 brew reinstall hive出现同样的错误.另一个更新鉴于此错误的新方向,现在可以在另一个问题中回答:Another update Given the new direction of this error it now is answered by within another question:找到了一个非 os/x 的答案 - 但在其他方面类似 - 问题的答案可以在这里提供:An answer to a non-os/x - but similar otherwise - question was found that can serve here:https://stackoverflow.com/a/40017753/1056563I 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.sqlvi /usr/local/Cellar/hive/2.0.1/libexec/scripts/metastore/upgrade/derby/hive-schema-2.0.0.derby.sqlcomment the 'NUCLEUS_ASCII' function and 'NUCLEUS_MATCHES' functionrerun schematool -dbType derby -initSchema, then everything goes well!推荐答案Homebrew 安装 Hive(版本 2.3.1)未配置.默认设置是使用进程内 Derby 数据库(Hive 已包含所需的库).Homebrew installs Hive (version 2.3.1) unconfigured. The default settings are to use in-process Derby database (Hive already includes the required lib).您唯一需要做的(在 brew install hive 之后立即)就是初始化数据库:The only thing you have to do (immediatelly after brew install hive) is to initialize the database:schematool -initSchema -dbType derby然后你可以运行hive,它就会工作.但是,如果您尝试在初始化数据库之前运行 hive,Hive 实际上会半创建一个不完整的数据库并且无法工作:and then you can run hive, and it will work. However, if you tried to run hive before initializing the database, Hive will actually semi-create an incomplete database and will fail to work: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 现在也会失败:Since the database is semi-created, schematool will now fail as well:Error: FUNCTION 'NUCLEUS_ASCII' already exists. (state=X0Y68,code=30000)org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!要解决这个问题,您必须删除数据库:To fix that, you will have to delete the database:rm -Rf metastore_db并再次运行初始化命令.and run the initilization command again.注意到我从当前目录中删除了 metastore_db?这是另一个问题:Hive 被配置为在当前工作目录中创建和使用 Derby 数据库.这是因为它的javax.jdo.option.ConnectionURL"具有以下默认值:Noticed that I deleted the metastore_db from current directory? This is another problem: Hive is configured to create and use the Derby database in current working dir. This is because it has the following default value for ‘javax.jdo.option.ConnectionURL’:jdbc:derby:;databaseName=metastore_db;create=true要解决这个问题,创建文件 /usr/local/opt/hive/libexec/conf/hive-site.xml 为To fix that, create file /usr/local/opt/hive/libexec/conf/hive-site.xml as<?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,用:and recreate the database like before. Now the database is in /usr/local/var/hive, so in case you again accidentally ran hive before initializing the DB, delete it with:rm -Rf /usr/local/var/hive 这篇关于无法从 Brew 安装使用 Derby 初始化配置单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 07:22
查看更多