BDA Exp-5
BDA Exp-5
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.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
4.2: On the different tab, type this command to launch the beeline command shell:
bin/beeline -n dataflair -u jdbc:hive2://localhost:10000
5.1: I am using show databases query to list out the database in the Hive
warehouse.
COMMANDS:
1. Download Hive.
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
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/hiveserver2
EXAMPLES:
1.CREATE COMMAND
Create a table with the name student.
2.INSERT COMMAND
Select* from student;
4.ALTER COMMAND
Let’s rename table name demo to “customer”
DESCRIBE customer;
5.DROP COMMAND
Drop the table data,
RESULT:
Thus,The Apache Hive has been installed and the examples are executed
successfully.