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.
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
- Prerequisites and version compatibility
- Installation of Hive
- Metastore schema initialisation
- 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.
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.
Click on the bin file and the download will start.
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.
Step 3) Place different configuration properties in Apache Hive
In this step, we are going to do two things:
- Placing the Hive home path in the bashrc file
- 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.
- 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
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.
Mention the HADOOP_HOME path in the hive-config.sh file as shown below.
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.
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.
Step 5) Enter into the Hive shell
Get into the Hive shell by entering the ‘. /hive’ command as shown below.
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.
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.








