Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install Apache Hive on Ubuntu

Set up Hive on top of an existing Hadoop installation, initialize the metastore and run your first table.

VPS and Cloud Servers3 min read22 screenshots
Apache Hive

What Hive is

Apache Hive is a data warehouse tool built on Hadoop. It lets you query and manage large data sets in HDFS with a SQL-like language called HiveQL.

Requirements

  • Java 8 or newer with JAVA_HOME set.
  • A working Hadoop installation with the environment variables set (see our Hadoop guide). Hive 4.x needs Java 8 and Hadoop 3.x.
  • Ubuntu. This guide used Ubuntu 24.04, but other versions work.
  • At least 4 GB of RAM (8 GB is better for real work).
  • 20 GB of free disk space.

Step 1: Download and extract Hive

Check Hadoop first:

hadoop version
The Hadoop version

Download Hive from the Apache download page.

The Apache Hive download page

Or with wget (check the current version number on the Apache site):

wget https://downloads.apache.org/hive/hive-4.0.1/apache-hive-4.0.1-bin.tar.gz
Downloading Hive with wget

Extract it:

tar xzf apache-hive-4.0.1-bin.tar.gz
Extracting the archive

Step 2: Set the environment variables

Open ~/.bashrc:

nano ~/.bashrc

Add these lines at the end (change the path to where you extracted Hive):

export HIVE_HOME="/home/hdoop/apache-hive-4.0.1-bin"
export PATH=$PATH:$HIVE_HOME/bin
The Hive variables in .bashrc

Apply the changes:

source ~/.bashrc
Applying the changes

Check them:

echo $HIVE_HOME
HIVE_HOME
echo $PATH | grep hive
Hive in the PATH

Step 3: Configure Hadoop for Hive

Edit core-site.xml:

sudo nano $HADOOP_HOME/etc/hadoop/core-site.xml

Add the proxy user settings inside <configuration> (replace db_user and server with the users that run Hive):

<property>
    <name>hadoop.proxyuser.db_user.groups</name>
    <value>*</value>
</property>
<property>
    <name>hadoop.proxyuser.db_user.hosts</name>
    <value>*</value>
</property>
<property>
    <name>hadoop.proxyuser.server.hosts</name>
    <value>*</value>
</property>
<property>
    <name>hadoop.proxyuser.server.groups</name>
    <value>*</value>
</property>
Editing core-site.xml

These settings let the Hive user act on behalf of other users. The * values are open and fine for a test. Narrow them in production.

Step 4: Create the HDFS folders

hadoop fs -mkdir /tmp
Creating /tmp in HDFS
hadoop fs -chmod g+w /tmp
Setting the permissions
hadoop fs -ls /
Checking the folders

Also create the warehouse folder:

hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -chmod g+w /user/hive/warehouse

Step 5: Configure Hive (optional but good)

cd apache-hive-4.0.1-bin/conf
The Hive configuration folder
ls -l
The configuration files

Copy the template:

cp hive-default.xml.template hive-site.xml
Copying the template

Edit it:

nano hive-site.xml

Set, for example, the warehouse folder:

<property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/user/hive/warehouse</value>
</property>
Editing hive-site.xml

Custom settings help you tune performance for your hardware, fit your environment and meet production rules.

Step 6: Initialize the metastore

cd apache-hive-4.0.1-bin
Opening the Hive folder
bin/schematool -dbType derby -initSchema
Initializing the schema

The metastore stores the databases, table definitions, column data types, partitions and security information. Derby is fine for testing. Use MySQL or PostgreSQL for production.

Step 7: Start Hive and test it

bin/hiveserver2
Starting HiveServer2
The Hive session

In another terminal, connect with bin/beeline -u jdbc:hive2://localhost:10000 and create a table:

CREATE TABLE IF NOT EXISTS student_details(
name STRING,
marks FLOAT)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ',';
Creating a table

Quick recap

  • Install Hadoop first, then download and extract Hive.
  • Set HIVE_HOME, create the HDFS folders and run schematool -initSchema.
  • Start HiveServer2 and create a table to test.