Ccs335 Cloud Computing Lab Mannual
Ccs335 Cloud Computing Lab Mannual
J COLLEGE OF ENGINEERING
(ACADEMICYEAR: 2023-2024)
Name :
Register Number :
Year/Semester : III/VI
(ANNA UNIVERSITY:CHENNAI-600025)
MOHAMED SATHAK A.J COLLEGE OFENGINEERING
(Approved by AICTE,New Delhi and Affiliated to Anna University)34,Old
Mahabalipuram Road,Egattur,Chennai–603103.
Chennai–600034.
BONAFIDE CERTIFICATE
Register Number..................................................................................................... of
Submitted for the Anna University B.E Practical Examination held on.
.................................
10
3
EX.NO:1 VIRTUALBOX/VMWARE WORKSTATION INSTALLATION
Date :
AIM:
To install the Virtual box or VMware Workstation and to create and run virtual
machine with different flavours of Linux or Windows OS on top of Windows 7 or 8.
PROCEDURE:
Click the Create a New Virtual Machine icon displayed on the center of the screen
or go to File ---> New Virtual Machine or press Ctrl + N to create a new virtual
machine.
Select type of configuration you want (mostly Typical type is preferred for all) and
click next.
5
STEP 5: GUEST OPERATING SYSTEM INFORMATION
Choose the option of installation from Installation Disc Image File and browse the
location of the ISO file of the desired OS you want and click Next.
Give the size of your Virtual disk and choose the option Store virtual disk as a single
file or Split virtual disk as multiple files.Recommended size for Ubuntu 64-bit is 20 GB.
7
STEP 9 : READY TO CREATE VIRTUAL MACHINE
Verify the details for virtual machine and click Finish to create the virtual
machine and start installing Ubuntu 64 -bit and then VMware Tools.
8
9
OUTPUT:
1
0
1
1
RESULT:
PROGRAM:
#include <stdio.h>
int main()
{
char a[1000], b[1000];
scanf(“%s”,a);
scanf(“%s”,b);
if (check_anagram(a, b))
else
return 0;
}
int check_anagram(char a[], char b[])
{
int first[26] = {0}, second[26] = {0}, c=0;
1
while (a[c] != '\0') { 2
first[a[c]-'a']++;
c++;
}
c = 0;
while (b[c] != '\0') {
second[b[c]-'a']++;
c++;
if (first[c] != second[c])
return 0;
return 1;
PROCEDURE:
Right click and select Open Terminal .The terminal windows opens.
Type the following command to install the C Compiler: sudo apt-get install gcc
Type the password to allow the installation.
1
3
STEP 3: EXECUTE PROGRAM
Open the terminal and open the gedit editor using the command : gedit filename.c
1
4
Compile the C program using the following command : gcc filename.c -o filename
1
6
RESULT:
PROGRAM: 1
7
#include <stdio.h>
int check_anagram(char [], char []);
int main()
{
char a[1000], b[1000];
scanf(“%s”,a);
scanf(“%s”,b);
if (check_anagram(a, b))
else
return 0;
}
int check_anagram(char a[], char b[])
{
int first[26] = {0}, second[26] = {0}, c=0;
first[a[c]-'a']++;
c++;
}
c = 0;
while (b[c] != '\0') {
second[b[c]-'a']++;
c++;
if (first[c] != second[c])
return 0;
return 1;
}
1
PROCEDURE: 8
Right click and select Open Terminal .The terminal windows opens.
Type the following command to install the C Compiler: sudo apt-get install gcc
Type the password to allow the installation.
1
9
Type the C program and save the file.
Compile the C program using the following command : gcc filename.c -o filename
2
0
Run the C program using the command : ./filename
2
1
OUTPUT:
RESULT:
2
EX.NO: 3.b) DEVELOP CELSIUS TO FAHRENHEIT WEB APPLICATION
2
Date: USING PYTHON / JAVA
t est1.py:
import webapp
def convert_temp(cel_temp):
''' convert Celsius temperature to Fahrenheit
temperature ''' if cel_temp == "":
ret
urn ""
try:
far_temp = float(cel_temp) * 9 / 5 + 32
far_temp = round(far_temp, 3) # round to three decimal places
return str(far_temp)
except ValueError: # user entered non-numeric temperature
return "invalid input"
class
MainPage(webapp2.RequestHandle
r): def get(self):
cel_temp =
self.request.get("cel_temp")
far_temp =
convert_temp(cel_temp)
self.response.headers["Content-Type"] =
"text/html"
self.response.headers["Content-Type"] =
"text/html" self.response.write(""")
<html><head><title>Temperature Converter</title></head>
<body>
<form action="/" method="get">
Celsius temperature: <input type="text"
name="cel_temp" value={}>
<input type="submit"
value="Convert"><br>
Fahrenheit temperature: {}
</form>
</body>
</html>""".format(cel_temp, far_temp))
routes = [('/', MainPage)]
my_app = webapp2.WSGIApplication(routes, debug=True)
14. Create a text document and type the yaml file code and save it as app.yaml
a pp.yaml:
runtime:python27
api_version: 1
threadsafe: true
handlers:
- url: /
script: test1.my_app
15. After creating both .yaml and .py file, now we have to execute this python file by running
dev_appserver.py file in bin folder by using this command “google-cloud- sdk\bin\
dev_appserver.py
2
C:\Users\DELL\Desktop\test”. 3
16. Select ‘Y’ if you want to install the components. And automatically after installing
the components the python file is executed and hosted.
RESULT:
AIM :
To use GAE Launcher to launch the web applications.
PROCEDURE :
Accept the terms and conditions for the installation. Click Next.
2
5
Choose the destination folder to install.Click Next.
2
8
Step 4:
Click the application name and click Run icon.After application runs, the symbol
on left of application name becomes green in colour.Note the Port number and type in
the browser as : localhost:portnumber
PROGRAM:
PYTHON PROGRAM(GCD):
#!/usr/bin/env python
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.html = ''' <html><body><h2> GCD</h2><form action = "/submit" method = "get">
Enter Number 1 <input type = "text" name = "A" id = "numA"> <br><br>
Enter Number 2 <input type = "text" name = "B" id = "numB"> <br> <br>
<input type = "submit" value = "Submit"> <br> </form> </body> </html> '''
self.response.write(self.html)
return self.response;
2
class SubmitHandler(webapp2.RequestHandler): 9
def get(self):
self.a = int(self.request.get('A'))
self.b = int(self.request.get('B'))
self.res = self.gcd(self.a,self.b)
self.response.write("The GCD of "+ str(self.a) + " and " + str(self.b) +" is \n")
self.response.write(self.res)
return self.response;
def gcd(self,a,b):
if (self.a > self.b):
self.small = b
else:
self.small = a
return self.gcd
FILENAME.YAML
app = webapp2.WSGIApplication([
('/', MainHandler),
('/submit',SubmitHandler),
], debug=True)
OUTPUT
3
0
RESULT:
3
1
EX.NO: 5 TO SIMULATE A CLOUD SCENARIO USING CLOUDSIM
Date: AND RUN A SCHEDULING ALGORITHM
PROGRAM:
package cloudsimexample5;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
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.VmSchedulerSpaceShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
cloudletList1.add(cloudlet1);
cloudletList2.add(cloudlet2);
broker1.submitCloudletList(cloudletList1);
broker2.submitCloudletList(cloudletList2);
CloudSim.startSimulation();
CloudSim.stopSimulation(); 3
3
System.out.println("=============> User "+brokerId1+" ");
printCloudletList(newList1);
System.out.println("=============> User "+brokerId2+" ");
printCloudletList(newList2);
System.out.println("CloudSimExample5 finished!");
}
catch (Exception e) {
e.printStackTrace();
System.out.println("The simulation has been terminated due to an unexpected
error");
}
}
private static Datacenter createDatacenter(String name){
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerSpaceShared(peList)
)
);
return datacenter;
}
private static DatacenterBroker createBroker(int id){
}
}
3
5
OUTPUT :
RESULT:
3
6
EX.NO: 6 TRANSFER A FILE BETWEEN TWO VIRTUAL MACHINES
Date:
PROCEDURE:
● Before turning on the virtual machines, create a shared folder in the host OS
● Choose the people whom you want to share with. Select as everyone.
3
7
● Configure the Shared folder settings.
3
8
Click the First Virtual machine and goto VM - > Settings. Goto Options and choose
Shared Folders and click Always Enabled.Add the folder which we want to share.
● Click Files and then goto Other locations.Choose Computer ,goto mnt -> hfgs ,so that
the shared folder is visible.
● Turn on the Second Virtual machine and click Files and then click Other
locations.Choose Computer ,goto mnt -> hfgs. 4
0
● Open the shared folder which you have seen in the previous Virtual machine. Open
the folder and open the text file.
● Finally you can see that the file has been transferred from one virtual machine
through another virtual machine by using the shared folder method.
OUTPUT:
RESULT:
4
1
Ex.No:7. HADOOP SINGLE NODE CLUSTER
Date:
Aim:
To find procedure to set up the one node Hadoop cluster.
Procedure
1. Open VM – new -> full name : centos7
username : admin
password : admin
confirm password :admin.
2. Create folder in D drive D:
centos7 Hadoop -> after that goto h/w customs and change memory to 4GB.
3. During installation time create user:
Right corner user creation
Fullname : hadoop.
User : hadoop.
Password : hadoop.
4. Copy hadoop 3.0.3 and JDK 1.8.0 from windows to hadoop user desktop/root
user and extract jar files in desktop itself .
5. Login to Root user : i) $ groupadd cluster
ii) $usermode –aG cluster hadoop.
6. //Open bashrc file and type the following command in the ‘bashrc’ file bottom.
bashrc file present in computer -> home -> Desktop -> Bashrc.
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hduser(change the hd user) /hdfs/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hduser(change the hd user) /hdfs/datanode</value>
</property>
</configuration>
Output:
NameNode:
DataNode:
4
4
Result:
4
5
● Insert the name of the Instance (eg. "vm01") and click Next button
●Select Instance Boot Source (eg. "Image"), and choose desired image (eg. "Ubuntu
16.04 LTS") by clicking on arrow. Keep the setting "Create New Volume" feature to
"No" state.
4
6
●Choose Flavour (eg. eo1.xsmall).
4
7
●Choose or generate SSH keypair for your VM. Next, launch your instance by
clicking on blue button.
●You will see "Instances" menu with your newly created VM. Open the drop-down
menu and choose "Console".
4
8
●Click on the black terminal area (to activate access to the console). Type: eoconsole
and hit Enter.
●Now you can type commands. After you finish, type "exit". This will close the
session.
RESULT:
4
9
Ex.No: 7. b) USE THE HADOOP SINGLE NODE CLUSTER TO
Date: IMPLEMENT WORD COUNT PROGRAM
Program:
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.*;
import org.apache.hadoop.mapreduce.lib.output.*;
import org.apache.hadoop.util.*;
FileInputFormat.setInputPaths(job, inputPath);
FileOutputFormat.setOutputPath(job, outputPath);
job.setJobName("WordCount");
job.setJarByClass(WordCount.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
job.setMapperClass(Map.class);
job.setCombinerClass(Reduce.class);
job.setReducerClass(Reduce.class);
return job.waitForCompletion(true) ? 0 : 1; }
public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
41
private Text word = new Text();
public void map(LongWritable key, Text value,
Mapper.Context context) throws IOException, InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one);
} } }
public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException,
InterruptedException {
int sum = 0;
for (IntWritable value : values) {
sum += value.get();
}
context.write(key, new IntWritable(sum));
} }}
NameNode:
41
DataNode:
Input File:
a.txt Output:
aaa aaa aaa aaa 3
bbb bbb bbb bbb 3
ccc ccc ccc ccc 3
41
Result:
41