Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Getting java.io.IOException: Schema script failed, errorcode 2 while starting Hive metastore

Highlighted

Getting java.io.IOException: Schema script failed, errorcode 2 while starting Hive metastore

New Contributor

My Hive and mysqld services are already running and while starting the Hive metastore I'm getting below error.

HDP version: 2.5.5

Ambari version: 2.5.0.3

Closing: 0: jdbc:mysql://pnkj-1.openstacklocal/hive?createDatabaseIfNotExist=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:304)
	at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:277)
	at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:526)
	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:233)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
Caused by: java.io.IOException: Schema script failed, errorcode 2
	at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java:410)
	at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java:367)
	at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:300)
	... 8 more
*** schemaTool failed ***
2 REPLIES 2

Re: Getting java.io.IOException: Schema script failed, errorcode 2 while starting Hive metastore

Master Collaborator

Is this a fresh instance? Can you run the following command on the Hive node and post the output?

/usr/hdp/current/hive-server2-hive2/bin/schematool -dbType <dbtype> -initSchema -verbose

This will definitely throw more light on what is the issue here.

Re: Getting java.io.IOException: Schema script failed, errorcode 2 while starting Hive metastore

New Contributor

I am also having same issue,

the o/p of /usr/hdp/current/hive-server2-hive2/bin/schematool -dbType mysql -initSchema -verbose is as follows,

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/hdp/2.5.5.0-157/hive2/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/hdp/2.5.5.0-157/hadoop/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:derby:;databaseName=/var/lib/hive/metastore/metastore_db;create=true Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver Metastore connection User: APP Starting metastore schema initialization to 2.1.0 Initialization script hive-schema-2.1.0.mysql.sql Connecting to jdbc:derby:;databaseName=/var/lib/hive/metastore/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:> /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */ Error: Syntax error: Encountered "<EOF>" at line 1, column 64. (state=42X01,code Closing: 0: jdbc:derby:;databaseName=/var/lib/hive/metastore/metastore_db;create org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED Underlying cause: java.io.IOException : Schema script failed, errorcode 2 org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:304 at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:277 at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:526) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:233) at org.apache.hadoop.util.RunJar.main(RunJar.java:148) Caused by: java.io.IOException: Schema script failed, errorcode 2 at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:300 ... 8 more *** schemaTool failed ***

What does this means??

Don't have an account?
Coming from Hortonworks? Activate your account here