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

Practical 1-4

The document provides steps to install Hadoop single node cluster in Ubuntu, monitor and manage Hadoop resources using Ambari server, import MySQL database to Hadoop using Apache Sqoop, and create a database and tables using HiveQL functions from Apache Hive. The key steps include downloading required software, setting up the Hadoop cluster in VirtualBox, using the Ambari dashboard to monitor services, using Sqoop to import data from MySQL to HDFS, and using Hive commands to create databases and tables and insert sample data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views14 pages

Practical 1-4

The document provides steps to install Hadoop single node cluster in Ubuntu, monitor and manage Hadoop resources using Ambari server, import MySQL database to Hadoop using Apache Sqoop, and create a database and tables using HiveQL functions from Apache Hive. The key steps include downloading required software, setting up the Hadoop cluster in VirtualBox, using the Ambari dashboard to monitor services, using Sqoop to import data from MySQL to HDFS, and using Hive commands to create databases and tables and insert sample data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

ABDU lAHv s

2022 212 4o4|o2


VO:

INSTALLATION OF HADOOP

AIM:

To install Hadoop single node cluster in Ubuntu

ALOGORITHM:

Step 1 :Download VirtualBox from


https:download.virtualbox.org'virtualbox/7.0.4/VirtualBox-7.0.4-154605
Win.exe or https://aka.ms/vs/17irelease/vc redist x64 exe
Step 2 Download the Hortonworks Data Platform from the link:
https://drive google. fileldi 15ok9gXPcbFs WKFqytXOA8shAhG6Yvf/view?usp
=share ink Hortonworks Data Platfo1 (HDP)Product Downtoad (cloudera. com)
Step 3 : Copy the .ova file (HDP) to the local system
Step 4: Install Oracle VirtualBox
Step 5 : open Oracle VirtualBox and click import appliance.
Gtep 6: choose the path of the .0va file(HOP) and click OK
Step 7: Select the Hortonworks Docker sandbox from the list of Virtual machines and Press
the Start Button
Step 8 : Wait until the OS loads and shows that the browser can be used to navigate

Step 9 : Open Hortonworks page ( http:/127.0.0.1:8888)


Step 10: When asked for the username and password give username/ passWord as
raj_ops/raj ops
Step 11 :Open the SSH Client for running terminal commands inside the browser using
http://127.0.0.1:4200
Step 12 Type the username as root and passvord as hadoop to enter the shell.
Step 13:Type in Hadoop/ HDFS/ PIG Gommands in the term1nal window from the browser.
ESULT:

Thus Hadoop single nodefluster wás installed successfully.


2022 4ol2 o 4 102

X. No :2
AMBARISERVER

AIM:

To monitor and manage Hadoop resources and processes using Ambari server.
ALOGORITHM:

Step I :Open any weh browser (Firefox Chrome Fdge) after running the Hadoop
IHDP in the Virtual Box

Step 2 : Open the Hortonworks Sandbox Page by navigating to


http:/localhost:88RR

Step 3 :0Open the Ambari Dashboard by navigating to http://localhost:8080


Step 4 : Click the Launch Dashboard button and go to http://Mocalhost:8080#/login
Step 5 : Enter the credentials as raj ops, raj ops for username and password
respectivelyand Go through the services and components in the UI.
Step 6:Unless there occurs any problem. the services need not he ehanged. If
there is an issue in the components.choose Serices - &g. Any Serice -&gl. and
then manage the service by choosing from Service Actions -&gt: Turn On |Turn
Maintenance | Turn Off. Turn On the service and turn off the maintenance mode.
Step 7:To view and manage files in the HDFS through the web dashboard go to
Views-&gt: Files View

Step 8: Ifany problem occurs and persists while working. give Start All
Components or Restart All Components under services
Sten 9: For using the Web Client Terminal for running all commands, navigate to
http:/ localhost:4200:

Step 10: The Ambari Server is ready4Q orchestrate and monitor the Hadoop
cluster.
RESULT:

Thus Hadoop resgurces ani processcr are monitored and managed using
Ambari server.
ABD U!LAH Vs

202 24o/2 4o4)o 2

x. No :3
APACHE SÌ0OP
22)o3/23

AIM:

To import MySQL Database to Hadoop using import functions in Apache Sqoop.

ALGORITHM:

Step I:0pen any web browser (Firefos/ Chrome/ Edge) after running the Hadoop
HDP in the Virtual Box

Step 2:Open the Hortonworks Sandbox Page by navigating to


http:/Mocalhost:8888/
Ster 3 : For using the Web Client Terminalfor running all commands. navigate to
http://localhost:4200.
Step 4 : Type the username and password tor Weh Client Terminal to he root and
hadoup
Step 5 : In. the Web Client Terminal. type mysql --user root --password and press
cnter

Step 6.: Give the password as hadoop and press enter.


Step 7.: Create a mysql database using the command create database samp:
Step 8. : In order to create a table use databuse using the command use samp.

Step 9. :create a new table using commands create table student(name varchar(40),.
age int ):

Step 10.: View the schema of the creted table using the cOmmand describe
student:

Step 11 : insert into student(name, age)valugs(&*39:hi&#39:.2|): Likewise, inscrt


more student records.
Step 12: Show the table contents using the command select * from student: then
enter quit: command to cxit the bash.
Step 13 :Create a folder named student in ambari server. Upload a text file inside
the student folder.Import the student table to HDES using the command
sqoop inport -connect jdbc:my sql:/localhost samp --username root --password
hadoop -table student -ml-driver com.mvsyl.jdbc.Driver
Step 14 : view the contents using the command hadoop fs -cat
tudent filename Iilety pe

Step 15 : import the student table to HDES in a particular directory using the
command sqoop import -connect jdbc:mysql://localhost/samp --username root --
password hadoop -table student -ml -driver com.mysql.jdbe.Driver -target-dir
istud folder

Step 16: view the contents using the command hadoop fs -cat /stud folder/part-m

Step 17:import the student table with a condition to HDFS in a particular


directory using thec command sqoop import -connect jdbe:mysql:/1ocalhost 'samp -
-USernane root --password hadoop -tahle stulent -m-s here &quot:age 29&quo.:
-driver com.mysql.jdbe.Driver -target-dir /stud age
Step 18: view the contents using the command hadoop fs -cat /stud age/part-m-*
RESULT:

Thus the MYSQIL Database to Hadood using import functions in Apache


Sqoop was created and verificd succgsslully.
No :40)
APACHE HIVE
lozh3

AIM:

To create a database and work using HIVE QL functions from Apache hive.
ALGORITHM:
Step I:0Open any web browser (Firefos/ Chrome/ Edge) alter running the Hadoop
HDP in the Virtual Box

Step 2 :Open the Hortonworks Sandbox Page by navigating to


http://localhost:8888/
Step 3 : For using the Web Client Terminal lor running all commands. navigate to
http:/Mocalhost:4200.
Step 4 : 1'ype the username and password for Weh Client Terminal to be root and
hadoop
Step 5 :In. the Web Client Terminal, type and enter hive.
Step 6: Now. hive shell opens up to enter hive commands
Step 7:list all the databases using show databases: command
Step 8:create a student database using the command create database stud:
Step 9 :Use the created database for managing the tables using command use stud.
Step 10 :List down all the tables using the command show tables:
Step I| :Create a new student data to add the student reeords to the [ables. A
table can be created using the

following code create table student(pine string.age int. ml int.m2 int,m3 int ):
Step 12 : Preview the schema yr thetabl ereated using command describe student:
Sten 13: Insert three or more student records using insert query.

insert into student(name.age.ml.m2.m3 )values(&quot:Adam&quot:29.100,90,91):


insert into student(name.age.ml.m2.m3)values(&quot:Bala&quot:.13.100,90.92 );:
insert into student(name.age.ml.m2.m3)valucs( &quot:Charlie&quot:.13.90.60.85):
Likewise. all the other student data can be added.
Step 14 : Retrieve all the list of students lrom the lable using the command select *
from student:

Step 15: Retrieve the list of students using where clause. group by and sort by
values.

select * from student where age=13:

select * from student groupy age:

select * from student sort by name desc:


select * from student sort by name asc:

Step 15: Drop the schema just created using command drop schema student:
Step 16: Databases can be deleted or dropped using the command drop database
stud:
RESULT:

Thus the database was created and wok using HIVE QL functions from Apache
hive was created and verified successfully
202 2 ol2 4o/oz

Ex. No 4 (6)

ADVANCED HIVE

AIM:

To create a database and work using HIVE QL functions from Apache hive.
ALGORITHM:

Step 1 :Open any web browser (Firefox/ Chrome/ Edge) after running the Hadoop
HDP in the Virtual Box

Step 2: Open the Hortonwork_ Sandbox Page by navigating to

http://localhost:8888/

Step 3: For using the Web Client Terminal for running all commands, navigate to

http://localhost:4200/.

Step 4: Type the username and password for Web Client Terminal to be root and
hadoop

Step 5:In, the Web Client Terminal, type and enter hive.

Step 6: Now, hive shell opens up to enter hive commands.

Step 7: list all the databases using show databases; command

Step 8: create a product database using the command create database prod :

Step 9: Use the created databáse for managing the tables using
command use prod;
Step 10: List down all the tables using the command show tables;

Step 11 : Create a new product data to add the student records to the Tables. A

table can be created using the following code create table products(prodid
int, prodname string,prodprice float);
Step 12 : Preview the schema of the table created using command describe student;
Step 13: Insert three or more student records using insert query.

insert into products values('Barbie",101,250);


insert into products values("Heman",102,300);
insert into products values"Buji",104,150):
Likewise, all the other products data can be added.

Step 14:Retrieve all the list of students from the table using the command select

from products;

Step 15: Alter the table using the following commands;


ALTER TABLE <name>RENAME TO <new name>

ALTER TABLE <name> ADD COLUMNS (<col spec,[<col spec> 1)

ALTER TABLE <name> CHANGE <column name><new


name><new type>

ALTER TABLE <name> REPLACE COLUMNS (<col spec>),[<col spec>|)

Step 16: Rename a Partitionjn the existing Table using the following
command:
ALTER TABLE <table name> PARTITION partition spec RENAME TO
PARTITION
partition_spec,
Step 17: Create bucketed Table for toy airoplane of product code 10725 and create

cluster of 5 buckets

CREATE TABLE IF NOT EXISTS toy_airoplane 10725(productCategory String.


Productid int, productName string), CLUSTERED BY into 3 buckets;

Step 18: Create a view named toy_ tbl MiniJoin

CREATE VIEW toy_tbl_MiniJoin AS

Select toy_tbljoin people JOIN Toy Airplane


ON(Toy_Airoplane.Productid.id)Where productid=10725;
Step 19: Createa join clause

SELECT t.productid, t.Prouctname, p.ProdductPrice FROM toy_tbl t JOIN price p


on (t.Productid p.id):

Step 20: Drop the schema just created using command drop
schema products;
Step 21: Databases can be deleted or dropped using the command drop database
prod;
RESULT:

Thus the databasc was greated and work using HIVE QL


functions from
Apache hive created and verified successfully.

You might also like