How to Install HIVE on Ubuntu (Download & Setup Guide)

⚡ Smart Summary

Apache Hive installs on Ubuntu as a thin data-warehouse layer above an already running Hadoop cluster, so the setup is mostly a matter of unpacking one archive and pointing three environment variables at the right directories.

  • 🧱 Hadoop first: Every Hadoop daemon must already be running, because Hive stores its table data on HDFS and submits its jobs to the cluster.
  • ⬇️ Download source: Binary releases come from the Apache mirror page, and the 3.x line reached end of life in October 2024.
  • 📁 Two config files: HIVE_HOME belongs in bashrc, and HADOOP_HOME belongs in hive-config.sh inside the Hive bin directory.
  • 💾 HDFS folders: The warehouse and tmp directories must exist on HDFS with group write permission before the first table is created.
  • 🧩 Schema step: The schematool utility creates the metastore tables, and Hive 3.x and later refuse to start against an uninitialised schema.
  • 🔨 Verify quickly: A create statement followed by describe proves that the shell, the metastore and HDFS are all wired together correctly.

How to install Hive on Ubuntu

Prior to Apache Hive installation we require a dedicated Hadoop installation, up and running with all the Hadoop daemons.

For installation of Hadoop check this link.

Once all the Hadoop daemons are working fine, just start installation of the Hive part. The walkthrough below moves through four stages:

Apache Hive installation process

  1. Prerequisites and version compatibility
  2. Installation of Hive
  3. Metastore schema initialisation
  4. Hive shell commands

Prerequisites for Installing Apache Hive on Ubuntu

Hive is not a standalone database. It is a query layer that translates HiveQL into jobs that run on an existing cluster, so almost every failed installation traces back to a missing prerequisite rather than to Hive itself. Confirm the following before downloading anything:

  • A supported JDK. Hive 4.1.x runs on JDK 17, while Hive 4.2.x raises the minimum to JDK 21. Check the version with java -version and make sure JAVA_HOME is exported.
  • A running Hadoop cluster. Both the NameNode and the DataNode must be live. Run jps and confirm that NameNode, DataNode, ResourceManager and NodeManager all appear in the list.
  • Write access to HDFS. The account that starts Hive needs permission to create directories under HDFS.
  • Matching versions. Hive 4.2.0 is built against Hadoop 3.4.1 and Tez 0.10.5. The Hive 3.x line reached end of life in October 2024, so a fresh install should target the 4.x line.
  • Free resources. A single-node learning setup is comfortable with roughly 4 GB of RAM and 20 GB of free disk.

With those boxes ticked, the download and unpack sequence below runs without surprises.

How to Install Hive on Ubuntu

Below is a step by step process on how to install Hive in Ubuntu:

Step 1) Download and Install Hive on Ubuntu

For downloading the Hive stable setup, refer to the Apache URL as mentioned below.

https://www.apache.org/dyn/closer.cgi/hive/ — go to the URL and select the Apache mirror download link. The Apache Hive downloads page lists which release pairs with which Hadoop version.

The mirror page opens with the list of available Hive release directories, as shown below.

Apache mirror page listing the available Apache Hive release directories

Select the latest version of the Hive setup. (In my current case it is hive – 3.1.2.) The release folder lists the binary and source archives side by side.

Hive release folder showing the binary and source distribution archives

Click on the bin file and the download will start.

Browser download prompt for the apache-hive bin tar.gz distribution file

Step 2) Extract the tar file

Go to the downloaded tar file location, then extract the tar file by using the following command to install Hive on Ubuntu on your system.

tar -xvf  apache-hive-3.1.2-bin.tar.gz

The terminal echoes each file as it is unpacked into the new Hive directory.

Terminal output while the Hive tar archive is extracted on Ubuntu

Step 3) Place different configuration properties in Apache Hive

In this step, we are going to do two things:

  1. Placing the Hive home path in the bashrc file
  2. Placing the Hadoop home path location in hive-config.sh

1) Mention the Hive path in ~/.bashrc

Open the file for editing with the command shown below.

Command that opens the bashrc file for editing the Hive environment variables

  • Open the bashrc file as shown in the above screenshot
  • Mention the Hive home path, i.e., the HIVE_HOME path, in the bashrc file and export it as shown below

HIVE_HOME and PATH export lines added at the end of the bashrc file

Code to be placed in bashrc:

export HIVE_HOME="/home/guru99hive/apache-hive-1.2.0-bin"
export PATH=$PATH:$HIVE_HOME/bin

Reload the file with source ~/.bashrc so the new path takes effect in the current terminal session.

2) Exporting the Hadoop path in hive-config.sh

To communicate with the Hadoop ecosystem we define the Hadoop home path in the Hive config file. Open hive-config.sh as shown below.

Command used to open hive-config.sh from the Hive bin directory

Mention the HADOOP_HOME path in the hive-config.sh file as shown below.

HADOOP_HOME path declared inside the hive-config.sh file

Step 4) Create Hive directories in Hadoop

To communicate with Hadoop, we need to create directories in Hadoop as shown below. Hive writes managed table data into the warehouse directory and staging output into the tmp directory.

HDFS commands that create the Hive tmp and warehouse directories

Giving root permissions to create Hive folders in Hadoop. If it does not throw any error message, then it means that Hadoop has successfully given permissions to the Hive folders.

Terminal showing group write permissions granted to the Hive folders on HDFS

Step 5) Enter into the Hive shell

Get into the Hive shell by entering the ‘. /hive’ command as shown below.

Hive shell prompt opened from the Hive bin directory on Ubuntu

How to Initialize the Hive Metastore Schema

Hive keeps every table name, column name and data type in a relational store called the metastore. On a fresh install that store is empty, and from Hive 3.x onward the shell refuses to start until the schema tables exist. The schematool utility that ships in the Hive bin directory creates them.

For a single-user learning setup, the bundled Derby database is enough:

$HIVE_HOME/bin/schematool -dbType derby -initSchema

The command prints the schema version it created and ends with schemaTool completed. Derby writes its files into whichever directory the command was run from, so always launch Hive from that same directory afterwards.

Derby accepts only one active session at a time, which makes it unsuitable for a shared cluster. Point Hive at MySQL instead by adding the connection properties to hive-site.xml and re-running the tool with a different database type:

$HIVE_HOME/bin/schematool -dbType mysql -initSchema

The full property list and driver placement are covered in the guide on how to configure the Hive metastore with MySQL. Two more flags are worth remembering:

  • -info reports the schema version currently recorded in the metastore without changing anything.
  • -upgradeSchema migrates an existing metastore to the schema version of the newly installed Hive release.

With the schema in place, the shell is ready to accept its first HiveQL statement.

Hive shell commands

Here we are going to create a sample table using the Hive shell command “create” with column names.

Sample code for creating a database in Hive. The screenshot below shows the create statement and the describe output one after the other.

Hive shell output for the create table and describe product commands

From the above screenshot we can observe the following:

1) Creation of a sample table with column names in Hive

  • Here the table name is “product” with three column names product, pname, and price
  • The three column names are denoted by their respective data type
  • All fields are terminated by a comma ‘, ‘

2) Displaying Hive table information

  • Using the “describe” command we are able to see the table information present in Hive
  • Here it is displaying column names with their respective data types present in the table schema
  • At the end, it will display the time taken to perform this command and the number of rows it fetched

Sample code for creating a database in Hive (for self check)

1) Create table product(product int, pname string, price float)

Row format delimited
Fields terminated by ',';

2) describe product;

Once the table responds to describe, the shell, the metastore and HDFS are all wired together. From here the same session accepts the wider create, alter and drop table statements and the order by, group by and cluster by queries.

Common Hive Installation Errors on Ubuntu and How to Fix Them

Most first-run failures come from the environment around Hive rather than from Hive itself. The table below maps the messages that appear most often to their cause and the command that clears them.

Message on screen Likely cause Fix
hive: command not found HIVE_HOME/bin is not on the PATH Re-check the export lines in bashrc, then run source ~/.bashrc
Version information not found in metastore The metastore schema was never initialised Run schematool with -initSchema for the chosen database type
Call to localhost:9000 failed on connection exception HDFS is not running Start the Hadoop daemons and confirm NameNode and DataNode appear in jps
Name node is in safe mode The NameNode is still in its start-up safe mode Leave safe mode with hdfs dfsadmin -safemode leave
Permission denied: access=WRITE on /user/hive/warehouse The warehouse directory lacks group write permission Re-apply hdfs dfs -chmod g+w on the warehouse and tmp directories
NoSuchMethodError on Preconditions.checkArgument Hive and Hadoop ship different Guava jar versions Delete the older Guava jar in the Hive lib directory and copy the Hadoop one in its place

A quick way to separate a Hive problem from a Hadoop problem is to run jps first. If the daemons are missing, the cluster is the fault; if they are present and the shell still fails, the fault is in the Hive configuration or the metastore schema. Once the shell is stable, the HiveQL operators and built-in functions reference is the natural next stop.

FAQs

A managed table lets Hive own both the metadata and the files, so dropping it deletes the data in the warehouse directory. An external table records only the metadata, and dropping it leaves the underlying files untouched.

Hive runs anywhere a JVM and Hadoop run, but the shell scripts assume a Unix layout. On Windows most teams use WSL2 or a Docker image; on macOS the same tar archive works once JAVA_HOME and HADOOP_HOME are exported.

Beeline is a JDBC client that connects to HiveServer2 rather than loading Hive inside the shell process. It supports concurrent users and authentication, and the older Hive CLI is deprecated, so new installs should standardise on Beeline.

Modern engines feed historical query statistics into learned cost models that predict scan sizes, partition pruning and join order. Cloud vendors expose the same signals as automatic recommendations for file compaction, partition layout and container sizing.

Copilot drafts bashrc exports, hive-site.xml blocks and schematool invocations quickly, and agentic runners can execute them in a sandbox. Treat the output as a first draft: version numbers, ports and directory paths still need verification against your own cluster.

Roughly 4 GB of RAM and 20 GB of free disk is comfortable for learning, since Hive itself is a thin client. Production nodes size around the Hadoop cluster and the metastore database rather than around Hive.

Unpack the new release beside the old one, repoint HIVE_HOME, then run schematool with -upgradeSchema so the metastore matches. Removal is simply deleting the Hive directory and stripping the export lines from bashrc; the HDFS warehouse data survives.

No. MapReduce is deprecated as a Hive execution engine and Hive 4.x runs on Apache Tez by default. The MapReduce model is still worth understanding because Tez follows the same directed job model.

Summarize this post with: