0% found this document useful (0 votes)
98 views68 pages

CCS335-Cloud Computing Record

record

Uploaded by

manavalan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views68 pages

CCS335-Cloud Computing Record

record

Uploaded by

manavalan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

COLLEGE OF ENGINEERING & TECHNOLOGY, ARASUR.

(Reaccredited by NAAC & an ISO 9001:2008 Recertified Institution)

DEPARTMENT
OF
COMPUTER SCIENCE AND ENGINEERING

RECORD NOTE BOOK


2024 - 2025

STUDENT NAME :
ROLL NUMBER :
YEAR : III
SEMESTER : V
SUBJECT CODE / NAME : CCS335/ CLOUD COMPUTING LAB
REGULATION : 2021
BRANCH : COMPUTER SCIENCE AND ENGINEERING
V.R.S COLLEGE OF ENGINEERING &
TECHNOLOGY, ARASUR.
(Reaccredited by NAAC & an ISO 9001:2008 Recertified Institution)

BONAFIDE CERTIFICATE

NAME : …………………………………………………………………………

DEPARTMENT :………………………………………………………………………….

ROLL NO :…………………………………………………………………….........

Register No.

Certified that this is the bonafide record of work done by the above Student in the

......................................................................................................................................................................

Laboratory during the year 2024 - 2025

Head of the Department Lab-in-Charge

Submitted for the Practical Examination held on...……………………………

Internal Examiner External Examiner


Ex. No. Date LIST OF EXPERIMENTS Page No. Sign

1.

2.

3.

4.

5.

6.

7.

8.

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

Aim
To Install Virtualbox/VMware Workstation with different flavours of linux or
windows OS on top of windows7 or 8.

Procedure:
VirtualBox installation
1. First we need to download VirtualBox from https://www.virtualbox.org. I’ve
downloaded VirtualBox 5.1.14
2. Run the executable and follow the prompts to complete the installation. We don’t
really need to change anything for our purposes, and can accept the defaults. Before
completing the wizard you will get a warning that the network connection will
temporarily be interrupted, so make sure you’re not doing anything that would be
impacted, like being half-way through downloading a 16GB file that can’t be resumed.

3. Create an Ubuntu virtual machine


1. Download the latest Ubuntu release from
https://www.ubuntu.com/download/desktop. I’ve downloaded Ubuntu 16.04.1
2. Open VirtualBox and click New

1
3. Type the Name for the virtual machine, like Ubuntu 16. VirtualBox will try to predict
the Type and Version based on the name you enter. Otherwise, select:
• Type: Linux
• Version: Ubuntu (64-bit)
and click Next.

4. Next we need to specify how much memory to allocate the virtual machine. According
to the Ubuntu system requirements we need 2GB, but I’d recommend more if your
host can handle it. Basically the higher you can set the memory without severly
impacting your host machine, the better the performance of the guest machine. If
you’re not sure, stick with 2GB.

2
5. On the Hardware screen select Create a virtual hard disk now and click Create
6. Accept the default option VDI for Hard disk file type (or change it if you wish…) and
click Next
7. Next we are prompted for Storage on physical hard disk. The options are
Dynamically allocated and Fixed size. We’ll use the default of Dynamically allocated.
Click Next

8. Choose the hard disk size and storage location. The Ubuntu system requirements
recommend 25GB. Remember, we choose Dynamically allocated as our storage option
in the last step, so we won’t consume all this disk space immediately. Rather,
VirtualBox will allocate it as required, up to the maximum 25GB we specified. Click
Create
9. The wizard will finish and we are returned to the main VirtualBox window. Click
Settings
3
10. In the left pane select Storage, then in the right select the CD icon with the
word Empty beside it.

11. Under Attributes click the CD icon (highlighted in the screenshot above) and
select Choose Virtual Optical Disk File and browse to the downloaded file ubuntu-
16.04.1-desktop-amd64.iso

12. Click OK to close the Settings dialog window. The virtual machine should now
be ready to start.

4
Install Ubuntu
In VirtualBox your VM should be showing as Powered Off, and the optical drive configured to
point to the Ubuntu ISO file we downloaded previously.
1. In VirtualBox, select the virtual machine Ubuntu 16 and click Start. VirtualBox will
launch a new window with the vm and boot from the iso.

2. Click Install Ubuntu

3. Select Download updates while installing Ubuntu and click Continue


4. On the next screen accept the default of Erase disk and install Ubuntu and click
Install Now

5
5. You will be prompted with a warning saying the changes will be written to disk. Click
Continue

6. Select your timezone and click Continue

6
7. Select your keyboard layout. I accepted the default of English (US) and click
Continue
8. Enter a username and password, then click Continue

9. The Ubuntu installation may take several minutes to run, so have another coffee.

7
10. When the installation is finished you will be prompted to restart. Save and
close anything else you may have open and click Restart Now

11. Now when the vm reboots you may see this message.

From the menu select Machine > Settings.


Navigate back into the Storage settings where we previously selected the iso file. If
the Ubuntu iso file is still there, remove it. Otherwise close the Settings window and in
the vm press Enter to proceed.
12. If all went well the VM should boot to the Ubuntu login screen. Enter your
password to continue.

8
Ubuntu should run normally in the VirtualBox environment. If everything is far too small,
you can adjust the ‘zoom’ by selecting View > Scale Factor > 200%.
Have fun!

9
Result:
Thus the Virtual box/Oracle Virtual machine has installed Successfully.

Ex.No:2 Install a C compiler in the virtual machine and execute a sample


program.
Aim :
To install a C compiler in the virtual machine and execute a sample program.

Procedure:
step1:
Install the centos or ubuntu in the VMware or Oracle Virtual Machine as per previous
commands.

Step 2:
Login into the VM of installed OS.

Step 3:
If it is ubuntu then, for gcc installation
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-6 gcc-6-base

Step 4:
Write a sample program like
Welcome.cpp
#include<iost
ream.h>
using
namespace
std; int
main()
{
cout<<”Hello world”;
return 0;
}

Step 5:
First we need to compile and link our program. Assuming the source code is saved in a
file welcome.cpp, we can do that using GNU C++ compiler g++, for example g++ -Wall -o
welcome welcome.cpp and output can be executed by ./welcome
10
Result:
Thus the GCC compiler has installed and executed in this sample program
successfully.

Ex.No:3 Install Google App Engine. Create hello world app and other simple web
applications using python/java.

Aim:
To install Google App Engine. Create hello world app and other simple web
applications using python/java.

Procedure:

To create a new App Engine standard project in Eclipse:

Steps to creation:
1. Click the Google Cloud Platform toolbar button .
2. Select Create New Project > Google App Engine Standard Java Project.

11
3. Enter a Project name and (optionally) a Java package.

12
4. To create a Maven-based App Engine project, check Create as Maven Project and
enter a Maven Group ID and Artifact ID of your choosing to set the coordinates for
this project. The Group ID is often the same as the package name, but does not have
to be. The Artifact ID is often the same as or similar to the project name, but does not
have to be.
5. Click Next.
6. Select any libraries you need in the project.
7. Click Finish.

The wizard generates a native Eclipse project, with a simple servlet, that you can run and
deploy from the IDE.

Running the project locally


Steps for Running the Project locally:

1. Select the project in the Project Explorer or Package Explorer.

13
2. Open the context menu.
3. Select Run As > App Engine.

4. Log messages appear in the console as the server starts up.


5. Eclipse opens its internal web browser to your application. You can also open an
external browser and navigate to http://localhost:8080. Either way, you'll see a static
HTML page with a link to the servlet.
Note: You may see a message that says, Port 8080 already in use. If so, you can run your
application on a different host or port.

14
Debugging the project locally

To debug your project locally, complete the running the project locally steps, except
select Debug As > App Engine instead of Run As > App Engine in the context menu.

The server stops at the breakpoints you set and shows the Eclipse debugger view.

Running App Engine Standard Apps on a Different Host or Port

To run your App Engine standard application on a different host or port:

1. Right-click your project.


2. Select Run As > Run on Server.

15
Note: You can also select Debug As > Debug on Server to debug your application on a
different host or port.

1. In the dialog, select Manually define a new server.


2. Select App Engine Standard as the server type.
3. Enter the hostname in the Server's host name field.
4. Enter the port in the Server port field.
5. Click Finish.

Configuring Eclipse
To configure Cloud Tools for Eclipse to use Objectify:

1. In Eclipse, select Run > Run Configurations.

16
2. In the Run Configurations dialog, select an existing App Engine Local Server launch
configuration, or click the New launch configuration button to create one.
3. Select the Cloud Platform tab of your run configuration.
4. Select an account.
5. Select a project to assign a project ID to be used in the local run. It doesn't matter
which project you select because you won't actually connect to it.

6. As an alternative, if you aren't logged in or don't have a Cloud Project, you can instead
set the GOOGLE_CLOUD_PROJECT environment variable to a legal string, such
as MyProjectId, in the Environment tab of the run configuration.

Result:
Thus the Google App Engine has installed and executed in this sample program
effectively.

17
Ex.No:4 Use GAE launcher to launch the web applications

Aim:
To use GAE launcher to launch the web applications(Eclipse)

Procedure:

Step1:
Install an Eclipse and create GAE web application as per previous commands.
Step2 :
Deploying App Engine Standard Applications from Eclipse

The steps of creating a new App Engine app in the Google Cloud Console,
authenticating with Google, and deploying your project to App Engine.

Before you begin


You need a Google Cloud project with an App Engine application to deploy to.
If you don't already have one, use the Google Cloud Console to set up your Cloud
project:
Go to Clud Cons
1. Select or create a new Cloud project.
2. Sign in to a Google account that is used to deploy your project to App Engine.
3. Select File > Sign in to Google.

If you see Manage Google Accounts instead of the Sign in to Google option, that
means you are already signed in, so you can skip these account sign in steps.
4. Your system browser opens outside of Eclipse and asks for the permissions it
needs to manage your App Engine Application.

18
5. Click Allow and close the window. Eclipse is now signed into your account.
6. Ensure that the appengine-web.xml file is in the WEB-INF folder of your web
application.
7. Ensure that the project has the App Engine Project facet. If you created it using
the wizard, it should already have this facet. Otherwise:
8. Right click the project in the Package Explorer to bring up the context menu.
9. Select Configure > Convert to App Engine Project.

Deploy the Project to App Engine

To deploy the project to App Engine standard environment:

1. Right click the project in the Package Explorer to open the context menu.
2. Select Deploy to App Engine Standard.
3. A dialog pops up.
4. Select the account you want to deploy with, or add a new account.
5. The list of projects the account has access to loads. Select the one you want to deploy
to.
6. Click OK.

19
A background job launches that deploys the project to App Engine. The output of the job is
visible in the Eclipse Console view.

By default, App Engine stops the previous version of your application and immediately
promotes your new code to receive all traffic. If you'd rather manually promote it later
using gcloud or the Google Cloud Console, uncheck Promote the deployed version to
receive all traffic. If you don't want to stop the previous version, uncheck Stop previous
version.

Result:
Thus, the Google App Engine has launched in this sample program agreeably.

20
Ex.No:5 Simulate a cloud scenario using CloudSim and run a scheduling algorithm
that is not present in CloudSim

Aim :
To Simulate a cloud scenario using CloudSim and run a scheduling algorithm.

Procedure:

1. Before you start, It is essential that the cloudsim should already installed/setup on your
local computer machine. In case you are yet to install it, you may follow the process
of Cloudsim setup using Eclipse IDE
2. The main() method is the pointer from where the execution of this example starts
public static void main(String[] args)
3. There are eleven steps that are followed in each example with some variation in them,
specified as follows:

Step1 :Set the Number of users for the current simulation. This user count is directly
proportional to a number of brokers in the current simulation.
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;
• Step 2: Initialize the simulation, provided with the current time, number of users and
trace flag.
CloudSim.init(num_user, calendar, trace_flag);
• Step 3: Create a Datacenter.
Datacenter datacenter0 = createDatacenter("Datacenter_0");
where the createDatacenter() method itself initializes the various datacenter
characteristics along with the host list. This is the most important entity without this there is
no way the simulation of hosting the virtual machine is applicable.
private static Datacenter createDatacenter(String name)
{
List<Host> hostList = new ArrayList<Host>();
List<Pe> peList = new ArrayList<Pe>();
int mips = 1000;
peList.add(new Pe(0, new PeProvisionerSimple(mips)));
int hostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
int bw = 10000;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
21
new VmSchedulerTimeShared(peList)
)
);
String arch = "x86";
String os = "Linux";
String vmm = "Xen";
double time_zone = 10.0;
double cost = 3.0;
double costPerMem = 0.05;
double costPerStorage = 0.001;
double costPerBw = 0.0;
LinkedList<Storage> storageList = new LinkedList<Storage>();
DatacenterCharacteristics characteristics = new
DatacenterCharacteristics(arch, os, vmm, hostList,
time_zone, cost, costPerMem,
costPerStorage, costPerBw);
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList),
storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
Step 4: Create a Datacenter broker.
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
Where the createBroker() method initializes the entity object from DatacenterBroker class
private static DatacenterBroker createBroker()
{
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}
• Step 5: Create a Virtual Machine(s).
vmlist = new ArrayList<Vm>();
int vmid = 0;
int mips = 1000;
long size = 10000;
int ram = 512;
long bw = 1000;
22
int pesNumber = 1;
String vmm = "Xen";

Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());

vmlist.add(vm);
• Step 6: Submit Virtual Machine to Datacenter broker.
broker.submitVmList(vmlist);
• Step 7: Create Cloudlet(s) by specifying their characteristics.
cloudletList = new ArrayList<Cloudlet>();

int id = 0;
long length = 400000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();

Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize,


outputSize, utilizationModel, utilizationModel,
utilizationModel);

cloudlet.setUserId(brokerId);
cloudlet.setVmId(vmid);

cloudletList.add(cloudlet);
• Step 8: Submit Cloudlets to Datacenter broker.
broker.submitCloudletList(cloudletList);
• Step 9: Send call to Start Simulation.
CloudSim.startSimulation();
• Step 10: Once no more event to execute, send the call to Stop Simulation.
CloudSim.stopSimulation();
• Step 11 : Finally, print the final status of the Simulation.
List<Cloudlet> newList = broker.getCloudletReceivedList();
printCloudletList(newList);
Where printCloudletList() method formats the output to correctly display it on the console.
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

23
+ "Data center ID" + indent + "VM ID" +
indent + "Time" + indent
+ "Start Time" + indent + "Finish Time");

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 +
dft.format(cloudlet.getActualCPUTime())
+ indent + indent +
dft.format(cloudlet.getExecStartTime())
+ indent + indent +
dft.format(cloudlet.getFinishTime()));
}
}
}
Once you Run the example the output for cloudsimExample1.java will be displayed like:

Result :
Thus the Simulation of a cloud scenario using CloudSim and run a scheduling
algorithm has implemented successfully.

24
Ex.No:6 Find a procedure to transfer the files from one virtual machine to
another virtual machine.

Aim:
To Find a procedure to transfer the files from one virtual machine to another virtual
machine.

Procedure:

Step 1: Open Opennebula service from root user and view in localhost:9869
root@linux:$ /etc/init.d/opennebula-sunstone restart

Step 2: Create oneimage, onetemplate and onevm as like earlier


Creating oneimage
oneadmin@linux:~/datastores$ oneimage create --name "Ubuntu" –path
"/home/linux/Downloads/source/tubuntu1404-5.0.1.qcow2c" --driver qcow2 --
datastore default

Creating One Template:


oneadmin@linux:~/datastores$ onetemplate create --name "ubuntu1" --cpu 1 --
vcpu 1 -- memory 1024 --arch x86_64 --disk "Ubuntu" --nic "private" --vnc –ssh

Instantiating OneVm (oneemplate)


oneadmin@linux:~/datastores$ onetemplate instantiate "ubuntu1"

Step 3: To perform a migration. We use onevm command with VM id as


VID = 0 to host02(HID=1)

oneadmin@linux:~/datastores$ onevm migrate --live 0 1

This will move the VM from host01 to host02. The onevm list shows
something like the following

oneadmin@linux:~/datastores$ onevm list


ID USER GROUP NAME STAT CPU MEM HOSTNAME TIME
0 oneadmin oneadmin one-0 runn 0 0k host02 00:00:48

Result :
Thus the virtual machine transfer the files from one virtual machine to
another virtual machine from one node to the other has executed successfully.
25
Ex.No: 7 Install Hadoop single node cluster and run simple applications like
wordcount.

Date:

Aim:
To Install Hadoop single node cluster and run simple applications like wordcount.

Procedure:
Step 1:
Download the latest sun java and apache hadoop from the official website.
Step 2:
To install Java and Hadoop follow the belo lines

######## 1. Install Java


#############################################
a. Extract the Downloaded java tar.gz file in Downloads /
Documents folder b. Open Terminal by pressing ctrl+alt+t
c. In Terminal, type
$gedit ~/.bashrc

d. At the bottom paste the following lines by changing the path alone

#--insert JAVA_HOME
JAVA_HOME= /opt/jdk1.8.0_05
#--in PATH variable just append at the end of the line
PATH=$PATH:$JAVA_HOME/bin
#--Append JAVA_HOME at end of the export statement
export PATH JAVA_HOME

e. Save the configuring by giving command as


$ source ~/.bashrc
f. Check java has been successfully installed by typing
26
$java -version

27
Step 3. Install ssh for passwordless authentication
For passwordless authentication we need to do certain changes by following the
below procedure and we need internet connection.
In Terminal: copy and the paste the below lines
$ sudo apt-get update
### It will ask your root password. Give it

$ sudo apt-get install openssh-server

28
$ sshlocalhost
### It also will ask ask root password

29
$ ssh-keygen(Don't mention any path during key generation)

$ ssh-copy-id -ilocalhost

Step 4. Installation Procedure of Hadoop


As like java, extract hadoop tar.gz file also and do the changes in bashrc file by
copy and paste the following line

30
a. Extract hadoop at java located folder itself (Downloads or Documents)
b. $ gedit ~/.bashrc
paste the following lines below java path (change the path)

#--insert HADOOP_PREFIX
HADOOP_PREFIX=/opt/hadoop-2.7.0
#--in PATH variable just append at the end of the line
PATH=$PATH:$HADOOP_PREFIX/bin
#--Append HADOOP_PREFIX at end of the export statement
export PATH JAVA_HOME HADOOP_PREFIX

c. save it by typing the below command in terminal


$ source ~/.bashrc
d. To check the installed path of Hadoop. Type the command
$ echo $HADOOP_PREFIX
e. Command is to get into the hadoop directory is
$ cd $HADOOP_PREFIX
f. To check the installed hadoop version
$bin/hadoop version

Step 5. Modifying the Hadoop configuration


files
Do the things as like we did before using terminal
(i) cd $HADOOP_PREFIX/etc/hadoop
$ gedit hadoop-env.sh
(paste the java and hadoop path as the first two
lines) export
JAVA_HOME=/usr/local/jdk1.8.0_05 export
HADOOP_PREFIX=/opt/hadoop-2.7.0

31
(ii) Modify the core-
site.xml
$ gedit core-site.xml
Paste the line within
<configuration></configuration>
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>

(iii) Modify the hdfs-


site.xml
$ gedit hdfs-site.xml
Paste the configuration file
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>

(iv) modify the mapred-site.xml


$ cpmapred-site.xml.template mapred-site.xml
$ gedit mapred-site.xml
<configuration>
32
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>

</property>
</configuration>

(v) Modiy yarn-site.xml


>gedit yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>

Step 7. Formatting the HDFS file-system via the NameNode


$ cd $HADOOP_PREFIX
$ bin/hadoopnamenode -format

33
after formatting, start the services

7. Starting the services.


$sbin/start-dfs.sh#######it will start services by taking some time and it will
ask permission give yes.
$sbin/start-
yarn.sh
else
$ sbin/start-all.sh

to check running services


>jps
3200 DataNode
12563 Jps
4036 ResourceManager
4172 NodeManager
5158NameNode
3685 SecondaryNameNode

34
Step 9. Stopping Services
>sbin/stop-
dfs.sh
>sbin/stop-yarn.sh

(or)
>sbin/stop-all.sh

Once you start the services after stopped means it shows only 4 services.
>jps
12563 Jps
4036 ResourceManager

4172 NodeManager
3685 SecondaryNameNode

Step 10. only four services will run. To start datanode and name node we have to add
some lines in hdfs- site.xml
In Terminal
$ cd $HADOOP_PREFIX/etc/hadoop
$gedit hdfs-site.xml (Paste the below lines)

<property>
<name>dfs.namenode.name.dir</name>
<value>/opt/name</value>
</property>

<property>
<name>dfs.datanode.data.dir</name>
<value>/opt/data</value>

35
</property>

Next do these procedures, for creating permanent log storage to namenode and datanode.
$ sudomkdir /opt/name
$ sudomkdir /opt/data
$ ls /opt/
$ ls -l /opt/ ##To change the directory from root user to admin user
$sudochownvrscet:vrscet -R /opt (root should be replaced by your
system username)
$ ls -l /opt/
Step 11. Format the namenode
$ cd $HADOOP_PREFIX
$ bin/hadoopnamenode -format

Step 12. Start services


$sbin/start-dfs.sh
$sbin/start-yarn.sh
$jps
3200 DataNode
12563 Jps
4036 ResourceManager
4172 NodeManager
5158 NameNode
3685 SecondaryNameNode

Step 13. To view in Browser (Open Firefox and enter the below address)
localhost:50070
localhost:80
88

36
Step
14:
Start the hadoop services by giving the following command in terminal
$ sbin/start-all.sh
$ jps
Step 15:
Open web browser and open
localhost:50070
localhost:8088
Step 16:
Creating folder in web interface (HDFS) from terminal.
$ bin/hadoop fs -mkdir /gobi
Wait until the command executes.

37
Step 17:
Open the localhost:50070
Utilities --> Browse the filesytem.
An folder has been created which we had given in terminal

bin/hadoop ----> represents the location of hdfs


fs ---> file system
-mkdir ------> create a folder
/ ------> root in hdfs
bala ----> folder name

Step 18: Loading the data into the folder we created in hdfs
$bin/hadoop fs -copyFromLocal /home/gobi/Pictures /gobi2

Open web browser and under utilities, browse the filesytem and check whether the content is
moved

38
Step 19: Space took by datanode

39
Step 20:
Write a map reduce program on java
Step 21:
Create a folder in HDFS by using the command
$ bin/hadoop fs -mkdir /gobi
Step 22:
Move the number of text file into the hdfs
$ bin/hadoop fs -copyFromLocal /home/gobi/Downloads/data /gobi
Step 23:
use the hadoop-mapreduce-examples-2.7.0.jar which is already available in hadoop.

Step 24:
Run the Mapreduce program by the following command.
$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-
examples-2.7.0.jar wordcount /gobi/data /output

Input file

40
Loaded file

41
Word Count Program:
package org.myorg;

import java.io.IOException;
import java.util.*;

import
org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

publicclass WordCount {

publicstaticclass Map extends Mapper<LongWritable, Text, Text, IntWritable>{


privatefinalstatic IntWritable one =new IntWritable(1);
private Text word =new Text();

publicvoid map(LongWritable key, Text value, Context context)throws IOException,


InterruptedException {
String line =value.toString();
StringTokenizer tokenizer =newStringTokenizer(line);
while(tokenizer.hasMoreTokens()){
word.set(tokenizer.nextToken());
context.write(word, one);

}
}
}

publicstaticclass Reduce extends Reducer<Text, IntWritable, Text, IntWritable>{

publicvoid reduce(Text key, Iterator<IntWritable> values, Context context)


throws IOException, InterruptedException {
int sum =0;
while(values.hasNext()){
sum+= values.next().get();
}
context.write(key,new IntWritable(sum));
}
}

publicstaticvoid main(String[] args)throws Exception {


Configuration conf =newConfiguration();

Job job =newJob(conf,"wordcount");

42
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);

job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);

job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);

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

job.waitForCompletion(true);
}

Executing Map reduce program

Open Localhost --->ouput folder ----> open

43
44
Output :

Result:
Thus, the wordcount program has inducted effectively.

45
Ex.No:8 Creating and Executing Your First Container Using Docker.
Date:

Aim:
To create and executing your first container using docker.

Procedure:
Step1:Docker for Windows
Docker for Windows is our newest offering for PCs. It runs as a native Windows application
and uses Hyper-V to virtualize the Docker Engine environment and Linux kernel-specific features
for the Docker daemon.

Step 2: Install Docker


• Docker for Windows - Install instructions are at Getting Started with Docker for Windows.

Step 3: Verify your installation


1. Open a command-line terminal, and run some Docker commands to verify that Docker is
working as expected.
Some good commands to try are docker version to check that you have the latest release
installed and docker ps to see if you have any running containers. (Probably not, since you
just started.)

->Docker images

46
2. Type the docker run hello-world command and press RETURN.
The command does some work for you, if everything runs well, the command’s output looks
like this:
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
535020c3e8ad: Pull complete
af340544ed62: Pull complete
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker Engine CLI client contacted the Docker Engine daemon.
2. The Docker Engine daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker Engine daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker Engine daemon streamed that output to the Docker Engine CLI client, which
sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/userguide/

$ docker run hello-world

47
Step4:
Run docker ps -a to show all containers on the system.

Push and Pull Containers Additional:


Default:
$ docker pull ubuntu

$ docker images

Open new Command Prompt:

48
$ docker ps

Specific Version Pull Docker:


$ docker pull ubuntu:16.04

$ docker images

49
$ docker ps

Result:
Thus, the docker program created and executed successfully.

50
Ex.No:9 Run a Container from Docker Hub
Date:

Aim:
To create and run a container from docker hub.
Procedure:
Step 1: Install Docker If you haven't already, install Docker on your system following the
instructions for your operating system as mentioned earlier.
Step 2: Search for an image on Docker Hub Visit the Docker Hub website
(https://hub.docker.com/) and use the search bar to find the image you want to run. For example, you
can search for the "nginx" image, which is a popular web server.

Step 3: Pull and run the Docker image Open a terminal (or Command Prompt on Windows) and
use the docker run command with the image name to pull and run the container. For example, to run
the "nginx" image, you can use the following command:
bashCopy code
docker run -d -p 8080:80 nginx
Explanation of the command:
docker run: This command tells Docker to run a container based on the specified image.
-d: This flag runs the container in detached mode, which means it will run in the background.
-p 8080:80: This flag maps port 8080 on the host to port 80 on the container, allowing you to
access the web server from your browser using http://localhost:8080.
nginx: This is the name of the image to be pulled from Docker Hub.
Docker will automatically download the "nginx" image from Docker Hub if it's not already
available on your system and then start a new container based on that image.
Step 4: Access the web server After running the container, open a web browser and navigate to
http://localhost:8080. You should see the default Nginx welcome page, confirming that the container
is running correctly.
Step 5: Stop the container (Optional) If you want to stop the running container, you can use the
following command:
bashCopy code
docker stop <container_id>
To get the <container_id>, you can use the docker ps command to list the running containers
and then stop the container using its ID.

51
Result:
Thus, the docker hub created and executed container successfully.

52
Additional Experiment
Ex.No:10 Develop a new Web Service for Calculator

Aim:
To develop a web service program for a calculator.
Procedures:
Step1. Open netbeans and go to New
Step 2. Choose Java Web and select Web Application and give next.
Step 3. Enter the project name and give next and Select the Server either tomcat
or glassfish
Step 4. Give next and select finish
Step 5. Right click the WebApplication (Projec Name) and Select New, and choose Java
Class

Step 6. Type the following code

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

53
/**
*
* @author cloud_grid_cmp
*/
@WebService(serviceName="MathService", targetNamespace = "http://my.org/ns/")
public class MathService {
@WebMethod(operationName = "hello")
public String hello(@WebParam(name="name")String txt){
return "Hello"+txt+"!";
}
@WebMethod(operationName = "addSer")
public String addSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int
v2){
return "Answer:" +(v1+v2)+"!";
}
@WebMethod(operationName = "subSer")
public String subSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int
v2){

return "Answer:" +(v1-v2)+"!";


}
@WebMethod(operationName = "mulSer")
public String mulSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int
v2){
return "Answer:" +(v1*v2)+"!";
}
@WebMethod(operationName = "divSer")
public String divSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int
v2){
float res = 0;
try
{
res = ((float)v1)/((float) v2);
return "Answer:" +res+"!";
}
catch(ArithmeticException e){
System.out.println("Can't be divided by Zero"+e);
return "Answer:" +e.getMessage().toString()+"!!!";
}
}
}

Step 7. Run Project by pressing F6 key or Run button.

Step 8. Check Web browser


for the following name is available else give it
http://localhost:8080/WebApplication2/MathService?Tester

MathService?Tester ---> represents the java class name

54
Output Screen:

Give some value in the fields and check the out put by pressing enter key.

55
Finally select the WSDL link

Result:

56
Thus, the program on calculator for web services is executed successfully.

Ex.No:10 Cloud Security Management

Aim:
To Study Cloud Security management

Hardware / Software Required: Ubuntu operating system, Virtual machine, WAMP/ZAMP


server, Any tool or technology can be used for implementation of web application e.g., JAVA, PHP,
etc.

Procedure:

Security using MFA(Multi Factor Authentication) device code:


1) goto aws.amazon.com
2) click on "My Account"
3) select "AWS management console" and click on it
4) Give Email id in the required field
if you are registering first time then select "I am a new user" radio button
5) click on "sign in using our secure server" button
6) follow the instruction and complete the formalities
(Note: do not provide any credit card details or bank details)
sign out from
7) Again go to "My Account"
select "AWS management console" and click on it
Sign in again by entering the user name and valid password ( check "I am returning
user and my password is" radio button)
Now you are logged in as a Root User
All AWS project can be viewed by you, but you cant make any changes in it or you
cant create new thing as you are not paying any charges to amazon (for reason
refer step:6)
To create the user in a root user follow the steps mentioned below:
1) click on "Identity and Access Management" in security and identity project
2) click in "Users" from dashboard
It will take you to "Create New Users"
click on create new user button
enter the "User Name"

57
(select "Generate and access key for each user" checkbox, it will create a user with
a specific key)
click on "Create" button at right bottom
3) once the user is created click on it
4) go to security credentials tab
5) click on "Create Access Key", it will create an access key for user.
6) click on "Manage MFA device" it will give you one QR code displayed on the
screen
you need to scan that QR code on your mobile phone using barcode scanner
(install it in mobile phone)you also need to install "Google Authenticator" in your
mobile phone to generate the MFA code
7) Google authenticator will keep on generating a new MFA code after every 60
seconds
that code you will have to enter while logging as a user.
Hence, the security is maintained by MFA device code...
one can not use your AWS account even if it may have your user name and
password, because MFA code is on your MFA device (mobiel phone in this case)
and it is getting changed after every 60 seconds.
Permissions in user account:
After creating the user by following above mentioned steps; you can give certain
permissions to specific user
1) click on created user
2) goto "Permissions" tab
3) click on "Attach Policy" button
4) select the needed policy from given list and click on apply.

Result:
Step 1 :goto aws.amazon.com

58
Step 2 : Click on "My Account". Select "AWS management console" and click on it.
Give Email id in the required field

59
Step 3: Addition of security features

Step 4: Sign in to an AWS account

60
Step 5 : Creation of users

61
Step 6: Adding users to group

Step 7: Creating Access key

62
63
Step 8 : Setting permissions to users

64
Result:
Thus, the Security Cloud Management login successfully.

65

You might also like