How to fix the Hive metastore database is not initialized issue? - Big Data In Real World

How to fix the Hive metastore database is not initialized issue?

How to update or drop a Hive Partition?
December 16, 2020
What is the difference between repartition and coalesce in Spark?
December 21, 2020
How to update or drop a Hive Partition?
December 16, 2020
What is the difference between repartition and coalesce in Spark?
December 21, 2020

So you were installing Hive and ran into the below issue when Hive was trying to set up the metastore database. 

Exception in thread "main" java.lang.RuntimeException: Hive metastore database is not initialized. 
Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. 
If needed, don't forget to include the option to auto-create the underlying database in your JDBC connection string 
(e.g. ?createDatabaseIfNotExist=true for mysql)

Solution

Metastore database in Hive is used to store definitions of your Hive databases and tables. Sometimes the metastore initialization fails because of a configuration issue. The most common issue that we have seen is that the JDBC URL to the database wasn’t correct or the user provided doesn’t have the correct information. Make sure to check the logs and if there are any specific issues related to URL or permissions issues fix them first.

Since you are installing Hive the metastore won’t have any information that you need to worry about. Follow the below steps if you are doing a fresh installation. Don’t try this on an existing metastore which already has metadata about your databases and tables.

  1. The error suggest you to run ./schematool -initSchema  but it will not work when a metastore directory is present already.
  2. If the metastore directory is present in your Hive installation directory. Rename the directory.
  3. mv metastore_db metastore_db.bkup
  4. Run the below command after step 2. Make sure to update the database
  5. schematool -initSchema -dbType derby 
  6. Check the logs and the issue should be resolved now.

 

Big Data In Real World
Big Data In Real World
We are a group of Big Data engineers who are passionate about Big Data and related Big Data technologies. We have designed, developed, deployed and maintained Big Data applications ranging from batch to real time streaming big data platforms. We have seen a wide range of real world big data problems, implemented some innovative and complex (or simple, depending on how you look at it) solutions.

Comments are closed.

How to fix the Hive metastore database is not initialized issue?
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.

Hadoop In Real World is now Big Data In Real World!

X