Jerusalem College of Engineering: ACADEMIC YEAR 2021 - 2022
Jerusalem College of Engineering: ACADEMIC YEAR 2021 - 2022
Name……………………………………………………………………………………
Year…………………………………Semester………………Branch……………….
Regulation………………..
Register No.
Certified that this is a Bonafide Record work done by the above student in the
EXAMINERS
DATE:
L T P C
JCS1412 OPERATING SYSTEMS LABORATORY 0 0 4 2
SYLLABUS
COURSE OBJECTIVES:
To Develop web application in cloud
To learn the design and development process involved in creating a cloud based application
To learn to implement and use parallel programming using Hadoop.
To learn to setup a instance , monitor , allocate and configure the compute Engines in cloud
LIST OF EXPERIMENTS
1. Install Virtual box/VMware Workstation with different flavors 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 Cloud Sim and run a scheduling algorithm that is not present
in Cloud Sim.
6. Find a procedure to transfer the files from one virtual machine to another virtual machine.
7. Find a procedure to launch virtual machine using try stack (Online Open stack Demo
Version).
8. Install Hadoop single node cluster and run simple applications like word count.
LIST OF EXPERIMENTS
CYCLE 1
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.
CYCLE 2
5. Simulate a cloud scenario using Cloud Sim and run a scheduling algorithm that is
not present in Cloud Sim.
6. Find a procedure to transfer the files from one virtual machine to anothervirtual
machine.
7. Find a procedure to launch virtual machine using try stack (Online Open stack Demo
Version).
8. Install Hadoop single node cluster and run simple applications like word count.
ADDITIONAL EXPERIMENTS
CONTENTS
Average Marks :
Signature :
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
Mandatory Prerequisite:
1. Linux 64 bit Operating System (The commands mentioned are for Linux Operating System latest
version).
INSTALLATION OF PACKAGES
uname -m
If the result is x86_64, it means that your Operating system is 64 bit Operating system.
ls /lib/modules/{press tab}/kernel/arch/x86/kvm
The three files which are installed in your system will be displayed
kvm-amd.ko kvm-intel.ko kvm.ko
sudo -i
1
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
Id Name State
If VMs are running, then it shows name of VM. If VM is not running, the system shows blank output,
whcih means your KVM installation is perfect.
8. To test KVM installation - we can create Virtual machines but these machines are to be done in
manual mode. Skipping this, Directly install Openstack.
Installation of Openstack
1. add new user named stack – This stack user is the adminstrator of the openstack services.
adduser stack
3. Be careful in running the command – please be careful with the syntax. If any error in thsi following
command, the system will crash beacause of permission errors.
8. In the file, make the following entry (Contact Your Network Adminstrator for doubts in these values)
[[local|localrc]]
FLOATING_RANGE=192.168.1.224/27
FIXED_RANGE=10.11.11.0/24
FIXED_NETWORK_SIZE=256
FLAT_INTERFACE=eth0
ADMIN_PASSWORD=root
DATABASE_PASSWORD=root
RABBIT_PASSWORD=root
SERVICE_PASSWORD=root
SERVICE_TOCKEN=root
3
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
12. Open the browser, http://IP address of your machine, you will get the openstack portal.
13. If you restart the machine, then to again start open stack
open terminal,
su stack
cd devstack
run ./rejoin.sh
14. Again you can access openstack services in the browser, http://IP address of your machine,
4
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
PROCEDURE :
This experiment is to be performed through portal, install virtual machines.
TO INSTALL VM
Step 1 : After clicking on the setup so click on the Yes button..
Step 2 : Setup Wizard: then the setup wizard will install the VMware Workstation Pro on your
system so click Next to go ahead and click Exit to cancel the installation.
Step 3: End-User License Agreement: in this step accept the terms in the license agreement and
click on the Next button
Step 4: Custom Setup: select the folder in which you would like to install the VMware application.
and besides that select enhanced keyboard driver
Step 5: User Experience Setting: select both options but you can uncheck it, so I leave it as
default and click on the Next button.
Step 6: Application Shortcuts preference: here select the place you want the shortcut icons to be
placed on your system to launch the application so I recommend you select both options and click
on the Next button.
Step 7: Install VM Workstation: in this step, the installation is ready to go, so click on the
Install button to begin the installation.
Step 8: Complete the Setup Wizard: In the end, you will see the installation complete dialog box.
so, click on Finish and you are done with installation progress
Your VM will get installed on your windows.
5
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT:
RESULT:
6
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
AIM:
ToInstall a C compiler in the virtual machine and execute a sample program.
Through Openstack portal create virtual machine. Through the portal connect to virtual machines.
Login to VMs and install c compiler using commands.
Eg : apt-get install gcc
Most of the time, when you are installing Linux, GNU Gcc compiler is already installed. If not,
run the following command (our system is Ubuntu Linux) :
If C compiler is already installed, it will show you a message like above. If not, it will install all
the necessary packages.
Now open a text editor and write a small C program like following and save it as demo.c :
#include <stdio.h>
main()
{
printf("Welcome to C Programming");
}
Now run the command as shown below to compile and execute the file :
7
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT:
RESULT:
Thus Installation of a C compiler in the virtual machine is done successfully and a sample program is executed.
8
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
AIM: To create hello world app and other simple web applications using python/java.
PROCEDURE:
Step1: Download Python Release 2.5.4
Step2: First install Python2.5.4 and then install Google App Engine
Step 4: Open Text Editor (Notepad) and copy the following code in it
This is your application written in Python! All it does is print Hello World on the screen every time
its called.
Step 5: Map every request to our helloworld.py file, so create a “app.yaml” file in
your helloworld directory and write the following code in it:
application: helloworld
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: helloworld.py
9
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
Step 6: Deployment on Web Server - you can deploy your applications on local machine before
deploying them to the actual cloud.
Step 7: Open command prompt (type cmd in run) and go to the directory where you installed.
Once you are in the directory, you have to start the webserver with your application deployed.
dev_appserver.py helloworld/
Web Server is started and your HelloWorld application is deployed in it! Now you can send
requests to your app by opening the browser and typing in: http://localhost:8080
10
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT:
RESULT:
Thus Google App Engine is installed and a simple program is executed successfully.
11
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
PROCEDURE:
To upload the guest book app, run the following command from within the appengine-guestbook-
python directory of your application where the app.yaml and index.yaml files are located:
Optional flags:
Include the --project flag to specify an alternate Cloud Console project ID to what you initialized a
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]
The Data store indexes might take some time to generate before your application is available. If the
indexes are still in the process of being generated, you will receive a Need Index Error message
when accessing your app. This is a transient error, so try a little later if at first you receive this
error.
To learn more about deploying your app from the command line, see Deploying a Python App.
12
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT :
RESULT:
Thus GAE launcher is launched successfully and Web application is also launched.
13
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
AIM : To simulate a cloud scenario using Cloud Sim and run a scheduling algorithm that is not present
in Cloud Sim
Step 6: Data centres are the resource providers in CloudSim; hence, creation of data centres is a second
step. To create Datacenter, you need the DatacenterCharacteristics object that stores the properties of a
data centre such as architecture, OS, list of machines, allocation policy that covers the time or
spaceshared, the time zone and its price:
Step 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())
14
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
Step 10: Create a cloudlet with length, file size, output size, and utilisation model:
broker.submitCloudletList(cloudletList)
CloudSim.startSimulation()
Sample Output from the Existing Example:
Starting CloudSimExample1...
Initialising...
Starting CloudSim version 3.0
Datacenter_0 is starting...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>null
Broker is starting...
Entities started.
0.0 : Broker: Cloud Resource List received with 1 resource(s)
0.0: Broker: Trying to Create VM #0 in Datacenter_0
0.1 : 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
15
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT:
RESULT:
Thus Cloud simulator is used and a scheduling algorithm is executed in cloud sim and output is verified.
16
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
AIM : To find a procedure to transfer the files from one virtual machine to another virtual machine.
PROCEDURE :
17
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT:
RESULT:
Transfer of files from one virtual machine to another virtual machine is completed successfully.
18
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
PROCEDURE :
Step 1: Move to Project -> Instances and hit on Launch Instance button and a new
window will appear.
Step 2:On the first screen add a name for your instance, leave the Availability Zone to nova,
use one instance count and hit on Next button to continue.
Step 3:Choose a descriptive Instance Name for your instance because this name will be used
to form the virtual machine hostname.
Step 4:Next, select Image as a Boot Source, add the Cirros test image created earlier
by hitting the + button and hit Next to proceed further.
Step 5:Allocate the virtual machine resources by adding a flavor best suited for your
needs and click on Next to move on.
Step 6:Finally, add one of the OpenStack available networks to your instance using the +
button and hit on Launch Instance to start the virtual machine.
Step 7:Once the instance has been started, hit on the right arrow from Create Snapshot
menu button and choose Associate Floating IP.
Step 8:Select one of the floating IP created earlier and hit on Associate button in order to
make the instance reachable from your internal LAN.
Step 9:Use the instance View Log utility to obtain Cirros default credentials
19
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT:
RESULT:
20
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
AIM: To install hadoop single node cluster and run simple applications like wordcount
PROCEDURE:
Hadoop MapReduce is a software framework for easily writing applications which process vast amounts
of data (multi-terabyte data-sets) in-parallel on large clusters (thousands of nodes) of commodity
hardware in a reliable, fault-tolerant manner.
A MapReduce job usually splits the input data-set into independent chunks which are processed by the
map tasks in a completely parallel manner. The framework sorts the outputs of the maps, which are then
input to the reduce tasks. Typically both the input and the output of the job are stored in a file- system.
The framework takes care of scheduling tasks, monitoring them and re-executes the failed tasks.
Typically the compute nodes and the storage nodes are the same, that is, the MapReduce framework and
the Hadoop Distributed File System are running on the same set of nodes. This configuration allows the
framework to effectively schedule tasks on the nodes where data is already present, resulting in very high
aggregate bandwidth across the cluster.
The MapReduce framework consists of a single master ResourceManager, one slave NodeManager per
cluster-node, and MRAppMaster per application.
Minimally, applications specify the input/output locations and supply map and reduce functions via
implementations of appropriate interfaces and/or abstract-classes. These, and other job parameters,
comprise the job configuration.
The Hadoop job client then submits the job (jar/executable etc.) and configuration to the
ResourceManager which then assumes the responsibility of distributing the software/configuration to the
slaves, scheduling tasks and monitoring them, providing status and diagnostic information to the job-
client.
Prerequisites:
21
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
The key and value classes have to be serializable by the framework and hence need to implement the
Writable interface. Additionally, the key classes have to implement theWritableComparable
interface to facilitate sorting by the framework.
(input) <k1, v1> -> map -><k2, v2> -> combine -><k2, v2> -> reduce -><k3, v3> (output)
CODING :
WordCount is a simple application that counts the number of occurrences of each word in a given input
set.
package hadoop;
import java.util.*;
import java.io.IOException;
import java.io.IOException;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
//Map function
22
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
while(s.hasMoreTokens())
{
lasttoken=s.nextToken();
}
//Reducer class
public static class E_EReduce extends MapReduceBase implements
Reducer< Text, IntWritable, Text, IntWritable >
{
//Reduce function
public void reduce( Text key, Iterator <IntWritable> values,
OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException
{
int maxavg=30;
int val=Integer.MIN_VALUE;
while (values.hasNext())
{
if((val=values.next().get())>maxavg)
{
output.collect(key, new IntWritable(val));
}
}
23
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
//Main function
public static void main(String args[])throws Exception
{
JobConf conf = new JobConf(ProcessUnits.class);
conf.setJobName("max_eletricityunits");
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
conf.setMapperClass(E_EMapper.class);
conf.setCombinerClass(E_EReduce.class);
conf.setReducerClass(E_EReduce.class);
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
JobClient.runJob(conf);
}
}
EXECUTION:
Hadoop launches jobs by getting a jar file containg the compiled Java code. In addition, we typically
send two command line arguments through to the Java program: the input data file or directory, and an
ouput directory for the results from the reduce tasks. Using a tool called ant makes it pretty quick to
create a jar file from the above code.
The ant tool uses an xml file that describes what needs to be compiled and packaged into a jar file. Here
is the one you used for the above WordCount example:
24
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
Assuming that:
25
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
Applications can specify a comma separated list of paths which would be present in the current working
directory of the task using the option -files. The -libjars option allows applications to add jars to the
classpaths of the maps and reduces. The option -archives allows them to pass comma separated list of
archives as arguments. These archives are unarchived and a link with name of the archive is created in
the current working directory of tasks.
Output:
26
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT :
RESULT:
Thus Hadoop single node cluster is installed and word count application is executed successfully.
27
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
PROCEDURE :
FUSE (Filesystem in Userspace) enables you to write a normal user application as a bridge for
a traditional filesystem interface.
The hadoop-hdfs-fuse package enables you to use your HDFS cluster as if it were a traditional
filesystem on Linux. It is assumed that you have a working HDFS cluster and know the
hostname and port that your NameNode exposes.
mkdir -p <mount_point>
hadoop-fuse-dfs dfs://<name_node_hostname>:<namenode_port><mount_point>
You can now run operations as if they are on your mount point. Press Ctrl+C to end the fuse-
dfs program, and umount the partition if it is still mounted.
· If you are using SLES 11 with the Oracle JDK 6u26 package, hadoop-fuse-dfs may exit
immediately because ld.so can't find libjvm.so. To work around this issue,add
$ umount<mount_point>
28
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
You can now add a permanent HDFS mount which persists through reboots. To add a system
mount:
hadoop-fuse-dfs#dfs://<name_node_hostname>:<namenode_port><mount_point> fuse
allow_other,usetrash,rw 2 0
For example:
$ mount <mount_point>
Your system is now configured to allow you to use the ls command and use that mount point
as if it were a normal system disk.
29
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
OUTPUT:
RESULT:
30
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
PROCEDURE :
Click Create subscription, and then click Create subscription in the menu that appears.
Click Create.
31
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
32
CS8711-CC LAB DEPARTMENT OF CSE 2021-2022
RESULT:
33