Sure! Here's a step-by-step guide to installing Apache Hive on Red Hat Enterprise Linux (RHEL) or CentOS. This assumes you already have Java and Hadoop installed, as Hive depends on both.
✅ Prerequisites
Before installing Hive:
- Java 8 or later must be installed.
- Hadoop should be installed and running.
- Ensure that
JAVA_HOME is set in your environment.
📦 Step-by-Step Installation of Apache Hive on RHEL
🔹 Step 1: Download Apache Hive
Go to the Apache Hive downloads page and copy the link for the latest stable release.
cd /opt
sudo wget https://downloads.apache.org/hive/hive-<version>/apache-hive-<version>-bin.tar.gz
Example:
sudo wget https://downloads.apache.org/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz
🔹 Step 2: Extract the Tarball
sudo tar -xzvf apache-hive-<version>-bin.tar.gz
sudo mv apache-hive-<version>-bin hive
This will create a directory /opt/hive.
🔹 Step 3: Set Environment Variables
Edit your .bashrc or /etc/profile.d/hive.sh file to add Hive to your PATH.
sudo nano /etc/profile.d/hive.sh
Add the following lines:
export HIVE_HOME=/opt/hive
export PATH=$PATH:$HIVE_HOME/bin
export CLASSPATH=$CLASSPATH:$HIVE_HOME/lib/*:.
Then apply the changes:
source /etc/profile.d/hive.sh
🔹 Step 4: Configure Hive
Create a hive-site.xml file:
cd $HIVE_HOME/conf
cp hive-default.xml.template hive-site.xml
nano hive-site.xml
Update the following properties in hive-site.xml:
Example Changes:
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=/opt/hive/metastore_db;create=true</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/user/hive/tmp</value>
</property>
Note: These directories need to exist in your HDFS and be accessible by Hive.
🔹 Step 5: Install Derby (For Embedded Metastore)
Hive uses a metastore to store metadata. For simple installations, Apache Derby is used in embedded mode.
Install Java DB (Derby) if not already available:
sudo yum install java-1.8.0-openjdk-devel
Ensure Derby JARs are in $HIVE_HOME/lib. If not, download them from the Apache Derby website.
🔹 Step 6: Initialize the Metastore
Run the schema tool to initialize the Derby metastore:
schematool -dbType derby -initSchema
You should see output indicating success.
🔹 Step 7: Create Required HDFS Directories
Make sure the warehouse and scratch directories exist in HDFS:
hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -mkdir -p /user/hive/tmp
hadoop fs -chmod g+w /user/hive/warehouse
hadoop fs -chmod g+w /user/hive/tmp
🔹 Step 8: Start Hive
Now you can start Hive:
hive
You'll enter the Hive shell where you can run HiveQL commands.
🧪 Optional: Use MySQL/PostgreSQL as Metastore (Production Setup)
In production environments, it’s recommended to use a more robust database like MySQL, PostgreSQL, or Oracle instead of Derby.
Let me know if you want instructions for setting up Hive with MySQL.
✅ Summary
You've now installed Apache Hive on Red Hat. The basic setup includes:
- Java and Hadoop installed
- Hive binaries downloaded and configured
- Metastore initialized using Derby
- HDFS directories created
If you're planning to integrate Hive with Hadoop ecosystem tools like Tez, Spark, or Ranger, let me know — I can provide additional configuration steps.
Let me know if you hit any issues during installation!