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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Doris: Unifying SQL Dialects for a Seamless Data Query Ecosystem
  • Evaluating Performance Gains in MySQL Lock Scheduling Algorithms
  • Codify Your Cloud and Kubernetes With Crossplane and IaC
  • Troubleshooting Connection Issues When Connecting to MySQL Server

Trending

  • Optimizing Integration Workflows With Spark Structured Streaming and Cloud Services
  • Power BI Embedded Analytics — Part 2: Power BI Embedded Overview
  • How the Go Runtime Preempts Goroutines for Efficient Concurrency
  • Streamlining Event Data in Event-Driven Ansible
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Configure MySQL Metastore for Hive?

How to Configure MySQL Metastore for Hive?

This is a step by step guide on How to Configure MySQL Metastore for Hive in place of Derby Metastore (Default).

By 
Saurabh Chhajed user avatar
Saurabh Chhajed
·
Jan. 08, 15 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
81.2K Views

Join the DZone community and get the full member experience.

Join For Free

hive by default comes with derby as its metastore storage, which is suited only for testing purposes and in most of the production scenarios it is recommended to use mysql as a metastore. this is a step by step guide on how to configure mysql metastore for hive in place of derby metastore (default).

assumptions : basic knowledge of unix is assumed and also it’s assumed that hadoop and hive configurations are in place.hive with default metastore derby is properly configured and tested out.

  1. install  mysql -
$ sudo apt-get install mysql-server

note :  you will be prompted to set a password for root.

2. install the mysql java connector –

$ sudo apt-get install libmysql-java

3. create soft link for connector in hive lib directory  or copy connector jar to lib folder  –

ln -s /usr/share/java/mysql-connector-java.jar $hive_home/lib/mysql-connector-java.jar

note :- hive_home points to installed hive  folder.

4. create the initial database schema using the hive-schema-0.14.0.mysql.sql file ( or the file corresponding to your installed version of hive) located in the $hive_home/scripts/metastore/upgrade/mysql directory.

$ mysql -u root -p

enter password:

mysql> create database metastore;

mysql> use metastore;

mysql> source $hive_home/scripts/metastore/upgrade/mysql/hive-schema-0.14.0.mysql.sql;

5. you also need a mysql user account for hive to use to access the metastore. it is very important to prevent this user account from creating or altering tables in the metastore database schema.

mysql> create user 'hiveuser'@'%' identified by 'hivepassword'; 

mysql> grant all on *.* to 'hiveuser'@localhost identified by 'hivepassword';

mysql>  flush privileges;

note : –  hiveuser is the connectionusername in hive-site.xml ( as explained next)

6. create hive-site.xml ( if not already present) in $hive_home/conf folder with the configuration below –

<configuration>
   <property>
      <name>javax.jdo.option.connectionurl</name>
      <value>jdbc:mysql://localhost/metastore?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>hiveuser</value>
      <description>user name for connecting to mysql server</description>
   </property>
   <property>
      <name>javax.jdo.option.connectionpassword</name>
      <value>hivepassword</value>
      <description>password for connecting to mysql server</description>
   </property>
</configuration>

7. we are all set now. start the hive console.

note :- if you are seeing any error related to driver “com.mysql.jdbc.driver” not found, please make sure you have copied the mysql-java connector jar properly to hive lib folder or created a soft link for the same.

if you have reached this far, without any errors , you can continue reading else , go back to step 1 and see what you missed – :)

now we’ll test through hive console and mysql console if our hive metastore using mysql is configured properly.

hive console:

let’s create a table in hive.

hive> create table saurzcode(id int, name string);

hive mysql metastore configuration

and see if we can see it’s metadata stored in mysql.

mysql console:

mysql -u root -p

enter password:                                                             
mysql> use metastore;
                           mysql> show tables ;

you can query the metastore schema in your mysql database. something like:

mysql> select * from tbls;

on your mysql database you will see the names of your hive tables.

mysql metastore configuration for hive

that’s it !! you are all set to use mysql as a metastore in hive.

happy learning !!

references :

[1]  cloudera mysql metastore guide.

MySQL

Published at DZone with permission of Saurabh Chhajed, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Doris: Unifying SQL Dialects for a Seamless Data Query Ecosystem
  • Evaluating Performance Gains in MySQL Lock Scheduling Algorithms
  • Codify Your Cloud and Kubernetes With Crossplane and IaC
  • Troubleshooting Connection Issues When Connecting to MySQL Server

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!