This tutorial is tested on Ubuntu
First of we need to install and configure Hadoop on system. Use the following link to install Hadoop on Ubuntu: http://www.professionalcipher.com/2018/01/how-to-install-hadoop-on-ubuntu-1604.html
Steps:
#Download Hive from http://www.eu.apache.org/dist/hive/stable/apache-hive-1.2.2-bin.tar.gz
# Copy and extract apache-hive-1.2.2-bin.tar.gz in home folder
# Rename the extracted folder name from apache-hive-1.2.2 to hive
# remember your user name
# Set the environment variables
# add following lines at the end CHANGE YOUR_USER_NAME
# save and exit the file
#then add below line in terminal
# verify the PATH variable
# start DFS
#Make Directories for Hive
#Add these lines
#DONE Run Hive CLI
# Creating Hive Table
hive>
# show all tables
hive>
# show tables that end with ‘t’
hive>
# show the list of columns of a table
hive>
# change the table name
hive>
# add new column to a table
hive>
hive>
# drop table
hive>
# quit Hive CLI
hive>
# Stop hadoop
First of we need to install and configure Hadoop on system. Use the following link to install Hadoop on Ubuntu: http://www.professionalcipher.com/2018/01/how-to-install-hadoop-on-ubuntu-1604.html
Steps:
#Download Hive from http://www.eu.apache.org/dist/hive/stable/apache-hive-1.2.2-bin.tar.gz
# Copy and extract apache-hive-1.2.2-bin.tar.gz in home folder
# Rename the extracted folder name from apache-hive-1.2.2 to hive
# remember your user name
whoami
# Set the environment variables
gedit .bashrc
# add following lines at the end CHANGE YOUR_USER_NAME
export PATH="/home/your_user_name/hadoop/bin:$PATH"
export PATH="/home/your_user_name/hadoop/sbin:$PATH"
export PATH="/home/your_user_name/hive/bin:$PATH"
# save and exit the file
#then add below line in terminal
source .bashrc
# verify the PATH variable
echo $PATH
# start DFS
~/hadoop/sbin/start-dfs.sh
jps
#Make Directories for Hive
~/hadoop/bin/hadoop fs -mkdir /tmp
~/hadoop/bin/hadoop fs -mkdir /user
~/hadoop/bin/hadoop fs -mkdir /user/hive
~/hadoop/bin/hadoop fs -mkdir /user/hive/warehouse
#Add these lines
~/hadoop/bin/hadoop fs -chmod g+w /tmp
~/hadoop/bin/hadoop fs -chmod g+w /user/hive/warehouse
#DONE Run Hive CLI
hive
# Creating Hive Table
hive>
CREATE TABLE student (roll INT, name STRING);
# show all tables
hive>
SHOW TABLES;
# show tables that end with ‘t’
hive>
SHOW TABLES '.*t';
# show the list of columns of a table
hive>
DESCRIBE student;
# change the table name
hive>
ALTER TABLE student RENAME TO student1;
# add new column to a table
hive>
ALTER TABLE student1 ADD COLUMNS (marks INT);
hive>
DESCRIBE student1;
# drop table
hive>
DROP TABLE student1;
# quit Hive CLI
hive>
quit;
# Stop hadoop
~/hadoop/sbin/stop-dfs.sh
jps
Comments
Post a Comment