10
Setup Hive and Collect the Honey By Kannan Kalidasan

Setup hive and test queries

Embed Size (px)

DESCRIPTION

This is basic tutorial to setup hive in rapid way and quickly test the hive shell with same statement.

Citation preview

Page 1: Setup hive and test queries

Setup Hive and Collect the Honey

By Kannan Kalidasan

Page 2: Setup hive and test queries

Hive IntroductionHive is a data warehousing infrastructure based on Hadoop. Hive is designed to enable easy data summarization, ad-hoc querying and analysis of large volumes of data. It provides a simple query language called Hive QL, which is based on SQL and which enables users familiar with SQL to do ad-hoc querying, summarization and data analysis easily.I recommended To learn Programming Hive – Allan Gates bookBelieve me any Developers having intermediate knowledge on any one of the Database can able to pick up this easily , quickly and expertise it. When i say intermediate knowledge on Database , i am referring like an individuals has knowledge on Table Creation,Select queries and different clauses,Join Queries,DML Operations,Basic Database creation script knowledge, Indexes and Partitions. Thats it . This should be sufficient for anyone to understand most of the topics in HIVE. Hive has its own features and Data Model Approach which you will come to know when you read it .

Then Your brain will start comparing your left and right eyes to know which is best :)

Page 3: Setup hive and test queries

Hive Installation1. Download the stable version of tarbal.

http://mirror.reverse.net/pub/apache/hive/stable/

hive-0.11.0.tar.gz

Release notes link

http://hive.apache.org/releases.html

Page 4: Setup hive and test queries

Hive Installation ...2.Copy the downloaded package to /usr/local

kannan@kannandreams:/usr/local$ ls -ltrtotal 192652-rw-r–r– 1 root root 74945460 Dec 5 00:59 hive-0.11.0.tar.gzkannan@kannandreams:/usr/local$

3. unzip and change the ownersudo tar xzf hive-0.11.0.tar.gzsudo mv hive-0.11.0 hivesudo chown -R hduser:hadoop hive

chown command change the owner of the directory hive from root to hadoop user hduser.

Page 5: Setup hive and test queries

Hive Installation ...4.Login to Hadoop user hduser and set the environment variables.kannan@kannandreams:/usr/local$ su – hduserPassword:hduser@kannandreams:~$ vi .bashrc

Add the below two lines in ~/.bashrc file and save it.

#Hive env variablesexport HIVE_HOME=”/usr/local/hive”export PATH=$PATH:$HIVE_HOME/bin

hduser@kannandreams:~$ . .bashrc ( source the file to reflect the env. values)

Page 6: Setup hive and test queries

Note to Remember

Hadoop services should be running to work in HiveStart the Hadoop services with the command start-all.sh

Page 7: Setup hive and test queries

Hive Shellhduser@kannandreams:~$ cd $HIVE_HOMEhduser@kannandreams:/usr/local/hive$ hiveLogging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-0.11.0.jar!/hive-log4j.propertiesHive history file=/tmp/hduser/hive_job_log_hduser_6282@kannandreams_201312050123_1791376162.txthive>

Page 8: Setup hive and test queries

Hive Shell ...Test by creating a sample table and show tables statement – list the tables available in database.hive> show tables;OKTime taken: 6.84 secondshive> create table test (Id INT);OKTime taken: 0.605 secondshive> show tables;OKtestTime taken: 0.1 seconds, Fetched: 1 row(s)hive>quit;

Page 9: Setup hive and test queries

Hive DirectoryIf you notice in HDFS Directory, Hive create the below directory by default based on configuration XML file. I didn’t mentioned in detail about the conf. xml file.

drwxr-xr-x – hduser supergroup 0 2013-12-05 01:33 /user/hivedrwxr-xr-x – hduser supergroup 0 2013-12-05 01:39 /user/hive/warehousedrwxr-xr-x – hduser supergroup 0 2013-12-05 01:39 /user/hive/warehouse/test

Page 10: Setup hive and test queries

Thank You !!!Now we got the new job “apiarist” :)

mail : [email protected]@kannanpoem on twitter

Blog: http://kannandreams.wordpress.com/about/FB Community: www.facebook.com/groups/huge360/

HUGE - Hadoop User Group & Enthusiasts

Huge , Yes Its All about "BIG" DataThis has been created to build a group to get expertise and experts in Hadoop and Big Data .