DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Join us tomorrow at 1 PM EST: "3-Step Approach to Comprehensive Runtime Application Security"
Save your seat
  1. DZone
  2. Data Engineering
  3. Databases
  4. Hive Metastore Configuration After Fresh Installation

Hive Metastore Configuration After Fresh Installation

This article takes a quick look at a tutorial that explains how to configure Hive Metastore.

Ranjan Choudhury user avatar by
Ranjan Choudhury
·
Nov. 08, 18 · Tutorial
Like (2)
Save
Tweet
Share
8.79K Views

Join the DZone community and get the full member experience.

Join For Free

For the beginners playing around in Hive, a stoppage arises with the proper configuration. After placing Hive libraries in designated folders and updating necessary environment variables, many times the first eager execution of hive fails with the exception “HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient”. That’s when Hive Metastore needs to be configured, which is pretty simple and straightforward.

There are two ways to configure Hive Metastore. We can use ‘schematool’ or directly source the hive-schema-3.1.0.mysql.sql script provided by Hive into the Metastore database.

Here are the steps for configuring Hive Metastore. We are configuring it for mysql type metastore on ubuntu 16.04.

  1. Install MySQL using apt-get as sudo apt-get install mysql-server.
  2. Download and copy the mysql jdbc connector jar ‘mysql-connector-java-8.0.13.jar’ into Hive lib directory.
  3. Create hive-site.xml file if not exist in Hive conf directory and add the following properties to use the above-installed MySQL database. If the properties are not added/updated, it will use the default Derby database.
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/metastore_db?createDatabaseIfNotExist=true</value>
<description>metadata is stored in a MySQL server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>MySQL JDBC driver class</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>user name for connecting to mysql server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
<description>password for connecting to mysql server</description>
</property>
</configuration>

4. Up to this step, our Metastore configurations are complete and we need to initialize those configurations.

The initialization can be done simply by using schematool provided by Hive. To initialize it for MySQL database use the command ‘schematool -initSchema -dbType mysql’ and we are all set to use Hive.

Another way to initialize metastore_db is by sourcing the hive-schema-3.1.0.mysql.sql script. Below are the steps to follow.

  1. Login to MySQL using command ‘mysql -u root -p’
  2. Create the Metastore database (metastore_db in our case) using command ‘create database metastore_db’
  3. Use database metastore_db
  4. Source hive-schema-3.1.0.mysql.sql into the MySQL Metastore database using command ‘source $HIVE_HOME/scripts/metastore/upgrade/mysql/hive-schema-3.1.0.mysql.sql’.

That’s it. We are all set to play around with Hive.

Database Fresh (IDE)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Is a Kubernetes CI/CD Pipeline?
  • Deploying Java Serverless Functions as AWS Lambda
  • How To Check Docker Images for Vulnerabilities
  • Bye Bye, Regular Dev [Comic]

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: