You are on page 1of 85

JAYARAM

COLLEGE OF ENGINEERING & TECHNOLOGY


KARATAMPATTI - PAGALAVADI, TIRUCHIRAPPALLI 621 014
(Accredited by NAAC ‘B’ Grade)

DEPARTMENT OF INFORMATION TECHNOLOGY

CERTIFICATE

Certified that this is a bonfide record of practical exercises done by

Mr/Ms._____________________________ Register Number ________________________ of V Semester


rd
III Year in CSS335- CLOUD COMPUTING LABORATORY during the ODD Semester of

2023 – 2024.

HOD FACULTYINCHARGE

Submitted for the University Practical Examination held on

EXTERNAL EXAMINER INTERNAL EXAMINER


JAYARAM
COLLEGE OF ENGINEERING &TECHNOLOG
KARATAMPATTI - PAGALAVADI, TIRUCHIRAPPALLI - 621 014

(Accredited by NAAC ‘B’ Grade)

DEPARTMENT OF INFORMATION TECHNOLOGY

V – SEMESTER / III – YEAR

CSS335 – CLOUD COMPUTING LABORATORY


TABLE OF CONTENT

SNO DATE NAME OF THE EXPERIMENTS PAGE FACULTY


NO SIGN
1 Install Virtualbox/Vmware Workstation with different
flavours of linux or windows OS on top of windows7 or 8.

2 Install a C compiler in the virtual machine created using


virtual box and execute Simple Programs.

3 Install Google App Engine. Create hello world app and


other simple web applications using python/java.

4 Use GAE launcher to launch the web applications.

5 Simulate a cloud scenario using CloudSim and run a


scheduling algorithm that is not present in CloudSim.

6 Find a procedure to transfer the files from one virtual


machine to another virtual machine.

7 Install Hadoop single node cluster and run simple


applications like wordcount.

8 Creating and Executing your First container using Docker

9 Run a container from Docker Hub


Ex.No.1 Install Virtualbox/VMware Workstation with different flavours of linux or windows
OS on top of windows7 or 8. Date:

AIM:

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

PROCEDURE:

Installing Ubuntu using Oracle Virtual Box


Step1:

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 OK.The virtual

machine will be created.


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


search box 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.

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.
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.


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.
PRE LAB VIVA QUESTIONS:
1. What is meant by virtualization?
2. What does virtual machine do?
3. What is the role of VM Ware in virtual machine?
4. Is 32 bit processor supports Virtual Machine?
5. What are two components of a virtual machine?

POST LAB VIVA QUESTIONS:


1. Explain the steps to install oracle virtual box?
2. How to create two VMs on your laptop?
3. How to specify an amount of disk space to allocate for a virtual machine?
4. Specify the full names of (.iso, .rar, .nrg) files?
5. What is virtual machine and types?
MARK ALLOCATION

Details Mark Mark


Allotted Awarded

Pre Lab Questions 10


Algorithm & Logic Explanation 30
Coding 30
Execution and Output 20
Post Lab Questions (Viva) 10
Total 100
RESULT:

Thus the procedure to run different virtual machines on a single system using Oracle
Virtual Box is studied and implemented successfully.
Ex.No.2 Install a C compiler in the virtual machine created Date:
using virtual box and execute Simple Programs.

AIM:

To find a procedure to use the C compiler in the virtual machine and execute asample 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 GEDIT.It 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.


Step 4:

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

Step 5:

Type the necessary commands to compile and run the C program.


(1). cc_filename to compile the C program.
(2). ./a.out to display the output of the last compiled program.

PRE LAB VIVA QUESTIONS:

1. What is meant guest OS?


2. What is meant by host OS?
3. Why the RAM size to be allocated to your guest OS?
4. Why to provide connectivity between guest OS and host OS?
5. How to install C compiler in virtual machine?

POST LAB VIVA QUESTIONS:


1. If guest OS takes the 50% of your physical machine‘s RAM size what happens?
2. Why to create a Virtual Hard disk for your Virtual Machine?
3. What does .vdi extension file contains inside the virtual machine?
4. Define the ― Dynamically expanding disk
5. How to write C program in VirtualBox?
MARK ALLOCATION

Details Mark Mark


Allotted Awarded

Pre Lab Questions 10


Algorithm & Logic Explanation 30
Coding 30
Execution and Output 20
Post Lab Questions (Viva) 10
Total 100

RESULT:

Thus the procedure to use the C compiler in the virtual machine and execute a sample program
is implemented successfully.
Ex.No.3 Installing and Running the Google App Engine

Date: On Windows

AIM:
To Installing and Running the Google App Engine On Windows

PROCEDURE:

PROCEDURE:
Install the latest Cloud SDK version (303.0.0)
Step 1: Download the Cloud SDK installer.

(New-Object
Alternatively, open a PowerShell terminal and run the following PowerShell commands.
Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/cha
nnels/ra
pid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe")

& $env:Temp\GoogleCloudSDKInstaller.exe

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:

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.

• 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.

• 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 SDKhttps://cloud.google.com/sdk/docs

• Login to google account and verify the account with google for the successful
authentication.
• Download webapp2 module from https://pypi.org/project/webapp2/

• Write down simple hello world python program. import webapp2


class MainPage(webapp2.RequestHandler)
def get(self):
self.response.write("Hello World")

app = webapp2.WSGIApplications([('/',MainPage)], debug=True)

• Create app.yaml which has url link


• runtime: python3 api_version: 1 threadsafe: true

handlers:
-url: / script:
test.app

• Run the gcloud prompt and give Yes option to proceed further.
Install gcloud components using the command
gcloud components install cloud-datastore-emulator
PRE LAB VIVA QUESTIONS:
1. What is Google app Engine and why it is used? 2. What two
programming languages does App Engine’s tool use?
3. Do you have to use a server to upload your application?
4. What is YAML?
5. What are the main features of Google App Engine?

POST LAB VIVA QUESTIONS:


1. What are the components of Google App Engine?
2. What are two services provided by Google App Engine?
3. What are different versions of Google App Engine?
4. Is Google App Engine an API?
5. What is the difference between Google App Engine and cloud Engine?

MARK ALLOCATION

Details Mark Mark


Allotted Awarded
Pre Lab Questions 10
Algorithm & Logic Explanation 30
Coding 30

Execution and Output 20


Post Lab Questions (Viva) 10

Total 100

RESULT:

Thus the Google App Engine installed on Windows successfully and hello world app and other
simple web applications using python/java executed successfully
Google App Engine Launch the Web Applications
Ex.No : 4
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
• Django

• Pyramid

• Bottle web.py

• Tornado

Creating a website to host on Google App Engine


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

• app.yaml: 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.


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

Creating the app.yaml file

The app.yaml 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/index.html when someone
visits your website, and all static files will be stored in and called from the www directory.

Create the app.yaml file in your application's root directory:

1. Create a directory that has the same name as your project ID. You can find your project
ID in the Console.
2. In directory that you just created, create a file named app.yaml.

3. Edit the app.yaml file and add the following code to the file:
Creating the index.html 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.

<html>
<head>
<title>Hello, world!</title>
<linkrel="stylesheet"type="text/css"href="/css/style.css">

</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>
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 app.yaml file is located:

gcloud app deploy

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
To launch your browser and view the app at
https://PROJECT_ID.REGION_ID.r.appspot.com, 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.


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.
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. app.yaml

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

2. 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

3. libraries
This is where you can include external libraries to use within the webapp

main.py
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.

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:
PRELAB VIVA QUESTION

1.How do I run a web application in Google App Engine?


2.What is the application of Google App Engine?
3.Is Google App Engine a web server?
4.What is Google App Engine in AWS?
5.How many applications can I create with Google App Engine?

POST LAB VIVA QUESTION

1. What are two services provided by Google App


Engine? 2.What are the benefits of GAE?
3.What languages are supported by GAE?
4.How do I add services to Google App Engine?
5.What sort of application environment is provided by Google App Engine?

MARK ALLOCATION

Details Mark Mark


Allotted Awarded
Pre Lab Questions 10
Algorithm & Logic Explanation 30
Coding 30

Execution and Output 20


Post Lab Questions (Viva) 10

Total 100

Result :

Thus the GAE launcher to launch the Applications Successfully.

Ex.No : 5 Simulate a cloud scenario using CloudSim and run a


Date : 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 http://tinyurl.com/JNU-JAVA
• Eclipse 4.2 or above http://tinyurl.com/JNU-Eclipse
• Alternatively NetBeanshttps://netbeans.org/downloads

• Up & Running with cloudsim guide: https://goo.gl/TPL7Zh Cloudsim-
Directory structure
• cloudsim/ -- top level CloudSim directory
• docs/ -- CloudSim API Documentation
• examples/ -- CloudSim examples
• jars/ -- CloudSim jar archives
• sources/ -- CloudSim source code

Cloudsim - Layered Architecture

Cloudsim - Component model classes o
CloudInformationService.java o Datacenter.java,Host.java,Pe.java o
Vm.java,Cloudlet.java o DatacenterBroker.java
o Storage.java,HarddriveStorage.java, SanStorage.java


Cloudsim - Major blocks/Modules o org.cloudbus.cloudsim o
org.cloudbus.cloudsim.core o org.cloudbus.cloudsim.core.predicates
o org.cloudbus.cloudsim.distributions o org.cloudbus.cloudsim.lists o
org.cloudbus.cloudsim.networko
org.cloudbus.cloudsim.network.datacenter o
org.cloudbus.cloudsim.power o org.cloudbus.cloudsim.power.lists o
org.cloudbus.cloudsim.power.models o
org.cloudbus.cloudsim.provisioners
o org.cloudbus.cloudsim.util


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 Local
machine

https://www.eclipse.org/downloads/packages/release/kepler/sr1/eclipse -
ide-java-developers

Windows
Step 2: Download cloudsim-3.0.3 from git hub repository in your local machine

https://github.com/Cloudslab/cloudsim/releases/tag/cloudsim-3.0.3

Cloudsi

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

https://commons.apache.org/proper/commons-math/download_math.cgi

Commons-
maths3-
3.6.1 -bin.zip

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
Downloaded

Step 5: First of all, navigate to the folder where you have unzipped the eclipse folder and
open Eclipse.exe

Step 6: Now within Eclipse window navigate the menu: File -> New -> Project, to open the
new project wizard
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.
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 commons-math3-3.x.jar (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’ (commons-math3-3.x.jar 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 ‗Commons-math3-3.x.jar„ 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)
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 ‗org.cloudbus.cloudsim.examples‗ and double
click to open the ‗CloudsimExample1.java‗
.
Step 17: Now navigate to the Eclipse menu ‗Run ->Run‗ or directly use a keyboard shortcut
‘Ctrl + F11’ to execute the ‗CloudsimExample1.java‗.
Step 18: If it is successfully executed it should be displaying the following type to output inthe

console window of the Eclipse IDE.


PRE LAB VIVA QUESTIONS:
1. What is Cloudsim?
2. What are the features of cloudsim?
3. What are the algorithms is already installed in cloudsim?
4. Why Scheduling algorithm is implemented in cloudsim?
5. What is the purpose of cloud simulator?

POST LAB VIVA QUESTIONS:


1. Can we run any application on CloudSim simulator?
2. How to download Cloudsim?
3. Why Round Robbin algorithm is executed in cloudsim?
4. What are the requirements for CloudSim?
5. How do I install and configure CloudSim?

MARK ALLOCATION

Details Mark Mark


Allotted Awarded
Pre Lab Questions 10
Algorithm & Logic Explanation 30
Coding 30

Execution and Output 20


Post Lab Questions (Viva) 10

Total 100

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

Ex.No : 6 Find a procedure to transfer the files from one virtual machine to another
virtual machine.
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:
FTPClient.java
import java.io.*;
import java.net.*;
import java.util.*;
public class
FTPClient
{

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


{
try
{
int number;

Socket s=new Socket("127.0.0.1",10087);

Scanner sc=new Scanner(System.in);

System.out.println("Enter the file name:");

String fn=sc.next();

DataOutputStream dos=new DataOutputStream(s.getOutputStream());

dos.writeUTF(fn);
DataInputStream dis=new DataInputStream(s.getInputStream());
String input=(String)dis.readUTF();
FileInputStream fis=new FileInputStream(input);

System.out.println("Even Numbers in the" +fn+"

are"); int i=0;


{

while((i=fis.read())!=-1)

System.out.println((char)i);

}
s.close();
}
catch(Exception e){
System.out.println("Port not available "+e);
}
}
}

FTPServer.java
import java.io.*; import
java.net.*; import
java.util.*; public class
FTPServer
{

public static void main


(

String args[]
)

throws IOException
{

Try
{
int num;

Scanner sc=new Scanner(System.in);


ServerSocket ss=new ServerSocket(10087);
Socket s=ss.accept();

System.out.println("Waiting ..... ");


DataInputStream dis=new DataInputStream(s.getInputStream());

String input=(String)dis.readUTF();

DataOutputStream dos=new DataOutputStream(s.getOutputStream());


FileInputStream fis = new FileInputStream("out.txt");

FileOutputStream fos = new FileOutputStream(input);

while((num=fis.read())!= -1)
{
if(num%2==0)
{ fos.write(num);
}
} dos.writeUTF(input); System.out.println("File
is sent to client");
ss.close(); s.close(); } catch(Exception e)
{
System.out.println("Port not available"+e);
}
}
}

Out.txt
1
2
3
4
5
6
7
8
9

Output:
PRELAB VIVA QUESTION
1. How to transfer the files from one virtual machine to another virtual machine?
2. How to copy files from one virtual machine to another in Linux?
3. How do I transfer a virtual machine to another computer using VMware?
4. How to transfer files from host to virtual machine in VirtualBox?
5. How to copy files from local machine to VMware virtual machine?

POST LAB VIVA QUESTION

1. How to transfer file from Linux to Linux command?


2. How do I copy a folder from Windows to a virtual machine?
3. How do I transfer files between VM and host in Hyper V?
4. How to export files from Oracle VM VirtualBox?
5. How do I upload files from local to virtual machine?

MARK ALLOCATION

Details Mark Mark


Allotted Awarded
Pre Lab Questions 10
Algorithm & Logic Explanation 30
Coding 30

Execution and Output 20


Post Lab Questions (Viva) 10

Total 100

Result:
Thus the program to the File transfer operation using virtual machine was successfully executed
and verified.
Ex.No :7 Install Hadoop single node cluster and run simple applications like Word count

Date :

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 - http://localhost:50070/
• Open in any Browser JobTracker - http://localhost:50030/
• Open hadoop/hadoop-1.2.1 create a document type something in that document and save it as test.txt
• 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 test.txt /user/vishal/example
• bin/hadoop jar hadoop-examples-1.2.1.jar wordcount /user/vishal/example/test.txt /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 External
→ → → → →
JARs 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: com.WordCount.Example Click on Finish.
Program: WordCount.java
import java.io.IOException; import java.util.StringTokenizer;

import org.apache.hadoop.conf.Configuration; import

org.apache.hadoop.fs.Path;

importorg.apache.hadoop.io.IntWritable;import

org.apache.hadoop.io.Text; import

org.apache.hadoop.mapreduce.Job; import

org.apache.hadoop.mapreduce.Mapper; import

org.apache.hadoop.mapreduce.Reducer; import

org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import

org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public

class WordCount { public static class TokenizerMapper

extends Mapper<Object, Text, Text, IntWritable>


{ 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(value.toString());

while (itr.hasMoreTokens()) {

word.set(itr.nextToken());

context.write(word, one);

public static class IntSumReducer

extends Reducer<Text,IntWritable,Text,IntWritable> { private

IntWritable result = new IntWritable();

public void reduce(Text key, Iterable<IntWritable> values,


Context context

) throws IOException, InterruptedException {

int sum = 0; for (IntWritable val : values) { sum +=

val.get();

result.set(sum);

context.write(key, result);

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

{ Configuration conf = new Configuration(); Job

job = Job.getInstance(conf, "word count");

job.setJarByClass(WordCount.class);

job.setMapperClass(TokenizerMapper.class);

job.setCombinerClass(IntSumReducer.class);

job.setReducerClass(IntSumReducer.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(IntWritable.class);

FileInputFormat.addInputPath(job, new Path(args[0]));

FileOutputFormat.setOutputPath(job, new Path(args[1]));

System.exit(job.waitForCompletion(true) ? 0 : 1);

Save the program as

WordCount.java

Step 1: Compile the java program


For compilation we need this hadoop-core-1.2.1.jar file to compile the mapreduce program.

https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-core/1.2.1

Assuming both jar and java files in same directory run the following command to compile

root@a4cseh160:/#javac -classpath hadoop-core-1.2.1.jar WordCount.java Step 2:

Create a jar file

Syntax:

jar cf jarfilename.jar MainClassName*.class

Output:

root@a4cseh160:/#jar cf wc.jar 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

Output:

root@a4cseh160:/#hdfs dfs -put /input.txt /user


Step 5: To a run a program

Syntax:

hadoop jar jarfilename main_class_name inputfile outputpath

Output:

root@a4cseh160:/#hadoop jar wc.jar WordCount /user/input.txt /user/out

Input File: (input.txt)


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 http://localhost:50070.In 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/out.txt

PRELAB VIVA QUESTION

1. How many data nodes can run on a single Hadoop cluster?


2. How to install and setup Hadoop cluster?
3. Which mode a single node cluster is said to be in Hadoop?
4. What is the minimum number of nodes for Hadoop cluster?
5. How to find number of nodes in Hadoop cluster?
POST LAB VIVA QUESTION

1. What is the size of Hadoop cluster?


2. How to calculate cluster size in Hadoop?
3. What is the formula for cluster size?
4. What is single node and multi node?
5. What is the simplest clustering method?

MARK ALLOCATION

Details Mark Mark


Allotted Awarded

Pre Lab Questions 10


Algorithm & Logic Explanation 30
Coding 30
Execution and Output 20
Post Lab Questions (Viva) 10
Total 100

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.

EXNO:8

DATE: Creating and Executing your First container using Docker

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 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 docker.io
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.

2. 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 ‘main.py’ 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
└── main.py
0 directories, 2 files
3. Edit the Python file
You can add the following code to the ‘main.py’ 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 'main.py' 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 main.py /

# 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 ./main.py".
CMD [ "python", "./main.py" ]
4. Create the Docker image
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.

5. 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.
• List your images.
$ docker image ls
• 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.


Docker man page
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
├─── app.py
├─── requirements.txt
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 app.py and copy the following code to it.

app.py
from flask import Flask app = Flask(__name__)@app.route('/') def
hello_world(): return 'Hello, This is my first Docker app!'if
__name__ == "__main__": app.run(debug=True, host='0.0.0.0')

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 requirements.txt file.

Add the following line to it.

requirements.txt

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 ./requirements.txt
/app/requirements.txtCOPY . /appWORKDIR /appRUN pip install-rrequirements.txtEXPOSE
5000CMD python app.py

Let’s look at the instructions line by line to have a better


understanding FROM alpine:3.11
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 ./requirements.txt /app/requirements.txtCOPY . /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 requirements .txt

This reads the requirements.txt 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 app.py
CMD is the command that is executed when you start a container. Here, you are using the command to run

your Python application. There can be only one CMD per Dockerfile. If 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.

docker build log

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 http://localhost:5000/ in your browser, you’ll see the “Hello, This is my first Docker
app!” in the window.

Container

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.


PRELAB VIVA QUESTION
1. How do I run the first docker container?
2. How do I make sure docker container is running 3. What is the command to
create and run docker container?
4. How to create a container using docker?
5. How do I create a first Dockerfile?

POST LAB VIVA QUESTION


1. How do I know if docker is successfully installed?
2. Which command is used for checking running docker containers?
3. How do I run a docker image?
4. What is docker run option?
5. Can we create container without docker?

MARK ALLOCATION

Details Mark Mark


Allotted Awarded
Pre Lab Questions 10

Algorithm & Logic Explanation 30


Coding 30
Execution and Output 20
Post Lab Questions (Viva) 10
Total 100

Result
Thus the program Creating and Executing First container using Docker is run successfully

EXNO: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

by creating 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
Docker Hub.

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.

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

1. In your terminal, run docker pull hello-world to pull the image from Docker Hub.
You should see output similar to:
2. $ docker pull hello-world

3. Using default tag: latest


4. latest: Pulling from library/hello-world

5. 2db29710123e: Pull complete

6. Digest:
sha256:7d246653d0511db2a6b2e0436cfd0e52ac8c066000264b3ce63331ac6
6dc a625

7. Status: Downloaded newer image for hello-world:latest

8. docker.io/library/hello-world:latest

9. Run docker run hello-world to 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.

14. To generate this message, Docker took the following steps:

15. 1. The Docker client contacted the Docker daemon.

16. 2. The Docker daemon pulled the "hello-world" image from the
Docker Hub.

17. (amd64)

18. 3. The Docker daemon created a new container from that image
which runs the

19. executable that produces the output you are currently reading.

20. 4. The Docker daemon streamed that output to the Docker client,
which sent

21. it to your terminal.

22.

23. To try something more ambitious, you can run an Ubuntu


container with:

24. $ docker run -it ubuntu bash

25.

26. Share images, automate workflows, and more with a free Docker ID:

27. https://hub.docker.com/
28. For more examples and ideas, visit:

29. https://docs.docker.com/get-started/

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

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

2. # syntax=docker/dockerfile:1

3. FROM busybox

4. CMD echo "Hello world! This is my first Docker image."

5. Run docker build -t <your_username>/my-private-repo . to build your Docker


image.
6. Run docker run <your_username>/my-private-repo to test your Docker image locally.
7. Run docker push <your_username>/my-private-repo to push your Docker image
to Docker Hub. You should see output similar to:
Note

You must be signed in to Docker Hub through Docker Desktop or the command line, and you must
also name your images correctly, as per the above steps.

8. Your repository in Docker Hub should now display a new latest tag 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

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

PRELAB VIVA QUESTION


1. How do I create a new docker image?
2. What is run command in Dockerfile?
3. How to create a Dockerfile?
4. Which command is used to create a docker image from a Dockerfile?
5. How do I check docker container status?

POST LAB VIVA QUESTION

1. How to install docker and run?


2. What is the Docker process?
3. What is docker and its command?
4. How do I start and stop a docker container?
5. How to connect a docker container?

MARK ALLOCATION

Details Mark Mark


Allotted Awarded

Pre Lab Questions 10


Algorithm & Logic Explanation 30
Coding 30
Execution and Output 20
Post Lab Questions (Viva) 10
Total 100
Result
Thus the Run a container from Docker Hub is run successfully and output is verified

You might also like