• Post author:
  • Post category:Apache Hive
  • Post last modified:January 1, 2023
  • Reading time:4 mins read
You are currently viewing Hive – HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

I’ve installed Hive on Hadoop cluster and when running Hive commands from the hive shell, I am getting an error message HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient.

Hive HiveException Unable to instantiate

Solution: You are getting this HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient because you have not initialized Metastore database for Hive.

Post installation and setting up Hive, you need to initialize the Metastore database with the database type you choose

Note: By default Hive uses derby database.

Follow the below steps to resolve this error.

  • Exit from hive shell.
  • Rename the default metastore_db to metastore_db_bkp file. This metastore_db can be located in a directory where you are running a hive shell or at $HIVE_HOME directory.
  • After rename, run the schematool -initSchema -dbType derby command, which initializes the derby as Metastore database for Hive.

prabha@namenode:~/hive$ schematool -initSchema -dbType derby

This outputs below.


prabha@namenode:~/hive$ schematool -initSchema -dbType derby
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/prabha/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4                                                                        j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/prabha/hadoop/share/hadoop/common/lib/slf4j-log4j12-1                                                                        .7.25.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=metastore_db;create=true
Metastore Connection Driver :    org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User:       APP
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.derby.sql
Initialization script completed
schemaTool completed

Now start the hive shell and run the command that failed before, now you should see it getting successful. In my case I am running show databases;

Hope this solves your issue !!

Happy Learning !!

Prabha

Prabha is an accomplished data engineer with a wealth of experience in architecting, developing, and optimizing data pipelines and infrastructure. With a strong foundation in software engineering and a deep understanding of data systems, Prabha excels in building scalable solutions that handle diverse and large datasets efficiently. At SparkbyExamples.com Prabha writes her experience in Spark, PySpark, Python and Pandas.

Leave a Reply