0% found this document useful (0 votes)
4 views63 pages

CCS335 CC Record Final

fqwq

Uploaded by

maheshmsk2006
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)
4 views63 pages

CCS335 CC Record Final

fqwq

Uploaded by

maheshmsk2006
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

CCS335– CLOUD COMPUTING LABORATORY

RECORD

Name :

Register No :

Branch :

Year / Sem :
BONAFIDE CERTIFICATE

Register No.

Certified to be the bonafide record of work done by

of Semester B.E / [Link] course in the

CCS335 – Cloud Computing Laboratory in SRM MADURAI COLLEGE FOR ENGINEERING

AND TECHNOLOGY, POTTAPALAYAM, during the academic year 2026 - 2027.

Staff in Charge Head of the Department

Submitted for the University Practical Examination held on at SRM MADURAI

COLLEGE FOR ENGINEERING AND TECHNOLOGY, POTTAPALAYAM.

Internal Examiner External Examiner


CONTENTS

Ex No Date Name of the Experiment Page No. Observation Record Faculty


Mark Mark Sign

Install VirtualBox/VMware/ Equivalent open


source cloud Workstation with different
1
flavor’s of Linux or Windows OS on top of
Windows 8 and above.
Install a C compiler in the virtual machine
2 created using a virtual box and execute
Simple Programs.
Install Google App Engine. Create a
3 hello world app and other simple
web applications using python/java.

Use the GAE launcher to launch the web


4
applications.

Simulate a cloud scenario using CloudSim


5 and run a scheduling algorithm that is not
present in CloudSim.

Find a procedure to transfer the files from


6
one virtual machine to another virtual
machine.

Install Hadoop single node cluster and


7
run simple applications like wordcount.

Creating and Executing Your First


8
Container Using Docker.

9 Run a Container from Docker Hub

Content Beyond Syllabus

10 Mount the one node Hadoop cluster using


fuse
[Link].1 Install Virtualbox/VMware Workstation with different flavours
Date : of linux or windows OS on top of windows7 or 8.

AIM:
To find procedure to run the virtual machine of different configuration and check how
manyvirtual machines can be utilized at particular time.

PROCEDURE:

Installing Ubuntu using Oracle Virtual BoxStep1:


Open Oracle virtual box manager and click create new -> virtual machine.

Step 2: Provide a name for the virtual machine and select the hard disk size for the
virtualmachine. Select the storage size as Dynamically allocated memory size and click
[Link] virtual machine will be created.

1
Step 3: Select the iso file of the virtual OS Ubuntu and click Start.

Step 4: The virtual OS Ubuntu is opened successfully. Now type “gedit” in the searchbox to open text
editor in Ubuntu.

Step 5: Type your desired C program in text editor and save it with the extension (.c).

Step 6: Type “terminal” in the search box to open the command window.

Step 7: Type the necessary commands to compile and run the C program.

2
Installing Windows 7 using Oracle Virtual
Box PROCEDURE:
Step1: Open Oracle virtual box manager and click create new -> virtual machine. Provide and
name for the operating system and select the memory size to be occupied in memory.

Step 2: Select the iso file of the virtual OS Windows7 and click Start.

Step 3: Select the language to use in the Operating System and click Install Now.

3
LOUD COMPUTING LABORATORY
Step 4: Select the type of installation as Custom for new installation and allocate Diskspace
according to your convenience. Click Next to start the installation.

Step 5: After installation the system will be restarted to complete the installation.

4
Step 6: Provide a user name and password(optional) to gain access over the OS.

Step 7: Set the time and date for the new Operating System.

Step 8: Thus the new Operating System Windows7 will be opened as the virtual machine.

5
Viva Questions:

1. What is virtualization?
2. What is the role of a hypervisor?
3. Difference between host OS and guest OS?
4. What is the use of VirtualBox / VMware?
5. Name any two Linux distributions used in virtual machines.

RESULT:

Thus the procedure to run different virtual machines on a single system using
Oracle Virtual Box is studied and implemented successfully.

6
Viva Questions with Answers:

7
[Link] Install a C compiler in the virtual machine created using virtual box and
Date: execute Simple Programs.

AIM:
To find a procedure to use the C compiler in the virtual machine and execute a sample program.

PROCEDURE:

Step 1: Open the virtual machine in which you want to run the C program.
Step 2: The text editor used by the Ubuntu Operating System is the [Link] can be
opened by using the search option by typing gedit in it.

The text editor will be opened now.

Step 3: Type your desired C program in the text editor and save it as a C file using
theExtension (.c) for C programs.

8
Step 4: Type “terminal” in the search box to open the command window.

Step 5: Type the necessary commands to cmpile and run the C program.
(1). ./[Link] to display the output of the last compiled program.

9
Viva Questions:

1. What is a compiler?
2. Name a C compiler commonly used in Linux.
3. Why do we use GCC in virtual machines?
4. What is the purpose of the gcc command?
5. How do you execute a C program in Linux?

RESULT:
Thus the procedure to use the C compiler in the virtual machine and execute a sample
program is implemented successfully.
10
Viva Questions with Answers :

11
[Link]
Installing Google App Engine. Create a hello world app and other simple web
Date: applications using python/java

AIM:
To Installing and Running the Google App Engine On Windows
PROCEDURE:
Install the latest Cloud SDK
Version(303.0.0) Step1: Download the
Cloud SDK installer.

Alternatively, open a PowerShell terminal and run the following


PowerShell commands.
[Link]).DownloadFile("[Link] oudsdk/cha nnels/ra

pid/[Link]", "$env:Temp\[Link]

& $env:Temp\[Link]

Step 2: Launch the installer and follow the prompts. The installer is signed by Google LLC. Cloud
SDK requires Python. Supported versions are 3.5 to 3.7, and 2.7.9 or higher.
The installer will install all necessary dependencies, including the needed Python version. While
Cloud SDK currently uses Python 2 by default, you can use an existing Python installation if
necessary by unchecking the option to 'Install Bundled Python'. .

Note: Cloud SDK uses Python 2 by default, but will soon move to Python 3 (run gcloud topic
startup for exclusions and more information on configuring your Python interpreter to use a
different version). Consider upgrading to Python 3 to avoid disruption in the future.
Step 3: After installation has completed, accept the following options: Start
Cloud SDK Shell
Run gcloud init
OUTPUT:

12
The installer starts a terminal window and runs the gcloud init command
Step 4: The default installation does not include the App Engine extensions required to
deploy an application using gcloud commands. These components can be installed using
the Cloud SDK component manager.
Optional: Enable accessibility features
For a more streamlined screen reader experience, the gcloud command-line tool comes with
an accessibility/screen_reader property.
gcloud config set accessibility/screen_reader true
Percentage progress bars: Progress will be displayed as a percentage, outputted to stderr.

Boxed tables drawn with ASCII characters: Boxed tables are the default output of many
list commands. Instead of being drawn with Unicode, they will be rendered using ascii
characters. Also, consider using the --format flag to define your own format. To enable these
accessibility features, run:
$ gcloud config set accessibility/screen_reader true
Additional resources
Alternate documentation experiences

To search the gcloud CLI reference docs for a keyword or command, use gcloud help.
This runs a search for all commands with help text matching the given argument or
arguments.

Refining gcloud CLI output

To adjust the verbosity level of a command, you can set the gcloud CLI-wide flag --
verbosity with either debug, info, warning, error, critical, or none.

13
For list commands, you can further refine your output by using the --limit flag to set a
maximum number of resources to list. You can also use the --page-size flag to define the
number of resources per page if the service lists output in pages. To sort, use the --sort-
by flag with the relevant field to sort.

To disable interactive prompting, use the --quiet flag.

To structure and produce more meaningful output, you can use the format, filter and
projection flags to fine-tune your output.
If you'd like to define just the format of your output, use the --format flag to produce a
tabulated or flattened version of your output (for interactive display) or a machine-
readable version of the output (json, csv, yaml, value). To format a list of keys that
select resource data values, use projections.

14
To further refine your output to a criteria you'd like to define, use the -- filter flag.
Filing feedback

To file a bug, provide feedback, or send suggestions, use gcloud feedback to help
improve the gcloud command-line tool experience. This command will open the public
issue tracker in a browser window.
You can also directly log issues using issue tracker. Be sure to toggle the 'Type' field to
reflect the nature of the issue you're filing (Bug, Feature Request, etc.) to help make
responses more efficient.
To enable this property, run:
• Download Google Cloud SDK[Link]
• Login to google account and verify the account with google for the
successful authentication.
• Download webapp2 module from [Link]
• Write down simple hello world python program. import webapp2
class MainPage([Link]) def get(self):
[Link]("Hello World")

app = [Link]([('/',MainPage)], debug=True)


• Create [Link] which has url link

runtime: python3 api_version: threadsafe:


true handlers:
-url: / script:
[Link]

Run the gcloud prompt and give Yes option to proceed further. Install gcloud components
using the command gcloud components install cloud-datastore-emulator

15
Viva Questions:

1. What is Google App Engine?


2. Which cloud service model does GAE belong to?
3. What languages are supported by GAE?
4. What is the purpose of [Link]?
5. What is meant by automatic scaling in GAE?

RESULT:
Thus the procedure to use the C compiler in the virtual machine and execute a sample
program is implemented successfully.

16
Viva Questions with Answers:

17
[Link]: 4
Use the GAElauncherto launchthe web applications
Date:

AIM:
To Use GAE launcher to launch the web applications
PROCEDURE:

Setting Up Your Development Environment


To set up your environment for
developing on Python 3: 1. Download and
install the latest release of Python 3.

See Python 3 Runtime Environment for a list of the supported versions.

2. Download, install, and then initialize the Cloud SDK. If you already have
the Cloud SDK installed, run the gcloud components update command
to update to the latest release.

The Cloud SDK provides you the gcloud command-line tooling for
deploying and managing your apps.

By downloading, you agree to be bound by the Terms that govern use


of the Cloud SDK for App Engine.

Download and Install the Cloud SDK

Note: Avoid using a package manager such as apt or yum to install the Cloud SDK.

Installing optional tools


For access to code, samples, libraries, and tools in GitHub, install
Git: Download and install Git
Install your preferred tooling or framework, for example you can use any of the
following frameworks to develop your Python 3 app:

• Flask
• Pyramid

18
• Bottle
• [Link]
• Tornado

Creating a website to host on Google App Engine


Basic structure for the project
This guide uses the following structure for the project:

• [Link]: Configure the settings of your App Engine application.

• www/: Directory to store all of your static files, such as HTML, CSS,

images, and JavaScript.

• css/: Directory to store stylesheets.


• [Link]: Basic stylesheet that formats the look and feel of your site.
• images/: Optional directory to store images.
• [Link]: An HTML file that displays content for your website.
• js/: Optional directory to store JavaScript files.
• Other asset directories.

Creating the [Link] file

The [Link] file is a configuration file that tells App Engine how to map
URLs to your static files. In the following steps, you will add handlers that will
load www/[Link] when someone visits your website, and all static files will
be stored in and called from the www directory.

Create the [Link] file in your application's root directory:

1. Create a directory that has the same name as your project ID. You can find
<html>
<head>
<title>Hello, world!</title>
<linkrel="stylesheet"type="text/css"href="/css/[Link]">

19
</head>
<body>
<h1>Hello, world!</h1>
<p>
This is a simple static HTML file that will be served from Google
App
Engine.
</p>
</body>
</html>

gcloud app deploy


2. your project ID in the Console.
3. directory that you just created, create a file named [Link].
4. Edit the [Link] file and add the following code to the file:

Creating the [Link] file

Create an HTML file that will be served when someone navigates to the
root page of your website. Store this file in your www directory.

Deploying your application to App Engine


When you deploy your application files, your website will be uploaded
to App Engine. To deploy your app, run the following command from within
the root directory of your application where the [Link] file is located:

Optional flags:

• Include the --project flag to specify an alternate Cloud Console project ID


to what you initialized as the default in the gcloud tool. Example: --project
[YOUR_PROJECT_ID]
• Include the -v flag to specify a version ID, otherwise one is generated for
you. Example: - v [YOUR_VERSION_ID]

To learn more about deploying your app from the command line, see
Deploying a Python 2 App. viewing your application
20
To launch your browser and view the app at
[Link] run the following
command:

gcloud app browse

Step 1 : Download the basic housekeeping stuff

No matter what platform you build products on, there is always some
housekeeping stuff you need to put in place before you can hit the ground
running. And deploying apps within the Google App Engine is no exception.

Download Python 2.7


As of when this article was written, the Google App Engine standard
environment supports Python only upto version 2.7. However, it is only a
matter of time before support for Python 3.x is added. You can check the App
Engine docs for the latest info.

Download Google Cloud SDK

This will allow you to fork apps onto your local machine, make changes
(edit and develop the app), and deploy your app back to the cloud.

Set the Python path in the Google App Engine launcher

After downloading the SDK, launch the App Engine launcher, go to Edit
-> Preferences and make sure you set the path for where you installed Python
in step 1 above.
Set the Python path in Google App Engine launcher That’s all you need.
Your local machine should now be ready to build webapps.

Step 2 : App Engine sign-up

This is often the most confusing part of the entire setup. Things you should
know when you sign-up:

1. Currently, App Engine offers a free trial for one year.

21
2. The trial includes $300 of credit that can be used during the one year
trial period.
3. You will need to add a credit card to sign-up (for verification purposes).
4. You will not be charged during the sign-up process.
5. You will not be charged during the trial period as long as you do not cross
the credit limit offered.

Here are the steps you need to follow to sign-up:

1. Go to the Google Cloud landing page


2. Follow the sign-up process and go to your App Engine
dashboard Most of the hard work is complete after a successful sign-up.

Step 3 : Create a new project

The next step is to create a new Python project that you can work on.
Follow the screenshots below to create a new project.

Launch the new project wizard.


Give your app a name and make a note of your project ID.
Hit the create button and Google should take a few minutes to set up all that is
necessary for your newly created app.

Step 4 : Fork the app to develop it locally

The next step in the process is to fork the app on your local machine. This will
allow you to make changes to the app locally and deploy it whenever you wish to.

Go to Google App Engine launcher and create a new application.


Enter the project ID of your newly created app. Also, provide the folder (local
destination) where you wish to store the app locally. Make sure you select the
Python
2.7 as your runtime engine.

Hit the create button, and you should see your app listed on the window that
follows. You should also check that you now see some files in your local
storage (the directory you chose in the screenshot above) after this step.

22
Step 5 : Run the app locally
Before you go ahead and make some changes to the app, it is important to
check whether or not you have executed all the above steps correctly. This can be
done by simply running the app locally.

Select the app and hit the run button on the window.
Wait for a few seconds until you can hit the Browse button. Once the
Browse button becomes clickable, click it. This should take you to the browser,
and you should see the hello world text appear in your browser window.
Alternatively, you can manually go to the browser and use the port specified to
access the app. As long as you see the above screen, you are all set.

Step 6 : Understand the app structure

It is finally time to look at the lines of code which are running this
webapp. Open your app folder in the text editor of your choice. I recommend
Sublime text or VS Code. However, feel free to choose the one you prefer.

Here is a description of the various files. [Link]

This file is a basic markup file that stores information (some metadata) about
the app. It is important to note the following crucial parts of the file.
1. application

This is the project ID which you should never change. This is the unique identifier
for the app
url -> script
This is the homepage for the app. In other words, this file will be rendered in
your browser when you launch the app

2. libraries This is where you can include external libraries to use within the
webapp [Link]
This is the homepage of the app (as discussed above). Note that the hello world text in
the browser window (step 5) is due to the code you see highlighted below.

23
Step 7 : Make your changes and deploy the new app
No hello world app is ever complete without the developer changing the
hello world text to something else just to make sure that everything happening
behind the scenes is working as it
should.

Go ahead and change the text in the above screenshot to something else.
Save the changes, go to the browser and refresh the page. You should see the page
with the text
“MEOW” displayed.
Finally, it is time to deploy your changes to the cloud to make them globally
accessible via a URL. Go to the App Engine launcher, select the app, and hit the
Deploy button.

Step 8 : Misc
Congratulations, you’ve finally gotten your first Python webapp deployed on the
Google App Engine. Here are some other points which you may find useful.

1. Jinja 2 is an amazing front end templating library for Python that can do
some cool stuff, such as passing objects form Python to HTML, using for
loops, if conditions, and so on directly out of the box

2. Here’s a very useful Udacity course on web development that I have


personally found quite resourceful
3. Viewing the logs while running your webapp can be handy to debug and also
discover some bugs on the fly.

OUTPUT:

24
Viva Questions:

1. What is GAE Launcher?


2. Why is local testing important before deployment?
3. What is localhost?
4. What port number is commonly used by GAE?
5. What happens when an application fails to start in GAE?

RESULT :
Thus the GAE launcher to launch the Applications is Successful.

25
Viva Questions and Answers:

26
[Link] : 5
Date : Simulate a cloud scenario using CloudSim and run
a scheduling algorithm that is not present in
CloudSim.

AIM :
To Simulate a cloud scenario using CloudSim and run a scheduling algorithm that is not
present in CloudSim.

Introduction:
 CloudSim
 A Framework for modeling and simulation of Cloud
Computing Infrastructures and services
 Originally built at the Cloud Computing Distributed Systems
(CLOUDS) Laboratory, The University of Melbourne,
Australia
 It is completely written in JAVA
 Main Features of CloudSiM
o Modeling and simulation
o Data centre network topologies and message-passing applications
o Dynamic insertion of simulation elements
o Stop and resume of simulation
o Policies for allocation of hosts and virtual machines
 Cloudsim – Essentials
 JDK 1.6 or above [Link]
 Eclipse 4.2 or above [Link]
 Alternatively NetBeans [Link]
 Up & Running with cloudsim guide: [Link]
 Cloudsim- Directory structure
o cloudsim/ -- top level CloudSim directory
o docs/ -- CloudSim API Documentation
o examples/ -- CloudSim examples
o jars/ -- CloudSim jar archives
o sources/ -- CloudSim source code
 Cloudsim - Layered Architecture

 Cloudsim - Component model classes


o [Link]
o [Link],[Link],[Link]
o [Link],[Link]
o [Link]
o [Link],[Link], [Link]
 Cloudsim - Major blocks/Modules
 [Link]
27
28
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 [Link]
 Cloudsim - key components
o Datacenter
o DataCenterCharacteristics
o Host o DatacenterBroker
o RamProvisioner
o BwProvisioner
o Storage
o Vm
o VMAllocationpolicy
o VmScheduler
o Cloudlet
o CloudletScheduler
o CloudInformationService
o CloudSim
o CloudSimTags
o SimEvent
o SimEntity
o CloudsimShutdown
o FutureQueue
o DefferedQueue
o Predicate and associative classes.

CloudSim
Elements/Components Procedure to import Eclipse, Cloudsim
in your system
Step 1: Link to download Eclipse and download Eclipse for Windows 64bit into
your Loca machine.[Link]
ide- java-
eclipse-
developers

29
Step 2: Download cloudsim-3.0.3 from git hub repository in your local
machine.[Link]

Step 3: Download commons-maths3-3.6.1 from git hub repository in your local


machine [Link]

Step 4: Downloaded Eclipse, cloudsim-code-master and Apache Commons Math 3.6.1 in


your local machine and extract cloudsim-3.0.3 and Apache Commons Math 3.6.1

Step 5: First of all, navigate to the folder where you have unzipped the eclipse folder and
open [Link]

Step 6: Now within Eclipse window navigate the menu: File -> New -> Project, to open the new
project wizard
30
Step 7: A ‗New Project‗ wizard should open. There are a number of options displayed and
you have to find & select the ‗Java Project‗ option, once done click ‘Next‗

Step 8: Now a detailed new project window will open, here you will provide the project name
and the path of CloudSim project source code, which will be done as follows:
Project Name: CloudSim.

Step 9: Unselect the ‘Use default location’ option and then click on ‘Browse’ to open the
path where you have unzipped the Cloudsim project and finally click Next to set project
settings.

Step 10: Make sure you navigate the path till you can see the bin, docs, examplesetc folder in the
navigation plane.
31
Step 11: Once done finally, click ‗Next„ to go to the next step i.e. setting up of project settings

Step 12: Now open ‘Libraries’ tab and if you do not find [Link] (here ‘x’
means the minor version release of the library which could be 2 or greater) in the list then simply
click on ‗Add External Jar’ ([Link] will be included in the project from this
step)

Step 13: Once you have clicked on ‗Add External JAR’s‗ Open the path where you have
unzipped the commons-math binaries and select ‗[Link]„ and click on
open.

Step 14: Ensure external jar that you opened in the previous step is displayed in the list and then
click on ‗Finish„ (your system may take 2-3 minutes to configure the project)

32
Step 15: Once the project is configured you can open the ‗Project Explorer‗and start exploring
the Cloudsim project. Also for the first time eclipse automatically start building the workspace
for newly configured Cloudsim project, which may take some time depending on the
configuration of the computer system.
Following is the final screen which you will see after Cloudsim is configured.

Step 16: Now just to check you within the ‗Project Explorer‗, you should navigate to the
‗examples‗ folder, then expand the package ‗[Link]‗ and double
click to open the ‗[Link]‗

33
Step 17: Now navigate to the Eclipse menu ‗Run ->Run‗ or directly use a keyboard shortcut
‘Ctrl + F11’ to execute the ‗[Link]‗.

Step 18: if is successfully executed it should be displaying the following type to output in
the console window of the Eclipse IDE.

34
Viva Questions:

1. What is GAE Launcher?


2. Why is local testing important before deployment?
3. What is localhost?
4. What port number is commonly used by GAE?
5. What happens when an application fails to start in GAE?

RESULT:
Thus the cloudsim is simulated using Eclipse Environment successfully.

35
Viva Questions and Answers:

36
Find a procedureto transferthe files from one virtualmachineto
anothervirtualmachine.
Date:

AIM:

To procedure File Transfer in Client & Server using virtual machine


Steps:
Steps to perform File Transfer in Client & Server using virtual
machine. Step 1: Open a virtual machine to do file transfer.
Step 2: Write the java program for FTP Client and FTP
Server. Step 3: Run the program.

Source Code:
[Link]

import [Link].*;
import [Link].*;
import [Link].*;
public class
FTPClient
{
public static void main(String args[])throws IOException
{
try
{
int number;
Socket s=new Socket("[Link]",10087); Scanner sc=new Scanner([Link]);
[Link]("Enter the file name:");
String fn=[Link]();

DataOutputStream dos=new DataOutputStream([Link]());

[Link](fn); DataInputStreamdis=new
DataInputStream([Link]());

String input=(String)[Link](); FileInputStream fis=new


FileInputStream(input); [Link]("Even Numbers in the" +fn+" are");

37
int i=0;{
while((i=[Link]())!=-1)
[Link]((char)i);}
[Link]();
}
catch(Exc
eption e){
[Link]("Port not available "+e);
}
}
}

[Link]

import [Link].*;
import [Link].*;
import [Link].*;
public class
FTPServer
{

public static void main ( String args[] ) throws IOException


{
Try
{
int num;
Scanner sc=new
Scanner([Link]);
ServerSocketss=new
ServerSocket(1008
7); Socket
s=[Link]();
[Link]("Waiting ");
DataInputStream
dis=new
DataInputStream([Link]());
String input=(String)[Link]();

DataOutputStream dos=new
DataOutputStream([Link]()); FileInputStream
fis = new

FileInputStream("[Link]");
FileOutputStream fos = new
FileOutputStream(input);
while((num=[Link]())!= -1)
{
if(num%2==0)
38
{ [Link](num);
}
} [Link](input);
[Link]("File is sent to client"); [Link](); [Link](); } catch(Exception e)
{
[Link]("Port not available"+e);
}
}
}
[Link]
12
3
4
56
78
9

Viva Questions:

1. What is CloudSim?
2. Why is CloudSim used instead of real cloud?
3. What is a scheduling algorithm?
4. Name any one scheduling policy in CloudSim.
5. What is the role of a datacenter in CloudSim?

RESULT:
Thus the program to the File transfer operation using virtual machine was successfully
executed and verified.
39
Viva Questions and Answers:

40
[Link] :7
Install Hadoop Single Node Cluster and Run Simple Applications
DATE : Like Word Count

AIM :
To Install Hadoop single node cluster and run simple applications like wordcount.
PROCEDURE:

1. Analyze the input file content


2. Develop the code
a. Writing a map function
b. Writing a reduce function
c. Writing the Driver class
3. Compiling the source
4. Building the JAR file
5. Starting the DFS
6. Creating Input path in HDFS and moving the data into Input path
7. Executing the program.
Open in any Browser
 Open in any Browser NameNode - [Link]
 Open in any BrowserJobTracker - [Link]
 Open hadoop/hadoop-1.2.1 create a document type something in that document
and save it as [Link]
 bin/hadoop fs -ls / o Found 1 items o drwxr-xr-x - vishal supergroup 0 2014- 04-15 01:13
/tmp
 bin/hadoop fs -mkdir example
 bin/hadoop fs -ls /user/vishal/ o Found 1 items o drwxr-xr-x - vishal
supergroup /user/vishal/example • bin/hadoop fs -copyFromLocal [Link]
/user/vishal/example
 bin/Hadoop jar [Link] wordcount /user/vishal/example/[Link] /hello
 In Eclipse New → Java Project → Provide Project Name → Next → Select Libraries →
Add Externals JARs → Go to Hadoop → hadoop-1.2.1 → select all jar files → again
click on Add ExternalJARs → go to hadoop → hadoop-
1.2.1 → lib → select all JAR files → click on Finish.
 Right Click on Src Folder → Select Class → Provide a Class name: WCE → Package
name: [Link] → Click on Finish.

41
Program: [Link] import
[Link]; import
[Link];
import [Link]; import
[Link];
[Link]; import
[Link];
import [Link]; import
[Link]; import
[Link];
import [Link];
import [Link];
public class WordCount {
public static class TokenizerMapper extends Mapper { private final
static IntWritable one = new IntWritable(1); private Text word = new
Text();
public void map(Object key, Text value, Context context ) throws IOException,
InterruptedException {
StringTokenizer itr = new StringTokenizer([Link]()); while
([Link]()) {

[Link]([Link]());
[Link](word, one); } }
}
public static class IntSumReducer extends Reducer { private
IntWritable result = new IntWritable();
public void reduce(Text key, Iterable values, Context context ) throws IOException,
InterruptedException {
int sum = 0;
for (IntWritable val : values) { sum +=
[Link]();
}
42
[Link](sum); [Link](key,
result); }
}

public static void main(String[] args) throws Exception { Configuration conf


= new Configuration();
Job job = [Link](conf, "word count");
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]); [Link]([Link]);
[Link]([Link]); [Link](job,
new Path(args[0])); [Link](job, new Path(args[1]));
[Link]([Link](true) ? 0 : 1); } }

Save the program as : [Link]

Step 1: Compile the java program

For compilation we need this [Link] file to compile the mapreduce


program. [Link]

Assuming both jar and java files in same directory run the following command to compile
root@a4cseh160:/#javac -classpath [Link] [Link]

Step 2: Create a jar file

Syntax: jar cf [Link] MainClassName*.class

Output: root@a4cseh160:/#jar cf [Link] WordCount*.class

Step 3: Make directory in hadoop file system

Syntax: hdfs dfs -mkdir directoryname

Output: root@a4cseh160:/# hdfs dfs -mkdir /user

Step 4: Copy the input file into hdfs

Syntax: hdfs dfs -put sourcefile destpath


43
Output: root@a4cseh160:/#hdfs dfs -put /[Link] /user

Step 5: To a run a program

Syntax: hadoop jar jarfilename main_class_name inputfile outputpath

Output: root@a4cseh160:/#hadoop jar [Link] WordCount


/user/[Link]/user/out
Input File: ([Link])
Cloud and Grid Lab. Cloud and Grid Lab. Cloud Lab
OUTPUT:
18 3 Cloud 3 Lab.2 Grid 2 and
Step 6:
Check the output in the Web UI at [Link] the Utilities tab select browse
file system and select the correct user. The output is available inside the output folder named user.

Step 7: To Delete an output folder


Syntax: hdfs dfs -rm -R outputpath
Output: root@a4cseh160:/#hdfs dfs -rm -R /user/[Link]

44
Viva Questions:

1. What is Hadoop?
2. What is HDFS?
3. What is MapReduce?
4. What is a single-node Hadoop cluster?
5. What does the WordCount program do?

RESULT :
Thus the implemented Map Reduce example such as Word Count program on an file
which will count the number of times a word repeats in the given file.

45
Viva Questions and Answers:

46
[Link]
Creating and Executing your first container using Docker
Date:

AIM:
To Creating and Executing your First container using Docker
PROCEDURE:
1. Docker is fast. Unlike a virtual machine, your application can start in a
few seconds and stop just as quickly.
2. Docker is multi-platform. You can launch your container on any system.
3. Containers can be built and destroyed faster than a virtual machine.
4. No more difficulties setting up your working environment. Once your Docker
is configured, you will never have to reinstall your dependencies manually again. If
you change computers or if an employee joins your company, you only have to give
them your configuration.
5. You keep your work-space clean, as each of your environments will be isolated
and you can delete them at any time without impacting the rest.
6. It will be easier to deploy your project on your server in order to put it
online. Now let’s create your first application
➢ Now that you know what Docker is, it’s time to create your first application!
➢ The purpose of this short tutorial is to create a Python program that displays
a sentence. This program will have to be launched through a Dockerfile.
➢ You will see, it’s not very complicated once you understand the process.

Note: You will not need to install Python on your computer. It will be up to the
Docker environment to contain Python in order to execute your code. 1. Install Docker
on your machine For Ubuntu:
First, update your packages:
$ sudo apt update
Next, install docker with apt-get:
$ sudo apt install [Link]
Finally, verify that Docker is installed correctly:
$ sudo docker run hello-world
• For MacOSX: you can follow this link.
• For Windows: you can follow this link
change computers or if an employee joins your company, you only have to give them your
configuration.
7. You keep your work-space clean, as each of your environments will be isolated
and you can delete them at any time without impacting the rest.
8. It will be easier to deploy your project on your server in order to put it
online. Now let’s create your first application
➢ Now that you know what Docker is, it’s time to create your first application!
➢ The purpose of this short tutorial is to create a Python program that displays
a sentence. This program will have to be launched through a Dockerfile.
➢ You will see, it’s not very complicated once you understand the process.

47
Note: You will not need to install Python on your computer. It will be up to the Docker
environment to contain Python in order to execute your code. 1. Install Docker on your
machine For Ubuntu:
First, update your packages:
$ sudo apt update
Next, install docker with apt-get:
$ sudo apt install [Link]
Finally, verify that Docker is installed correctly:
$ sudo docker run hello-world
• For MacOSX: you can follow this link.
• For Windows: you can follow this link.
1. Create your project
In order to create your first Docker application, I invite you to create a folder on your
computer. It must contain the following two files:
• A ‘[Link]’ file (python file that will contain the code to be executed).
• A ‘Dockerfile’ file (Docker file that will contain the necessary instructions
to create the environment).
Normally you should have this folder architecture: .
├── Dockerfile
└──
[Link] 0
directories, 2 files
2. Edit the Python file
You can add the following code to the ‘[Link]’ file:
#!/usr/bin/env python3 print("Docker is magic!") Nothing exceptional, but once you see “Docker is
magic!” displayed in your terminal you will know that your Docker is working.
3. Edit the Docker file Some theory: the first thing to do when you want to create your
Dockerfile is to ask yourself what you want to do. Our goal here is to launch Python
code.
➢ To do this, our Docker must contain all the dependencies necessary to launch
Python. A linux (Ubuntu) with Python installed on it should be enough.
➢ The first step to take when you create a Docker file is to access the DockerHub
website. This site contains many pre-designed images to save your time (for example: all
images for linux or code languages).
➢ In our case, we will type ‘Python’ in the search bar. The first result is the
official image created to execute Python. Perfect, we’ll use it! # A dockerfile must always
start by importing the base image.
# We use the keyword 'FROM' to do that.
# In our example, we want import the python image.
# So we write 'python' for the image name and 'latest' for the version.
FROM python:latest
# In order to launch our python code, we must import it into our
image. # We use the keyword 'COPY' to do that.
# The first parameter '[Link]' is the name of the file on the host.
# The second parameter '/' is the path where to put the file on the
image. # Here we put the file at the image root folder. COPY
[Link] /
# We need to define the command to launch when we are going to run the image.
# We use the keyword 'CMD' to do that. # The following command will execute "python
./[Link]". CMD [ "python", "./[Link]" ]

48
3. Create the Docker image
• List your images. $ docker image ls
Once your code is ready and the Dockerfile is written, all you have to do is create your image
to contain your application.
$ docker build -t python-test .
The ’-t’ option allows you to define the name of your image. In our case we have chosen ’python-
test’ but you can put what you want.

4. Run the Docker image


➢ Once the image is created, your code is ready to be launched.
➢ $ docker run python-test
➢ You need to put the name of your image after ‘docker run’.
➢ There you go, that’s it. You should normally see “Docker is magic!” displayed in your terminal.
➢ Code is available
➢ If you want to retrieve the complete code to discover it easily or to execute it, I have put
it at your disposal on my GitHub.
➔ GitHub: Docker First Application example
➢ Useful commands for Docker
➢ Before I leave you, I have prepared a list of commands that may be useful to you
on Docker. Delete a specific image.
$ docker image rm [image name]
• Delete all existing images.
$ docker image rm $(docker images -a -q)
• List all existing containers (running and not running).
$ docker ps -a
• Stop a specific container.
$ docker stop [container name]
• Stop all running containers.
$ docker stop $(docker ps -a -q)
• Delete a specific container (only if stopped).
$ docker rm [container name]
• Delete all containers (only if stopped).
$ docker rm $(docker ps -a -q)
• Display logs of a container.
$ docker logs [container name]

This is a very simple tutorial for getting started with Docker. I’ll try to keep this as simple as
possible. In this, we are going to build a basic Flask application and dockerize the
application. By the end of this tutorial, you’ll get familiar with Docker and a few Docker
commands.

49
Overview of Docker

Docker is a platform for developing and running applications. It automates the


deployment of applications. It’s a tool for running applications in an isolated
environment. Docker makes it easy to share an application with all of its dependencies
across different environments.

Docker Image

Image is a template for creating an environment. The Docker image contains


the Operating System, Software, and application code. These are all packaged
in a single file. Images are defined with the Dockerfile.

Dockerfile

Dockerfile is built into a docker image

The Dockerfile contains the steps that are needed to package your application(to
create the image). These steps include configuring the Operating system, install the
required packages or software, copy the files from one place to another.
Create the Flask application
Let’s dive into code
Flask is the micro web framework for building small web
applications.
The directory structure is as follows:
flaskapp/
├─── Dockerfile
├─── [Link]
├─── [Link]
Create a directory with the name of your choice. The command for creating a directory
in Linux is,
$mkdir flaskapp
Navigate inside the directory you created. Now create a file named [Link] and copy the following
code to it.
50
from flask import Flask app = Flask( name )@[Link]('/') def
hello_world(): return 'Hello, This is my first Docker app!'if name
== " main ": [Link](debug=True, host='[Link]')

[Link]
This is a simple Hello world Flask app. If you want to learn about flask in detail, then visit
this page and explore about flask. Let’s concentrate more on Docker now. Then create the
[Link] file. Add the following line to it.

[Link]
Now we are going to create a Dockerfile that dockerizes this application.
Flask==1.1.2
Write the Docker File
The Dockerfile should not have any extension. If you haven’t downloaded the docker yet.
Get the Docker from here. Detailed installation instructions can be found here. Create a
file called Dockerfile. This must start with capital letter D.
Dockerfile
FROM alpine:3.11RUN apk add--update pythonRUN apk add--update py-pipCOPY
./[Link]
/app/[Link] . /appWORKDIR /appRUN pip insta-
[Link] 5000CMD python [Link]
Let’s look at the instructions line by line to have a better understanding This is our base
image. There are a lot of images available in the Dockerhub. We choose alpine since it’s one
of a lightweight image. The FROM allows us to initialize the build over the base image. The
number after the colon is the version number. A valid Dockerfile always starts with FROM
keyword.
RUN apk --update add
python RUN apk add --
update py-pip
These two lines are used to install the python and the pip package respectively. The RUN
instruction will execute a new layer on top of the current image. This instruction is used to
install packages and creating new directories.
COPY ./[Link] /app/[Link] . /app
The COPY instruction is used to copy the files from source(.) to the destination(/app). The
‘.’ represents the current directory. This basically copies the flask app into the
image. WORKDIR /app
The WORKDIR sets the working
directory RUN pip install-r
[Link]
This reads the [Link] file and installs the specified packages one by one on the host
EXPOSE 5000
The EXPOSE exposes a port that is used by Flask. When you run the image you’ll get a
container that container will run on this port
CMD python [Link]
CMD is the command that is executed when you start a container. Here, you are using the
51
command to run your Python application. There can be only one CMD per Dockerfile. If

52
you specify more than one, then the last CMD will take effect. When you start a container
this command is executed. There should be only one CMD instruction in the Dockerfile. If
there is more than one, it’ll execute the last instruction.
Build the docker image
Enough of information. Let’s run the application
To build the Docker image, execute this command in the terminal in the directory we created.
$docker build -t flask-app .
The -t is used to name your image flask-app. The . , in the end, represents the current
directory. When you execute this for the first time, it’ll have to download all of the layers
that make up to build the image. After that, it’ll use the cache. If you’re not an administrator,
try to run the command with the sudo.

To run the application, execute this command $docker run -p 5000:5000 flask-app
The -p is used to map the port running inside the container to your host. Here we’re mapping
the port 5000. The value before the colon represents the port running on your host and the
value after colon represents the port running inside the container.

Now, navigate to [Link] in your browser, you’ll see the “Hello, This is my first
Docker app!” in the window.
Container

53
To know the container id enter the following command in your terminal $docker ps This lists
all the running containers in the Docker engine. This has information about containers like
its ID, created time, status and on which port it’s running. $docker ps-a This will list the
containers that have been stopped as well. $docker stop [container name] This will stop all
the running containers.

Viva Questions:

1. What is Docker?
2. What is a container?
3. Difference between container and virtual machine?
4. What is a Docker image?
5. What command is used to run a container?

RESULT:
Thus the program Creating and Executing First container using Docker is run successfully.

Viva Questions and Answers:

54
[Link]: 9 Run a container from Docker Hub
Date:

AIM:
To run a container from docker hub
PROCEDURE:
Step 1: Get the sample application. If you have git, you can clone the repository for the
sample application. ...
Step 2: Explore the Dockerfile.
... Step 3: Build your first image.
... Step 4: Run your container. ...
Step 5: Verify that your container is running.
Step 1: Sign up for a Docker account

Start bycreating a Docker ID.

A Docker ID grants you access to Docker Hub repositories and allows you to explore images that are
available from the community and verified publishers. You’ll also need a Docker ID to share images on
DockerHub.

Step 2: Create your first repository

To create a repository:

1. Sign in to Docker Hub.


2. Select Create a Repository on the Docker Hub welcome page.
3. Name it <your-username>/my-private-repo.
4. Set the visibility to Private.
5. Select Create.

You’ve created your first repository.

Step 3: Download and install Docker Desktop

You need to download Docker Desktop to build, push, and pull container images.

1. Download and install Docker Desktop.


2. Sign in to Docker Desktop using the Docker ID you created in step one.
3. Sign in to Docker Desktop using the Docker ID you created in step one.
4. Download and install Docker Desktop.
5. Sign in to Docker Desktop using the Docker ID you created in step one.

Step 4: Pull and run a container image from Docker Hub


1. In your terminal, run dockerpullhello-worldto pull the image from Docker Hub. You should
see output similar to:
55
2. :$ docker pull hello-world
3. Using default tag: lates
4. latest: Pulling from library/hello-world
5. 2db29710123e: Pullcomplete
6. Digest: sha256:7d246653d0511db2a6b2e0436cfd0e52ac8c066000264b3ce63331ac66dc a625
7. Status: Downloaded newer image for hello-world:latest
8. [Link]/library/hello-world:latest
9. Run dockerrunhello-worldto run the image locally. You should see output similar to.
10. $ docker run hello-world
11. Hello from Docker!
12. This message shows that your installation appears to be working correctly.
13. To generate this message, Docker took the following steps:
14. 1. The Docker client contacted the Docker daemon.
15. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
16. (amd64)
17. 3. The Docker daemon created a new container from that image which runs the
18. executable that produces the output you are currently reading.
19. 4. The Docker daemon streamed that output to the Docker client, which sent
20. it to your terminal.22.
21. To try something more ambitious, you can run an Ubuntu container with:
22. $ docker run -it ubuntu bash25.
23. Shareimages, automateworkflows, andmorewitha free Docker ID:
24. [Link]
25. For more examples and ideas, visit:

26. [Link]

Step 5: Build and push a container image to Docker Hub from your computer

Start by creating a Dockerfile to specify your application as shown below:

1. syntax=docker/dockerfile:1
2. FROM busybox.
3. CMD echo "Hello world! This is my first Docker image."
4. Run dockerbuild-t <your_username>/my-private-repo . to build your Docker image.
5. Run dockerrun<your_username>/my-private-repoto test your Docker image locally.
6. Run dockerpush<your_username>/my-private-repoto push your Docker image toDocker Hub.
You should see output similar to :

56
Step 6: Your repository in Docker Hub should now display a new latesttag under Tags:

You’ve successfully:

• Signed up for a Docker account


• Created your first repository
• Pulled an existing container image from Docker Hub
• Built your own container image on your computer
• Pushed it successfully to Docker Hub
57
Next steps

• Create an organization to use Docker Hub with your team.


• Automatically build container images from code through builds.
• Explore official & publisher images.
• Upgrade your subscription to push additional private Docker images to Docker Hub.
• Docker Desktop
• Docker Extensions
• Docker Engine
• Docker Build
• Docker Compose
• Docker Hub

Viva Questions:

1. What is Docker Hub?


2. What is a public Docker image?
3. What is the use of the docker pull command?
4. What happens when an image is not found locally?
5. Why should image sources be trusted?

RESULT:
Thus the Run a container from Docker Hub is run successfully and output is verified.

58
Viva Questions and Answers:

59
Content Beyond Syllabus

EX NO:10
Mount The One Node Hadoop Cluster Using FUSE
DATE:

AIM:
To implement the procedure to mount the one node Hadoop cluster using
FUSE.

PROCEDURE:

1. Main Installation # Set Hadoop-related


a. environment variables export
b. HADOOP_HOME=/usr/local/ha doop # Add Hadoop bin/
c. directory to PATH
d. export PATH= $PATH:$HADOOP_HOME/bin
2. Starting your single-node cluster hduser@ubuntu:~
a. sudo chmod -R 777 /usr/local/hadoop
3. Run the command hduser@ubuntu:~$ /usr/local/hadoop/bin/[Link]
Stopping your single-node cluster hduser@ubuntu:~$
i. /usr/local/hadoop/bin/[Link]

OUTPUT:
$ wget
[Link] repository_1.0_all.deb
$ sudo dpkg -i cdh3-repository_1.0_all.deb
$ sudo apt-get update
$ sudo apt-get install hadoop-0.20-fuse
Once fuse-dfs is installed, go ahead and mount

RESULT:
Thus the Mount The One Node Hadoop Cluster Using FUSE run successfully and
output is verified.

52

You might also like