Cloud Lab Record 1
Cloud Lab Record 1
NAME: ..……………….....
YEAR:……………………
DEPT: …......……………..
GOVERNMENT COLLEGE OF ENGINEERING,
TIRUNELVELI - 627 007
2022 - 2023
Register Number:
CERTIFICATE
Place: Tirunelveli
Date:
Ex
Date Name of the Experiment Page No Signature
No
1 Study of Virtualization 1
2 Installing VMware Workstation 5
Installing C Compiler in Virtual
3 8
Machine
Creating Web Applications using
4 13
Google App Engine
5 Simulation of SJF Scheduling 20
Algorithm in CloudSim
File Sharing between Physical and
6 54
Virtual Machine
Launching Virtual Machine using
7 61
TryStack
Installing Hadoop Single Node
8 Cluster and running simple 66
applications like Word Count
Ex:No.1 STUDY OF VIRTUALIZATION
VIRTUALIZATION
Virtualization uses software to create an abstraction layer
over computer hardware that allows the hardware elements of a single
computer—processors, memory, storage and more—to be divided into
multiple virtual computers, commonly called virtual machines (VMs).
Each VM runs its own operating system (OS) and behaves like an
independent computer, even though it is running on just a portion of the
actual underlying computer hardware.
VIRTUAL MACHINE
A virtual machine, commonly shortened to just VM, is no
different than any other physical computer like a laptop, smart phone or
server. It has a CPU, memory, disks to store your files and can connect
to the internet if needed. While the parts that make up your computer
(called hardware) are physical and tangible, VMs are often thought of as
virtual computers or software-defined computers within physical servers,
existing only as code.
TYPES OF VIRTUALIZATION
Application virtualization
Network virtualization
Desktop virtualization
Storage virtualization
Server virtualization
Data virtualization
1
APPLICATION VIRTUALIZATION
NETWORK VIRTUALIZATION
DESKTOP VIRTUALIZATION
STORAGE VIRTUALIZATION
2
SERVER VIRTUALIZATION
DATA VIRTUALIZATION
VIRTUALIZATION
SOFTWARE VMware
Xen
VIRTUAL BOX
VirtualBox is open-source software for virtualizing the x86
computing architecture. It acts as a hypervisor, creating
a VM (virtual machine) where the user can run another OS (operating
system).The operating system where VirtualBox runs is called the "host"
OS. The operating system running in the VM is called the "guest" OS.
VirtualBox supports Windows, Linux, or macOS as its host OS. When
configuring a virtual machine, the user can specify how many CPU
cores, and how much RAM and disk space should be devoted to the VM.
RESULT
The concept of virtualization has been studied and
written successfully.
4
Ex:No.2 Installing VMware Workstation
AIM
PROCEDURE
6. In the End User Licence Agreement dialog box, check “I accept the
terms in the Licence Agreement” box and press next to continue.
5
7. Select the folder in which you would like to install the application.
Also select Enhanced Keyboard Driver check box.
8. Select “Check for Updates” and “Help improve VMware
Workstation Pro”.
9. Select the place you want the shortcut icons to be placed on your
system to launch the application. Select both the options, desktop
and start menu and click next.
10. Click install to start the installation process.
11. In installation complete dialog box, Click finish.
12. The VMware Workstation is now installed.
6
RESULT:
7
Ex:No.3 Installing C compiler in the virtual machine
AIM
To Install a C compiler in the virtual machine using the virtual
box and execute simple programs.
PROCEDURE
Step 1: Open Terminal (Applications-Accessories-Terminal).
8
Step 2: Open gedit by typing “gedit &” on terminal (You can also use
any other Text Editor application).
Step 3: Type the following on gedit (or any other text editor)
#include<stdio.h>
int main()
{
printf("Hello World\n");
}
9
Step 4: Save this file as “hellworld.c”.
Step 5: Type “ls” on Terminal to see all files under current folder.
10
Step 7: Type “gcc helloworld.c” to compile, and type “ls” to
conform that a new executable file “a.out” is created.
Step 9: If you see “Hello World” on the next line, you just
successfully ran your first C program.
11
Result
Thus the C program was compiled and execute in virtual
machine.
12
Ex.No:4 Creating Web Applications Using Google App Engine
AIM
To install Google App Engine and create hello world app and
other simple web applications using Python.
PROCEDURE
Downloading and Installing of GAE – Standard environment and
Python
1. Go to https://cloud.google.com/appengine/docs
14
15
16
9. Login in gloud and get authenticated (which will be opened in the
browser).
10. Download Python 2.7 from python.org and install
Project Creation
1. Create a folder with name of your choice (my_project)
17
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /
script: index.py (two spaces before script:index.py)
4. Open cloud SDK by giving run as administrator and run the yaml file
app.yaml by giving the following command and give the path of the
application within double quotation: Google-cloud-sdk\bin\dev-
appserver.py “myproject/app.yaml”.
18
RESULT
Thus Web Application using python program was created
and executed using Google App Engine.
19
Ex:No.5 SIMULATION OF SJF SCHEDULING
ALGORITHM IN CLOUDSIM
AIM
To simulate a cloud scenario using CloudSim and run a
scheduling algorithm that is not present in CloudSim.
PROCEDURE
1. Download CloudSim installable files
from https://code.google.com/p/cloudsim/downloads/list and unzip.
2. Open Eclipse.
8. The fourth step is to create one virtual machine unique ID of the VM,
userId ID of the VM’s owner, mips, number Of Pes amount of CPUs,
amount of RAM, amount of bandwidth, amount of storage, virtual
machine monitor, and cloudletScheduler policy for cloudlets:
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size,
vmm, new
CloudletSchedulerTimeShared())
10. Create a cloudlet with length, file size, output size, and utilisation
model:
Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel,
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
21
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
22
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
public class Simulation {
24
return list;
}
////////////////////////// STATIC METHODS ///////////////////////
Datacenter datacenter1 =
createDatacenter("Datacenter_1");
DatacenterBroker broker =
createBroker();
int brokerId = broker.getId();
vmlist = createVM(brokerId,10);
//creating 20 vms
cloudletList = createCloudlet(brokerId,40); // creating
40 cloudlets
broker.submitVmList(vmlist);
25
broker.submitCloudletList(cloudletList);
CloudSim.startSimulation();
// Final step: Print results when simulation is over
List<Cloudlet> newList =
broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList)
//Print the debt of each user to each
datacenter //datacenter0.printDebts();
//datacenter1.printDebts();
Log.printLine("CloudSimExample6 finished!");
}
catch (Exception e)
{
e.printStackTrace();
Log.printLine("The simulation has been terminated due
to an unexpected error");
}
}
26
private static Datacenter createDatacenter(String name)
{ List<Host> hostList = new
ArrayList<Host>();
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList2,
new VmSchedulerTimeShared(peList2)
)
);
//hostList.add(
new Host(
hostId,
new CpuProvisionerSimple(peList1),
new RamProvisionerSimple(ram),
28
new BwProvisionerSimple(bw),
storage,
new VmSchedulerSpaceShared(peList1)
)
);
29
String vmm = "Xen";
double time_zone = 10.0; // time zone this resource located
{ e.printStackTrace(
);
}
return datacenter;
30
}
private static DatacenterBroker createBroker(){
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e)
{ e.printStackTrace(
); return null;
}
return broker;
}
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
String indent = " ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent
+
"Data center ID" + indent + "VM ID" + indent +
indent + "Time" + indent + "Start Time" + indent + "Finish Time"
+indent+"user id"+indent);
31
DecimalFormat dft = new DecimalFormat("###.##");
for (int i = 0; i < size; i++) {
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent +
indent);
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS)
{
Log.print("SUCCESS");
Log.printLine( indent + indent +
cloudlet.getResourceId() + indent + indent + indent + cloudlet.getVmId()
+ indent + indent + indent + dft.format(cloudlet.getActualCPUTime())
+indent + indent + dft.format(cloudlet.getExecStartTime())+ indent +
indent + indent + dft.format(cloudlet.getFinishTime())+indent
+cloudlet.getUserId());
}
}
}
}
32
DatacenterBroker.java:
package taskchpack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.core.CloudSimTags;
import org.cloudbus.cloudsim.core.SimEntity;
import org.cloudbus.cloudsim.core.SimEvent;
import org.cloudbus.cloudsim.lists.CloudletList;
import org.cloudbus.cloudsim.lists.VmList; public
class DatacenterBroker extends SimEntity {
33
protected List<? extends Cloudlet>
cloudletSubmittedList; protected List<? extends
Cloudlet> cloudletReceivedList; protected int
cloudletsSubmitted; protected int vmsRequested;
protected int vmsAcks;
protected int vmsDestroyed;
protected List<Integer> datacenterIdsList;
protected List<Integer> datacenterRequestedIdsList;
protected Map<Integer, Integer> vmsToDatacentersMap;
setCloudletReceivedList(new ArrayList<Cloudlet>());
cloudletsSubmitted = 0;
setVmsRequested(0);
setVmsAcks(0);
34
setVmsDestroyed(0);
setDatacenterIdsList(new LinkedList<Integer>());
setDatacenterRequestedIdsList(new ArrayList<Integer>());
setVmsToDatacentersMap(new HashMap<Integer,
Integer>());
setDatacenterCharacteristicsList(new HashMap<Integer,
DatacenterCharacteristics>());
}
}
@Override
public void processEvent(SimEvent ev) {
switch (ev.getTag()) {
35
case
CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST:
processResourceCharacteristicsRequest(ev);
break;
case
CloudSimTags.RESOURCE_CHARACTERISTICS:
processResourceCharacteristics(ev);
break;
case CloudSimTags.VM_CREATE_ACK:
processVmCreate(ev);
break;
case CloudSimTags.CLOUDLET_RETURN:
processCloudletReturn(ev);
break;
// if the simulation finishes
case CloudSimTags.END_OF_SIMULATION:
shutdownEntity();
break;
/ other unknown tags are processed by this
method default:
processOtherEvent(ev);
36
break;
}
}
protected void processResourceCharacteristics(SimEvent ev) {
DatacenterCharacteristics characteristics =
(DatacenterCharacteristics) ev.getData();
getDatacenterCharacteristicsList().put(characteristics.getId(),
characteristics);
if (getDatacenterCharacteristicsList().size() ==
getDatacenterIdsList().size()) {
setDatacenterRequestedIdsList(new
ArrayList<Integer>());
createVmsInDatacenter(getDatacenterIdsList().get(0));
}
}
protected void processResourceCharacteristicsRequest(SimEvent
ev) {
setDatacenterIdsList(CloudSim.getCloudResourceList());
setDatacenterCharacteristicsList(new HashMap<Integer,
DatacenterCharacteristics>());
37
Log.printLine(CloudSim.clock() + ": " + getName() + ":
Cloud Resource List received with "
+ getDatacenterIdsList().size() + " resource(s)");
{ getVmsToDatacentersMap().put(vmId,
datacenterId);
getVmsCreatedList().add(VmList.getById(getVmList(), vmId));
Log.printLine(CloudSim.clock() + ": " + getName() + ":
VM #" + vmId
+ " has been created in Datacenter #" +
datacenterId + ", Host #"
38
+ VmList.getById(getVmsCreatedList(),
vmId).getHost().getId());
} else {
Log.printLine(CloudSim.clock() + ": " + getName() + ":
Creation of VM #" + vmId + " failed in Datacenter #" + datacenterId);
}
incrementVmsAcks();
if (getVmsCreatedList().size() == getVmList().size() -
getVmsDestroyed()) {
submitCloudlets();
} else {
if (getVmsRequested() == getVmsAcks()) {
// find id of the next datacenter that has not been
tried
for (int nextDatacenterId : getDatacenterIdsList())
{
if
(!getDatacenterRequestedIdsList().contains(nextDatacenterId)) {
createVmsInDatacenter(nextDatacenterId);
return;
}
}
39
// all datacenters already queried
if (getVmsCreatedList().size() > 0) { // if some vm
were created
submitCloudlets();
40
if (getCloudletList().size() == 0 && cloudletsSubmitted ==
0) { // all cloudlets executed
Log.printLine(CloudSim.clock() + ": " + getName() + ":
All Cloudlets executed. Finishing...");
clearDatacenters();
finishExecution();
} else { // some cloudlets haven't finished yet
if (getCloudletList().size() > 0 && cloudletsSubmitted
==0){
// all the cloudlets sent finished. It means that some
bount
}
}
41
Log.printLine(getName() + ".processOtherEvent(): " +
"Error - an event is null.");
return;
}
String datacenterName =
CloudSim.getEntityName(datacenterId);
for (Vm vm : getVmList()) {
if
(!getVmsToDatacentersMap().containsKey(vm.getId())) {
42
requestedVms++;
}
}
getDatacenterRequestedIdsList().add(datacenterId);
setVmsRequested(requestedVms); setVmsAcks(0);
}
protected void submitCloudlets() {
int vmIndex = 0;
{
Cloudlet smallestCloudlet= tempList.get(0);
for(Cloudlet checkCloudlet: tempList)
43
{
if(smallestCloudlet.getCloudletLength()>checkCloudlet.getCloudl
etLength())
{
smallestCloudlet= checkCloudlet;
}
}
sortList.add(smallestCloudlet);
tempList.remove(smallestCloudlet);
}
int count=1;
for(Cloudlet printCloudlet: sortList)
{
Log.printLine(count+".Cloudler
Id:"+printCloudlet.getCloudletId()+",Cloudlet
Length:"+printCloudlet.getCloudletLength());
count++;
}
for (Cloudlet cloudlet : sortList) {
Vm vm;
44
// if user didn't bind this cloudlet and it has not been
executed yet
if (cloudlet.getVmId() == -1) {
vm = getVmsCreatedList().get(vmIndex);
} else { // submit to the specific vm
vm = VmList.getById(getVmsCreatedList(),
cloudlet.getVmId());
if (vm == null) { // vm was not created
Log.printLine(CloudSim.clock() + ": " +
getName() + ": Postponing execution of cloudlet "+
cloudlet.getCloudletId() + ": bount VM not available");
continue;
}
}
Log.printLine(CloudSim.clock() + ": " + getName()
+ ": Sending cloudlet " + cloudlet.getCloudletId() + " to VM #"
+ vm.getId());
cloudlet.setVmId(vm.getId());
sendNow(getVmsToDatacentersMap().get(vm.getId()),
CloudSimTags.CLOUDLET_SUBMIT, cloudlet);
cloudletsSubmitted++;
vmIndex = (vmIndex + 1) %
getVmsCreatedList().size();
45
getCloudletSubmittedList().add(cloudlet);
}
getVmsCreatedList().clear();
}
protected void finishExecution() {
sendNow(getId(), CloudSimTags.END_OF_SIMULATION);
}
@Override
public void shutdownEntity() {
46
Log.printLine(getName() + " is shutting down...");
}
@Override
public void startEntity()
{ Log.printLine(getName() + " is
starting...");
schedule(getId(), 0,
CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST);
}
@SuppressWarnings("unchecked")
48
}
49
return vmsDestroyed;
}
51
OUTPUT
Starting CloudSimExample1...
Initialising...
Starting CloudSim version 3.0
Datacenter_0 is starting...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>null
Broker is starting...
Entities started.
: Broker: Cloud Resource List received with 1 resource(s)
0.0: Broker: Trying to Create VM #0 in Datacenter_0
: Broker: VM #0 has been created in Datacenter #2, Host
#0 0.1: Broker: Sending cloudlet 0 to VM #0
400.1: Broker: Cloudlet 0 received
400.1: Broker: All Cloudlets executed. Finishing...
400.1: Broker: Destroying VM
#0 Broker is shutting down...
Simulation: No more future events
CloudInformationService: Notify all CloudSim entities for shutting
down. Datacenter_0 is shutting down...
Broker is shutting down...
Simulation completed.
Simulation completed.
========== OUTPUT ==========
Cloudlet ID STATUS Data center ID VM ID Time Start Time Finish
Time
0 SUCCESS 2 0 400 0.1 400.1
*****Datacenter:
Datacenter_0***** User id Debt
3 35.6
CloudSimExample1 finished!
52
RESULT
Thus a cloud scenario was simulated using CloudSim and a scheduling
algorithm that is not present in CloudSim was executed successfully.
53
Ex:No.6 FILE SHARING BETWEEN PHYSICAL
MACHINE AND VIRTUAL MACHINE
AIM:
To share files between physical machine and virtual machine.
PROCEDURE:
54
4. Open VMware workstation and go to VM tab and click install
VMware tools.
If install VMWare tools are grayed out,then follow the steps.
56
11.Power off the vitual machine and power on.To check whether the
VMWare tools are installed , open the terminal enter the command $ vmware-
toolbox-cmd --version
12.Follow the commands to share the files between physical and virtual layer
$vmaware-hgfsclient
$cd /mnt
57
$cd hgfs/
$ls using this command check whether your file is there.
58
RESULT:
Thus the file is shared between physical and virtual machine.
59
Ex:No.7 Launching Virtual Machine Using TryStack
AIM
To find a procedure to launch virtual machine using TryStack.
PROCEDURE
Step 1: Create Network
1. Go to Network > Networks and then click Create Network.
2. In Network tab, fill Network Name for example internal
and then click Next.
3. In Subnet tab,
1. Fill Network Address with appropriate CIDR, for
example 192.168.1.0/24. Use private network CIDR
block as the best practice.
2. Select IP Version with appropriate IP version, in this
case IPv4.
3. Click Next.
4. In Subnet Details tab, fill DNS Name Servers with 8.8.8.8
(Google DNS) and then click Create.
Step 2: Create Instance
1. Go to Compute > Instances and then click Launch Instance.
2. In Details tab,
ample
1. Fill Instance Name, for e Ubuntu 1.
2. Select Flavor, for example m1.medium.
3. Fill Instance Count with 1.
4. Select Instance Boot Source with Boot from Image.
5. Select Image Name with Ubuntu 14.04 amd64 (243.7
MB) if you want install Ubuntu
60
14.04 in your virtual machine.
3. In Access & Security tab,
1. Click [+] button of Key Pair to import key pair. This key pair
is a public and private key that we will use to connect to the
instance from our machine.
2. In Import Key Pair dialog,
1. Fill Key Pair Name with your machine name (for
example Edward-Key).
2. Fill Public Key with your SSH public key (usually is
in ~/.ssh/id_rsa.pub). See description in Import Key
Pair dialog box for more information. If you are using
Windows, you can use Puttygen to generate key pair.
3. Click Import key pair.
3. In Security Groups, mark/check default.
4. In Networking tab,
1. In Selected Networks, select network that have been
created in Step 1, for example internal.
5. Click Launch.
6. If you want to create multiple instances, you can repeat
step 1-5. I created one more instance with instance name
Ubuntu 2.
Step 3: Create Router
1. Go to Network > Routers and then click Create Router.
2. Fill Router Name for router and then click Create router.
example
3. Click on your router name link, for example router1, Router Details page.
4. Click Set Gateway button in upper right:
1. Select External networks with external.
2. Then OK.
5. Click Add Interface button.
1. Select Subnet with the network that you have been created in
Step 1.
61
2. Click Add interface.
6. Go to Network > Network Topology. You will see the
network topology. In the example, there are two network,
i.e. external and internal, those are bridged by a router.
There are instances those are joined to internal network.
62
Now, you can SSH your instances to the floating IP
address that you got in the step 4. If you are using Ubuntu
image, the SSH user will be ubuntu.
OUTPUT
63
RESULT
Thus a procedure to launch virtual machine using TryStack was
written successfully.
64
Ex:No.8 INSTALLING HADOOP SINGLE NODE CLUSTER
LIKE WORDCOUNT
AIM
To find procedure to set up the one node Hadoop cluster and run
simple applications like wordcount.
PROCEDURE
Step 1: Installing Java is the main prerequisite for Hadoop. Install java16
and set the path for the JAVA_HOME environment variable.
Step 2: Install Apache Hadoop 3.1.0 for windows and Hadoop 3.1.0.
Step 3: Replace bin in Hadoop 3.1.0 by Apache Hadoop (rename original bin
in Hadoop to bin1 and then copy bin to it).
Step 8: Add Client libraries jars and map-reduce jars(except examples jar)
using the build path option.
65
Step 11: Execute the Jar File in the cmd using the command.
( hadoop jar <filename.jar> <inputdir> <outputdir>)
Step 12: Execute the Hadoop program using(hdfs dfs -cat
<outputdir>/* ).
Program
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
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.input.FileOuputFormat;
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, Textvalue, Context
context) throws IOException, InterruptedException{
66
StringTokenizer itr = new StringTokenizer(value.toStri
ng());
while (itr.hasMoreTokens()){
word.set(itr.nextToken());
output.collect(word, one);
}
}
}
67
Job.setMapperClass(TokenixerMapper.Class);
Job.setCombinerClass(IntSumReducer.Class);
Job.setReducerClass(IntSumReducer.Class);
Job.setOutputKeyClass(Text.Class);
Job.OutputValueClass(IntWritable.Class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.addOutputPath(job, new Path(args[1]));
System.exit(job. waitForCompletion(true)?0:1);
}
}
68
Output
69
RESULT
Thus, the set up the one node Hadoop cluster and the number of
words were counted successfully.
70
71