Tuesday, January 14, 2014

Day#3 Hive: Install Hive on Ubuntu and load a file into Hive




Hive installation is simple.I installed Hadoop in standalone mode on ubuntu linux machine.Download Hive into local drive from http://hive.apache.org/releases.html#Download.Find the latest releases.I used http://mirror.reverse.net/pub/apache/hive/hive-0.11.0/
 

Download hive from apache site into your local Ubuntu folder




Untar hive.

Untar



Move the binary into the hive home directory /usr/local/hive. Use sudo root password if you dont have permission.


Move the file into /usr/local/hive



Export variables and save it in .bashrc.


export variables and save in .bashrc



Here you go. In standalone mode, Hive shell will automatically detect the local HDFS and mapreduce nodes .Fire hive shell.


Start hive shell .Use set-v to see all configuration variables




Create a table book with a column string of data type string.

Create table syntax

From Another terminal window, Use hadoop fs -ls command to see the hive table is a directory in HDFS.

hive table is a directory in HDFS

Let us load a file into Hive.copy file book into HDFS using hadoop fs -copyFromLocal <local file system source> <HFDS Destination>

Copy the file named book to HDFS using hadoop fs -copyFromLocal command




Load the file into Hive table using LOAD DATA

From Hive shell ,Load the HDFS file 'book' into the Hive table book


SELECT * from table to see the data.

1 comment: