Vii Cse Cs8711 Cc Labmanual
Vii Cse Cs8711 Cc Labmanual
Vii Cse Cs8711 Cc Labmanual
IV Year/VII Semester
LAB MANUAL
Prepared By,
CS8791_CC
4931_GRACE College of Engineering, Thoothukudi.
EX NO: 1
Date:
INSTALL VIRTUALBOX WITH LINUX OS ON TOP OF WINDOWS
AIM:
PROCEDURE:
Steps to install VirtualBox:
1. Download VirtualBox installer for windows.
2. The installer can be downloaded from the link : https://www.virtualbox.org/wiki/Downloads
3. Click “Windows host” to download the binary version for windows host.
4. The installer file downloaded will have the file name format like “VirtualBox-VersionNumber-BuildNumber-
Win.exe”. Example: VirtualBox-6.1.12-139181-Win.exe.
5. Double click on the installer to launch the setup Wizard. Click on Next to continue.
6. Custom setup dialog box will be opened. Accept the default settings and click next.
7. Select the way you want the features to be installed. You can accept the default and click next.
8. A dialog box opens with Network Interfaces warning. Click Yes to proceed.
9. Click install to begin the installation process.
10. When prompted with a message to install (Trust) Oracle Universal Serial Bus, click Install to continue.
11. After the installation completes, click finish to exit the setup wizard.
12. Launch the Oracle VM VirtualBox.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
OUTPUT:
Result:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
EX NO: 2
Date:
INSTALL A C COMPILER IN THE VIRTUAL MACHINE
AIM:
PROCEDURE:
1.Launch the virtual box and open the virtual machine (Ubuntu).
2. Run the following command in the virtual machine terminal.
$ sudo apt-get update
$ sudo apt-get install gcc
It will install all the necessary packages for gcc complier.
3. Type the C program in the text editor and save the file with .c extention.
//fact.c
#include<stdio.h>
void main()
{
int n,fact=1;
int i=1;
printf("Enter a positive integer:");
scanf("%d",&n);
if(n==0)
{
fact=1;
}
else
{
while(i<=n)
{
fact*=i;
i++;
}
printf("The factorial of %d is %d ",n,fact);
}}
4. Compile and Run the C Program
cc fact.c
./a.out
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
OUTPUT:
RESULT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
AIM:
PROCEDURE:
Google App Engine SDK Installation:
1. Download the Google Cloud SDK installer using the link https://cloud.google.com/appengine/downloads.
2. Select the standard environment as Java.
3. Click „Download and Install the Cloud SDK‟. Launch the installer and follow the prompts.
4. After installation has completed, the installer presents severaloptions:
Make sure that the following are selected:
• Start Google Cloud SDKShell.
• Run 'gcloudinit' .The installer then starts a terminal window and runs the gcloudinit command.
5. Run the following command in your terminal to install the gcloud component that includes the App Engine
extension for Java11:
gcloudcomponentsinstallapp-engine-java
Creating a new App Engine standard project in Eclipse:
6. Eclipse with the cloud tools is used to create App Engine standard project.
7. To install the Cloud Tools in Eclipse, select Help > Eclipse Marketplace... and search for “Google Cloud Tools for
Eclipse” and click install.
8. After installation restart eclipse when prompted.
9. Click the Google Cloud Platform toolbar button.
10. Select Create New Project >Google App Engine Standard Java Project.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
18. Right click the project in the Package Explorer, select Run As > App Engine.
Either way, you'll see a static HTML page with a link to the servlet.
Index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF -8" />
<title>Hello App Engine</title>
</head>
<body>
<h1>Hello App Engine!</h1>
<table>
<tr>
<td colspan="2" style="font-weight:bold;">Available Servlets:</td>
</tr>
<tr>
<td><a href='/hello'>The servlet</a></td>
</tr>
</table>
</body>
</html>
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
HelloAppEngine.java
package com.pack;
import java.io.IOException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(
name = "HelloAppEngine",
urlPatterns = {"/hello"}
)
public class HelloAppEngine extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
response.setContentType("=text/plain");
response.setCharacterEncoding("UTF-8");
response.getWriter().print("Hello App Engine!\r\n");
}
}
RESULT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
EX NO: 4 Install Google App Engine and create a simple web applications
Date: using python
AIM:
PROCEDURE:
1. Download the python from http://www.python.org/downloads and install it in the system.
2. Download the SDK for python from https://cloud.google.com/appengine/docs .
3. Login into Cloud SDK with the Google account .
4. Create a python file and save it as index.py
5. Create a YAML file for configuration and name it as app.yaml
6. Open the Cloud SDK window and type the comment Google -cloud-sdk\bin\dev-appserver.py “<>”
7. In web browser obtain the result from address localhost:8080.
PROGRAM:
app.yaml
runtime: python27
threadsafe: true
handlers:
- url: /
script: main.app
main.py
import os
import json
import urllib
import webapp2
from google.appengine.ext.webapp import template
class MainPage(webapp2.RequestHandler):
def get(self):
template_values = {}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
def post(self):
pincode = self.request.get('zipCode')
if not pincode.isnumeric() or not len(pincode) == 6:
template_values = {
"error": "Incorrect Pin Code (String / False Code entered)"
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
return self.response.out.write(template.render(path, template_values))
url = "https://api.postalpincode.in/pincode/" + pincode
data = urllib.urlopen(url).read()
data = json.loads(data)
if(data[0]['Status'] == 'Success'):
post_office = data[0]['PostOffice'][0]['State']
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
OUTPUT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
name = data[0]['PostOffice'][0]['Name']
block = data[0]['PostOffice'][0]['Block']
district = data[0]['PostOffice'][0]['District']
template_values = {
"post_office": post_office,
"name": name,
"block": block,
"district": district
}
path = os.path.join(os.path.dirname(__file__), 'results.html')
self.response.out.write(template.render(path, template_values))
else:
template_values = {}
path = os.path.join(os.path.dirname(__file__), 'error.html')
self.response.out.write(template.render(path, template_values))
index.html
<html>
<style>
.weatherText {
font-family: 'Lato', 'sans-serif';
font-size: 24px;
text-align: center;
}
#weatherForm {
padding: 20px;
}
#weatherSubmit {
color: white;
background-color: #083375;
padding: 5px 20px;
border-radius: 5px;
margin-top: 20px;
}
#weatherSubmit:hover {
cursor: pointer;
}
body {
display: flex;
justify-content: center;
align-items: center;
}
.card {
border: 2px solid black;
width: 50%;
justify-content: center;
align-items: center;
}
</style>
<head>
<title class="alignct">Post Office Finder</title>
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
results.html
<!DOCTYPE html>
<html lang="en">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
}
#weatherResults {
background-color: #83e9c2;
font-family: 'Lato', sans-serif;
font-size: 24px;
padding: 30px;
display: inline-block;
text-align: center;
margin: 20px;
margin-top: 10%;
border: 2px solid black;
border-radius: 5px;
}
</style>
<head>
<meta charset="UTF-8" />
<title>Post Office Information</title>
<link href=https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap rel="stylesheet"/>
</head>
<body>
<div id="weatherResults">
<table>
<tr>
<th>
<h3>State of Post Office :</h3>
</th>
<th>
<h3>{{ post_office }}</h3>
</th>
</tr>
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
<tr>
<th>
<h3>Name of Post Office :</h3>
</th>
<th>
<h3>{{ name }}</h3>
</th>
</tr>
<tr>
<th>
<h3>Block of Post Office:</h3>
</th>
<th>
<h3>{{ block }}</h3>
</th>
</tr>
<tr>
<th>
<h3>District of Post Office:</h3>
</th>
<th>
<h3>{{ district }}</h3>
</th>
</tr>
</table>
<a href="http://localhost:8080/"><h4>Back to the Home page</h4></a>
</div>
</body>
</html>
error.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Error page</title>
<link href=https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap rel="stylesheet"/>
</head>
<body>
<div style="text-align: center">
<h2>No such pin exists</h2>
<a href="http://localhost:8080/"><h3>Back to the Home page</h3></a>
</div>
</body>
</html>
RESULT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
PROCEDURE:
What is Cloudsim?
CloudSim is a simulation toolkit that supports the modeling and simulation of the core functionality of cloud, like
job/task queue, processing of events, creation of cloud entities(datacenter, datacenter brokers, etc), communication
between different entities, implementation of broker policies, etc.
This toolkit allows to:
• Test application services in a repeatable and controllable environment.
• Tune the system bottlenecks before deploying apps in an actual cloud.
• Experiment with different workload mix and resource performance scenarios on simulated infrastructure for
developing and testing adaptive application provisioning techniques.
Core features of CloudSim are:
• The Support of modeling and simulation of large scale computing environment as federated cloud data
centers, virtualized server hosts, with customizable policies for provisioning host resources to virtual
machines and energy-aware computational resources.
• It is a self-contained platform for modeling cloud‟s service brokers, provisioning, and allocation policies.
• It supports the simulation of network connections among simulated system elements.
• Support for simulation of federated cloud environment, that inter-networks resources from both private and
public domains.
• Availability of a virtualization engine that aids in the creation and management of multiple independent and
co-hosted virtual services on a data center node.
• Flexibility to switch between space shared and time shared allocation of processing cores to virtualized
services.
How to use CloudSim in Eclipse:
CloudSim is written in Java. The knowledge you need to use CloudSim is basic Java programming and some basics
about cloud computing. Knowledge of programming IDEs such as Eclipse or NetBeans is also helpful. It is a library
and, hence, CloudSim does not have to be installed. Normally, you can unpack the downloaded package in any
directory, add it to the Java classpath and it is ready to be used. Please verify whether Java is available on your
system.
2. Open Eclipse
5. The first step is to initialise the CloudSim package by initialising the CloudSim library, as follows:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
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:
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 )
PROGRAM:
SJF_Scheduler.java
package com.sjfs;
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple ;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple ;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple ;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
//VM Parameters
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
int mips = 250;
long bw = 1000;
int pesNumber = 1; //number of cpus
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
//create VMs
Vm[] vm = new Vm[vms];
return list;
}
//cloudlet parameters
long fileSize = 300;
long outputSize = 300;
int pesNumber = 1;
UtilizationModel utilizationModel = new UtilizationModelFull();
new GenerateMatrices();
execMatrix = GenerateMatrices.getExecMatrix();
commMatrix = GenerateMatrices.getCommMatrix();
try {
int num_user = 1; // number of grid users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
OUTPUT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
//Fourth step: Create VMs and Cloudlets and send them to broker
vmList = createVM(brokerId, Constants.NO_OF_DATA_CENTERS);
cloudletList = createCloudlet(brokerId, Constants.NO_OF_TASKS, 0);
broker.submitVmList(vmList);
broker.submitCloudletList(cloudletList);
CloudSim.stopSimulation();
printCloudletList(newList);
/**
* Prints the Cloudlet objects
*
* @param list list of Cloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");
SJFDatacenterBroker.java
package com.sjfs;
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.core.CloudSimTags;
import org.cloudbus.cloudsim.core.SimEvent;
import java.util.ArrayList;
import java.util.List;
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
//setCloudletReceivedList(null);
//System.out.println("size :"+list.size());
int n = list.size();
setCloudletReceivedList(list);
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
@Override
protected void processCloudletReturn(SimEvent ev) {
Cloudlet cloudlet = (Cloudlet) ev.getData();
getCloudletReceivedList().add(cloudlet);
Log.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + cloudlet.getCloudletId()
+ " received");
cloudletsSubmitted--;
if (getCloudletList().size() == 0 && cloudletsSubmitted == 0) {
scheduleTaskstoVms();
cloudletExecution(cloudlet);
}
}
@Override
protected void processResourceCharacteristics(SimEvent ev) {
DatacenterCharacteristics characteristics = (DatacenterCharacteristics) ev.getData();
getDatacenterCharacteristicsList().put(characteristics.getId(), characteristics);
if (getDatacenterCharacteristicsList().size() == getDatacenterIdsList().size()) {
distributeRequestsForNewVmsAcrossDatacenters();
}
}
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
if (!getVmsToDatacentersMap().containsKey(vm.getId())) {
Log.printLine(CloudSim.clock() + ": " + getName() + ": Trying to Create VM #" + vm.getId() + " in " +
datacenterName);
sendNow(datacenterId, CloudSimTags.VM_CREATE_ACK, vm);
numberOfVmsAllocated++;
}
}
setVmsRequested(numberOfVmsAllocated);
setVmsAcks(0);
}
}
RESULT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
EX NO: 6
Date:
COPY FILES FROM ONE VIRTUAL MACHINE TO ANOTHER
AIM:
PROCEDURE:
1. .Create one shared folder in virtual box.
2. VirtualBox’s Shared Folders feature works with both Windows and Linux guest operating systems.
3. To use the feature, you first need to install VirtualBox’s Guest Additions in the guest virtual machine.
4. With the virtual machine running, click the “Devices” menu and choose the “Insert Guest Additions CD
image” option.
5. This inserts a virtual CD that you can use within the guest operating system to install the Guest Additions.
6. After the Guest Additions are installed, open the “Machine” menu and click the “Settings” option.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
OUTPUT:
Make all your choices and then hit the “OK” button.
RESULT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
AIM:
REQUIREMENTS:
1. Install OpenStack in RHEL and CentOS 7.
2. Configure OpenStack Networking Service.
PROCEDURE:
Step 1: Allocate Floating IP to OpenStack
1. Before you deploy an OpenStack image, first you need to assure that all pieces are in place and we‟ll start by
allocating floating IP.
2. Floating IP allows external access from outside networks or internet to an Openstack virtual machine.
3. In order to create floating IPs for your project, login with your user credentials and go to Project - > Compute
-> Access & Security -> Floating IPs tab and click on Allocate IP to The Project.
4. Choose external Pool and hit on Allocate IP button and the IP address should appear in dashboard.
5. It‟s a good idea to allocate a Floating IP for each instance you run.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
OUTPUT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
3. Finally, add one of the OpenStack available networks to your instance using the + button and hit on
Launch Instance to start the virtual machine.
RESULT:
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
EX NO: 8
Date:
INSTALL HADOOP SINGLE NODE CLUSTER
AIM:
PROCEDURE:
1. Download Hadoop 2.8.0
2. Check either Java 1.8.0 is already installed on your system or not, use “Javac - version" to check Java version
3. If Java is not installed on your system then first install java under "C:\JAVA" Java setup
4. Extract files Hadoop 2.8.0.tar.gz or Hadoop-2.8.0.zip and place under "C:\Hadoop-2.8.0" hadoop
5. Set the path HADOOP_HOME Environment variable.
6. Set the path JAVA_HOME Environment variable.
7. Next we set the Hadoop bin directory path and JAVA bin directory path.
HADOOP CONFIGURATION:
a) File C:/Hadoop-2.8.0/etc/hadoop/core-site.xml, paste below xml paragraph and save this file.
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
b) Rename mapred-site.xml.template" to "mapred-site.xml" and edit this file
C:/Hadoop2.8.0/etc/hadoop/mapred-site.xml, paste below xml paragraph and save this file.
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
c) Create folder "data" under "C:\Hadoop-2.8.0"
• Create folder "datanode" under "C:\Hadoop-2.8.0\data"
• Create folder "namenode" under "C:\Hadoop-2.8.0\data" data
d) Edit file C:\Hadoop-2.8.0/etc/hadoop/hdfs-site.xml, paste below xml paragraph and save this file.
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>C:\hadoop-2.8.0\data\namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>C:\hadoop-2.8.0\data\datanode</value>
</property>
</configuration>
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
e) Edit file C:/Hadoop-2.8.0/etc/hadoop/yarn-site.xml, paste below xml paragraph and save this file.
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
f) Edit file C:/Hadoop-2.8.0/etc/hadoop/yarn-site.xml, paste below xml paragraph and save this file.
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
g) Edit file C:/Hadoop-2.8.0/etc/hadoop/hadoop-env.cmd by closing the command line
"JAVA_HOME=%JAVA_HOME%" instead of set "JAVA_HOME=C:\Java"
Hadoop Configuration:
1) Download file Hadoop Configuration.zip
2) Delete file bin on C:\Hadoop-2.8.0\bin, replaced by file bin on file just download (from Hadoop
Configuration.zip).
3) Open cmd and typing command "hdfs namenode –format" .You will see hdfs namenode –format Testing.
4) Open cmd and change directory to "C:\Hadoop-2.8.0\sbin" and type "start- all.cmd" to start apache.
5) Make sure these apps are running.
a) Name node
b)Hadoop data node
c) YARN Resource Manager
d)YARN Node Manager hadoop nodes .
6) Open: http://localhost:8088 .
Open cmd in Administrative mode and move to "C:/Hadoop-2.8.0/sbin" and start cluster
1. Create an input directory in HDFS.
hadoop fs –mkdir/input_dir
2. Copy the input text file named input_file.txt in the input directory (input_dir) of HDFS.
hadoop fs –put C:/input_file.txt/input_dir
3. Verify input_file.txt available in HDFS input directory (input_dir).
hadoop fs –ls/input_dir/
4. Verify content of the copied file.
hadoop dfs –cat/input_dir/input_file.txt
5. Run MapReduceClient.jar and also provide input and out directories.
hadoop jar C:/MapReduceClient.jar wordcount /input_dir /output_dir
6. Verify content for generated output file.
hadoop dfs -cat /output_dir/*
CS8711_CC_LAB_R2017
4931_GRACE College of Engineering, Thoothukudi.
RESULT:
CS8711_CC_LAB_R2017