In this recipe, we will see how to compile Hive from source.
Apache Hive is an open source framework available for compilation and modification by any user. Hive source code is a maven project. The source has intermittent scripts executed on a UNIX platform during compilation.
The following prerequisites need to be installed:
UNIX OS: UNIX is preferable for Hive source compilation. Although the source could also be compiled on Windows, you need to comment out the intermittent scripts execution.
Maven: The following are the steps to configure maven:
Download the Apache maven binaries for Linux (
.tar.gz
) from https://maven.apache.org/download.cgi.wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
Extract the
tar
file:tar -xzvf apache-maven-3.3.3-bin.tar.gz
Create a folder and move maven binaries to that folder:
sudo mkdir –p /usr/lib/maven mv apache-maven-3.3.3-bin/usr/lib/maven/
Open
/etc/environment
:sudo nano /etc/profile
Add the following variable for the environment
PATH
:export M2_HOME=/usr/lib/maven/apache-maven-3.3.3-bin export M2=$M2_HOME/bin export PATH=$M2:$PATH
Use the command
source /etc/environment
to add variables toPATH
without restart:source /etc/environment
Check whether maven is properly installed or not:
mvn –version
Follow these steps to compile Hive on a Unix OS:
Download the latest version of the Hive source
tar
file:sudo wget http://a.mbbsindia.com/hive/hive-1.2.1/apache-hive-1.2.1-src.tar.gz
Extract the
source
folder:tar –xzvf apache-hive-1.2.1-src.tar.gz
Move to the
Hive
directory:cd apache-hive-1.2.1-src
To import Hive packages in eclipse, run the following command:
mvn eclipse:eclipse
To compile Hive with Hadoop 2 binaries, run the following command:
mvn clean install -Phadoop-2,dist
In case you want to skip tests execution, run the earlier command with the following switch:
mvn clean install –DskipTests -Phadoop-2,dist
To generate a tarball file from the source code, run the following command:
mvn clean package -DskipTests -Phadoop-2 -Pdist