Hello Guys,
Today we are learning how to deal with hive and HDFS in hadoop system.
First start hive server 2 and metadata for working with Hive. after starting hive client follow below commands:
Create table in Hive
CREATE TABLE NEWTERRITORIES (CID string,FAMILY_NAME string,FULLNAME string,ADDRESS string,DISTRICT string,REGION string,PHONE_NUMBER string,MOBILE_NUMBER string) row format delimited fields terminated by '\t' stored as textfile;
Using HDFS command:
Make directory on HDFS
hdfs dfs -mkdir /user/hadoop/hongkong/NEWTERRITORIES/
Hive evidence can be identified through HiveQL commands. The following commands can be used to get a full listing of all databases and tables as well as the table's formats:
Today we are learning how to deal with hive and HDFS in hadoop system.
First start hive server 2 and metadata for working with Hive. after starting hive client follow below commands:
Create table in Hive
CREATE TABLE NEWTERRITORIES (CID string,FAMILY_NAME string,FULLNAME string,ADDRESS string,DISTRICT string,REGION string,PHONE_NUMBER string,MOBILE_NUMBER string) row format delimited fields terminated by '\t' stored as textfile;
Using HDFS command:
Make directory on HDFS
hdfs dfs -mkdir /user/hadoop/hongkong/NEWTERRITORIES/
Upload file from local to HDFS system
hdfs dfs -copyFromLocal /mnt/data/hongkong/NEWTERRITORIES.tsv /user/hadoop/hongkong/NEWTERRITORIES/
Hive commnad:
Load data from HDFS to hive table
LOAD DATA INPATH '/user/hadoop/hongkong/NEWTERRITORIES/NEWTERRITORIES.tsv' INTO TABLE NEWTERRITORIES;
Create index in Hive data
CREATE INDEX NEWTERRITORIES_index ON TABLE NEWTERRITORIES (CID,FAMILY_NAME,FULLNAME,ADDRESS,DISTRICT,REGION,PHONE_NUMBER,MOBILE_NUMBER) AS 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' WITH DEFERRED REBUILD;
Get records from table:
select * from NEWTERRITORIES;
Hive evidence can be identified through HiveQL commands. The following commands can be used to get a full listing of all databases and tables as well as the table's formats:
Description
|
|
SHOW
DATABASES;
|
This
lists all available databases
|
SHOW
TABLES;
|
This
lists all tables in current database
|
USE
databaseName
|
This
makes databaseName the current database
|
DESCRIBE
(FORMATTED|EXTENDED) table
|
This
lists the formatting details about
|
For more information like connect hive with Programming language (PHP, Java) we will learn in next tutorial.




