0% found this document useful (0 votes)
13 views14 pages

BDA Exp-5

Big Data Analysis 5th experiment

Uploaded by

HEMALAKSHMI D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views14 pages

BDA Exp-5

Big Data Analysis 5th experiment

Uploaded by

HEMALAKSHMI D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Ex.

no:05
Date:
INSTALLATION OF HIVE ALONG WITH PRACTICE EXAMPLES

AIM:
To installation of hive along with practice examples.

PROCEDURE:
Step 1: Download Hive.
1.1: First, download the Hive 3.1.2.
1.2: Locate the apache-hive-3.1.2-bin.tar.gz file in your system.
1.3: Extract this tar file using this command: tar -xzf apache-hive-3.1.2-bin.tar.gz
Step 2: Configuring Hive files.
2.1: Now, we have to place the Hive PATH in .bashrc file.For this,open .bashrc file
in the nano editor and add the following in the .bashrc file.
2.2: Open the core-site.xml file in the nano editor. The file is located
in home/hadoop-3.1.2/etc/hadoop/ (Hadoop Configuration Directory).

2.3: Add the configuration property in the core-site.xml file.

2.4: Make a directory ‘tmp’ in HDFS using the command: hadoop fs -mkdir /tmp

2.5: Use the below commands to create a directory ‘warehouse’ inside ‘hive’
directory, which resides in ‘user’ directory. The warehouse is the location to store
data or tables related to Hive using hadoop fs -mkdir /user , hadoop fs -mkdir
/user/hive, hadoop fs -mkdir /user/hive/warehouse
2.6: Give the write permission to the members of the ‘tmp’ file group using
command: hadoop fs -chmod g+w /tmp

2.7: Now give write permission to the warehouse directory using the command:
hadoop fs -chmod g+w /user/hive/warehouse
Step 3: Initialize Derby database.

3.1: Hive by default uses Derby database. Use this command to initialize the Derby
database: bin/schematool -dbType derby -initSchema

Step 4: Launching Hive.

4.1: Now start the HiveServer2 using this command: bin/hiveserver2


[For this first move to the ~/apache-hive-3.1.2-bin/]

4.2: On the different tab, type this command to launch the beeline command shell:
bin/beeline -n dataflair -u jdbc:hive2://localhost:10000

Step 5: Verifying Hive Installation.

5.1: I am using show databases query to list out the database in the Hive
warehouse.
COMMANDS:

1. Download Hive.

Locate the apache-hive-3.1.2-bin.tar.gz file in your system.

1.1.Extract this tar file using the below command:

$ tar -xzf apache-hive-3.1.2-bin.tar.gz


2. Configuring Hive files.
open .bashrc file in the nano editor and add the following in the .bashrc file.

export HIVE_HOME= “home/dataflair/apache-hive-3.1.2-bin”


export PATH=$PATH:$HIVE_HOME/bin

Note: Here enter the correct name & version of your hive and correct path of your
Hive File “home/dataflair/apache-hive-3.1.2-bin” this is the path of my Hive File
and “apache-hive-3.1.2-bin” is the name of my hive file.

So please enter the correct path and name of your Hive file. After adding save this
file.
Press CTRL+O and enter to save changes. Then press CTRL+D to exit the editor

3. Open the core-site.xml file in the nano editor. The file is located
in home/hadoop-3.1.2/etc/hadoop/ (Hadoop Configuration Directory).
Add the following configuration property in the core-site.xml file.
<configuration>
<property>
<name>hadoop.proxyuser.dataflair.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.dataflair.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.server.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.server.groups</name>
<value>*</value>
</property>
</configuration>
Press CTRL+O and enter to save changes. Then press CTRL+D to exit the editor.
4. Make a directory ‘tmp’ in HDFS using the below command:

hadoop fs -mkdir/tmp

5. Use the below commands to create a directory ‘warehouse’ inside ‘hive’


directory, which resides in ‘user’ directory. The warehouse is the location to store
data or tables related to Hive.

hadoop fs -mkdir /user


hadoop fs -mkdir /user/hive
hadoop fs -mkdir /user/hive/warehouse
6. Give the write permission to the members of the ‘tmp’ file group using
command:

hadoop fs -chmod g+w /tmp

7. Now give write permission to the warehouse directory using the command:
hadoop fs -chmod g+w /user/hive/warehouse
8. Initialize Derby database.
Use the below command to initialize the Derby database.

bin/schematool -dbType derby -initSchema


9. Launching Hive.

bin/hiveserver2

[For this first move to the ~/apache-hive-3.1.2-bin/]


10. On the different tab, type the below command to launch the beeline command
shell.

bin/beeline -n dataflair -u jdbc:hive2://localhost:10000

11. Verifying Hive Installation.


For example, in the below image, I am using show databases query
to list out the database in the Hive warehouse.
We have successfully installed Apache Hive 3.1.2 on Hadoop 3.1.2 on Ubuntu.

EXAMPLES:
1.CREATE COMMAND
Create a table with the name student.

2.INSERT COMMAND
Select* from student;

3.LOAD DATA INTO TABLE


Load the data into student hive table.

Select* from student;

4.ALTER COMMAND
Let’s rename table name demo to “customer”

Let’s add the column to the customer name.

DESCRIBE customer;

5.DROP COMMAND
Drop the table data,

RESULT:
Thus,The Apache Hive has been installed and the examples are executed
successfully.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy