Apache Hive Installation – Install Hive on Ubuntu in 5 Min
This Apache Hive installation tutorial contains simple steps for installing and running hive on Ubuntu only in 5 min. Hive is a data warehousing infrastructure on the top of Hadoop. Moreover, this Apache Hive installation, help in the quick start, setup and configure Hive and run several Hive QL queries to learn the concepts of the Hive.
So, let’s start Apache Hive Installation Tutorial.
2. What is Apache Hive?
Apache Hive is a warehouse infrastructure designed on top of Hadoop for providing information summarization, query, and ad-hoc analysis. Hence, in order to get your Hive running successfully, Java and Hadoop ought to be pre-installed and should be functioning well on your Linux OS. For installation procedure in Java and Hadoop, you can refer Hadoop installation Guide
3. Apache Hive Installation on Ubuntu
Now in order to get Apache Hive installation successfully on your Ubuntu system, please follow the below steps and execute them on your Linux OS:
a. Hive Download
In this Apache Hive Installation tutorial, we will use hive-0.13.1-cdh5.3.2. (you can also use any latest version of hive) Download hive using below mentioned link: http://archive.cloudera.com/cdh5/cdh/5/hive-0.13.1-cdh5.3.2.tar.gz This file gets downloaded to your Downloads directory.
After the successful Hive download, we will get the following response:
i. Untar the file
Move the setup file in home directory and untar/unzip the downloaded file by executing the below command:
$ tar zxvf hive-0.13.1-cdh5.3.2.tar.gz
b. Setting up Hive Environment Variables
i. Editing .bashrc file
In order to set up the Hive environment, we need to append the following lines at the end of the ~/.bashrc file.
export HADOOP_USER_CLASSPATH_FIRST=true export PATH=$PATH:$HIVE_HOME/bin export HADOOP_HOME=/home/dataflair/hadoop-2.6.0-cdh5.5.1 export HIVE_HOME=/home/dataflair/hive-0.13.1-cdh5.3.2
Note: Here enter correct name & version of your hive and correct path of your Hive File “/home/dataflair/hive-0.13.1-cdh5.3.2” this is the path of my Hive File and “hive-0.13.1-cdh5.3.2” is the name of my hive file. So please enter correct path and name of your Hive file. After adding save this file.
And in order to execute this file use the following command:
$ source ~/.bashrc
4. Launching HIVE
This code will help to launch Hive for Apache Hive installation on Ubuntu.
The following output gets displayed:
Logging initialized using configuration in jar:file:/home/dataflair/HADOOP/hive-0.13.1-cdh5.3.2/lib/hive-common-0.13.1-cdh5.3.2.jar!/hive-log4j.properties hive>
5. Exit from Hive
When your Apache Hive Installation on Ubuntu will complete, you get this kind of Message.
Congratulations!! Hive gets successfully installed on your system. Now you can easily execute your commands.
Before using hive you should change the meta-store layer of the hive, follow this tutorial to change meta-store of the hive from derby to MySQL.
6. Hive Queries
Below are some basic Hive queries which you will need while using Apache Hive Installation on Ubuntu.
a. Show Databases
This Hive query gives a list of databases which are present in your Hive. If you had newly installed Hive and had not created any database, then by default a database named “default” is present there and would be shown up after executing above query.
b. Create Database
This will create a new database named “test”. And you can check this database by writing “show databases;” query.
create database test;
USE query is used to use the database created by you.
d. Current Database
It is used to know the name of the database in which you are currently working.
DROP query is used to delete a database
DROP database database_name;
DROP database test1;
f. Create Table
This command is used to create a new table.
CREATE TABLE TABLE_NAME (Parameters) COMMENT ‘Employee details’ ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ LINES TERMINATED BY ‘\n’ STORED AS TEXTFILE;
create table employee ( Name String comment ‘Employee Name’, Id int, MobileNumber String, Salary Float) row format delimited fields terminated by ‘,’ lines terminated by ‘\n’ stored as textfile;
g. View Tables
It will list you all the tables created by you in the current directory.
h. Alter Table
It is used to change attributes inside a table.
Syntax: We can change a number of attributes inside a table what we want to change.
ALTER TABLE TableName RENAME TO new_name ALTER TABLE TableName ADD COLUMNS (col_spec[, col_spec ...]) ALTER TABLE TableName DROP [COLUMN] column_name ALTER TABLE TableName CHANGE column_name new_name new_type ALTER TABLE TableName REPLACE COLUMNS (col_spec[, col_spec ...])
ALTER TABLE employee RENAME TO demo1;
i. Describe table
This command gives a description of the parameters inside the table.
j. Load Data
This command loads the data from your file path to the selected table created by you in Hive.
LOAD DATA LOCAL INPATH 'Path of the File' OVERWRITE INTO TABLE 'Name of the Table';
LOAD DATA LOCAL INPATH '/home/dataflair/Desktop/details.txt' OVERWRITE INTO TABLE employee;
So, this was all in Hive Installation tutorial. Hope you like our explanation.
7. Conclusion – Hive Installation
Hence, in this Hive installation tutorial, we discussed the process to install Hive on Ubuntu, Windows, and Mac. Moreover, we saw the meaning of Hive. Also, we discussed the launching and exit of Hive. At last, we learned about Hive Queries. Still, if you have any confusion related to Hive Installation, ask in the comment tab.