Cloud Computing Laboratory
Cloud Computing Laboratory
WOMEN
Approved by AICTE, New Delhi& Affiliated to Anna University, Chennai
Mr.K.A.KARTHICK
Assistant Professor /IT
PRACTICAL EXERCISES: 30 PERIODS
2.Install a C compiler in the virtual machine created using a virtual box and execute Simple
Programs
3.Install Google App Engine. Create a hello world app and other simple web applications using
python/java.
5.Simulate a cloud scenario using CloudSim and run a scheduling algorithm that is not present in
CloudSim.
6.Find a procedure to transfer the files from one virtual machine to another virtual machine.
7.Install Hadoop single node cluster and run simple applications like wordcount.
DATE:
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:
6. Then installation was completed..the show virtual box icon on desktop screen….
Steps to import Open nebula sandbox:
1. Open Virtual box
2.
File import Appliance
3. Browse OpenNebula-Sandbox-5.0.ova file
4. Then go to setting, select Usb and choose USB 1.1
5. Then Start the Open Nebula
6. Login using username: root, password:opennebula
Steps to create Virtual Machine through opennebula
1. Open Browser, type localhost:9869
2. Login using username: oneadmin, password: opennebula
3. Click on instances, select VMs then follow the steps to create Virtaul machine
a. Expand the + symbol
b. Select user oneadmin
c. Then enter the VM name,no.of instance, cpu.
d. Then click on create button.
e. Repeat the steps the C,D for creating more than one VMs.
APPLICATIONS:
There are various applications of cloud computing in today’s network world. Many search engines and social
websites are using the concept of cloud computing like www.amazon.com, hotmail.com, facebook.com,
linkedln.com etc. the advantages of cloud computing in context to scalability is like reduced risk , low cost testing
,ability to segment the customer base and auto-scaling based on application load.
RESULT:
Thus the procedure to run the virtual machine of different configuration.
EX.NO.:2
DATE:
Install a C compiler in the virtual machine created using virtual box
and execute Simple Programs
Aim:
To Install a C compiler in the virtual machine created using virtual box and
execute Simple Programs`
PROCEDURE:
APPLICATIONS:
Simply running all programs in grid environment.
RESULT:
Aim:
To Install Google App Engine. Create hello world app and other simple web
applications using python/java.
Procedure:
Figure – Deselect the “Google Web ToolKit“, and link your GAE Java SDK via the
“configure SDK” link.
Click finished, Google Plugin for Eclipse will generate a sample project automatically.
3. Hello World
Review the generated project directory.
Nothing special, a standard Java web project structure.
HelloWorld/
src/
...Java source code...
META-INF/
...other configuration...
war/
...JSPs, images, data files...
WEB-INF/
...app configuration...
lib/
...JARs for libraries...
classes/
...compiled classes...
Copy
The extra is this file “appengine-web.xml“, Google App Engine need this to run and deploy
the application.
File : appengine-web.xml
</appengine-web-app>
Copy
4. Run it local
Right click on the project and run as “Web Application“.
Eclipse console :
//...
INFO: The server is running at http://localhost:8888/
30 Mac 2012 11:13:01 PM com.google.appengine.tools.development.DevAppServerImpl
start INFO: The admin console is running at http://localhost:8888/_ah/admin
Copy
Access URL http://localhost:8888/, see output
and also the hello world servlet – http://localhost:8888/helloworld
File : appengine-web.xml
</appengine-web-app>
Copy
To deploy, see following steps:
Figure 1.2 – Sign in with your Google account and click on the Deploy button.
Figure 1.3 – If everything is fine, the hello world web application will be deployed to this URL
– http://mkyong123.appspot.com/
Result:
Aim:
To Simulate a cloud scenario using CloudSim and run a scheduling
algorithm that is not present in CloudSim.
Steps:
7. 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())
8. Submit the VM list to the broker:
broker.submitVmList(vmlist)
9. Create a cloudlet with length, file size, output size, and utilisation model:
Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationMode
10. Submit the cloudlet list to the broker:
broker.submitCloudletList(cloudletList)
Sample Output from the Existing Example:
Starting
CloudSimExample1...
Initialising...
Starting CloudSim
version 3.0 Datacenter_0
is starting...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>null
Broker is
starting...
Entities started.
: Broker: Cloud Resource List received with 1
resource(s) 0.0: Broker: Trying to Create VM #0
in Datacenter_0
: Broker: VM #0 has been created in Datacenter #2, Host #0
0.1: Broker: Sending cloudlet 0 to VM #0
400.1: Broker: Cloudlet 0 received
: Broker: All Cloudlets executed.
Finishing... 400.1: Broker: Destroying
VM #0
Broker is shutting down...
Simulation: No more future
events
CloudInformationService: Notify all CloudSim entities
for shutting down. Datacenter_0 is shutting down...
Broker is shutting
down... Simulation
completed.
Simulation completed.
========== OUTPUT ==========
Cloudlet ID STATUS Data center ID VM ID Time Start Time
Finish Time 0 SUCCESS 2 0 400
0.1 400.1
*****Datacenter:
Datacenter_0***** User id
Debt
3 35.6
CloudSimExample1 finished!
RESULT:
Aim:
To Use GAE launcher to launch the web applications.
Steps:
Now you need to create a simple application. We could use the “+” option to have
the launcher make us an application – but instead we will do it by hand to get a
better sense of what is going on.
Make a folder for your Google App Engine applications. I am going to make the
Folder on my Desktop called “apps” – the path to this folder is:
Just for fun, edit the index.py to change the name “Chuck” to your own
name and press Refresh in the browser to verify your updates.
You can watch the internal log of the actions that the web server is performing
when you are interacting with your application in the browser. Select your
application in the Launcher and press the Logs button to bring up a log window:
Each time you press Refresh in your browser – you can see it retrieving
the output with a GET request.
Dealing With Errors
With two files to edit, there are two general categories of errors that you
may encounter. If you make a mistake on the app.yaml file, the App Engine will
not start and your launcher will show a yellow icon near your application:
To get more detail on what is going wrong, take a look at the log for the application:
In this instance – the mistake is mis-‐indenting the last line in the app.yaml (line 8).
If you make a syntax error in the index.py file, a Python trace back error will appear in
your browser.
The error you need to see is likely to be the last few lines of the output – in
this case I made a Python syntax error on line one of our one--‐line application.
Reference: http://en.wikipedia.org/wiki/Stack_trace
When you make a mistake in the app.yaml file – you must the fix the
mistake and attempt to start the application again.
If you make a mistake in a file like index.py, you can simply fix the file
and press refresh in your browser – there is no need to restart the server.
Result:
Aim:
To Find a procedure to transfer the files from one virtual
machine to another virtual machine.
Steps:
1. You can copy few (or more) lines with copy & paste mechanism.
For this you need to share clipboard between host OS and guest OS,
installing Guest Addition on both the virtual machines (probably setting
bidirectional and restarting them). You copy from guest OS in the clipboard
that is shared with the host OS.
Then you paste from the host OS to the second guest OS.
2. You can enable drag and drop too with the same method (Click on the
machine, settings, general, advanced, drag and drop: set to bidirectional )
3. You can have common Shared Folders on both virtual machines
and use one of the directory shared as buffer to copy.
Installing Guest Additions you have the possibility to set Shared Folders too.
As you put a file in a shared folder from host OS or from guest OS, is
immediately visible to the other. (Keep in mind that can arise some
problems for date/time of the files when there are different clock settings on
the different virtual machines).
If you use the same folder shared on more machines you can exchange
files directly copying them in this folder.
4. You can use usual method to copy files between 2 different computer with
client-server application. (e.g. scp with sshd active for linux, winscp... you
can get some info about SSH servers e.g. here)
You need an active server (sshd) on the receiving machine and a client
on the sending machine. Of course you need to have the authorization
setted (via password or, better, via an automatic authentication method).
Note: many Linux/Ubuntu distribution install sshd by default: you can see
if it is running with pgrep sshd from a shell. You can install with sudo apt-
get install openssh-server.
5. You can mount part of the file system of a virtual machine via NFS
or SSHFS on the other, or you can share file and directory with
Samba. You may find interesting the article Sharing files between
guest and host without VirtualBox shared folders with detailed step
by step instructions.
You should remember that you are dialling with a little network of
machines with different operative systems, and in particular:
Each virtual machine has its own operative system running on and
acts as a physical machine.
Each virtual machine is an instance of a program owned by an user in the
hosting operative system and should undergo the restrictions of the user in
the hosting OS.
E.g Let we say that Hastur and Meow are users of the hosting machine, but
they did not allow each other to see their directories (no read/write/execute
authorization). When each of them run a virtual machine, for the hosting OS
those virtual machine are two normal programs owned by Hastur and Meow
and cannot see the private directory of the other user. This is a restriction due
to the hosting OS. It's easy to overcame it: it's enough to give authorization to
read/write/execute to a directory or to chose a different directory in which
both users can read/write/execute.
Windows likes mouse and Linux fingers. :-)
I mean I suggest you to enable Drag & drop to be cosy with the
Windows machines and the Shared folders or to be cosy with Linux.
When you will need to be fast with Linux you will feel the need of ssh-keygen and
to Generate once SSH Keys to copy files on/from a remote machine without writing
password anymore. In this way it functions bash auto-completion remotely too!
PROCEDURE:
Steps:
1. Open Browser, type localhost:9869
2. Login using username: oneadmin, password: opennebula
3. Then follow the steps to migrate VMs
a. Click on infrastructure
b. Select clusters and enter the cluster name
c. Then select host tab, and select all host
d. Then select Vnets tab, and select all vnet
e. Then select datastores tab, and select all datastores
f. And then choose host under infrastructure tab
g. Click on + symbol to add new host, name the host then click on create.
4. on instances, select VMs to migrate then follow the stpes
a. Click on 8th icon ,the drop down list display
b. Select migrate on that ,the popup window display
c. On that select the target host to migrate then click on migrate.
Before migration
Host:SACET
Host:one-sandbox
After Migration:
Host:one-sandbox
Host:SACET
APPLICATIONS:
Easily migrate your virtual machine from one pc to another.
Result:
Thus the file transfer between VM was successfully completed…..
EX.NO:7
DATE:
Find a procedure to launch virtual machine using trystack
(Online Openstack Demo Version)
Aim:
To Find a procedure to launch virtual machine using trystack.
Steps:
TryStack.org Homepage
I assume that you already join to the Facebook Group and login to the dashboard.
After you log in to the TryStack, you will see the Compute Dashboard like:
OpenStack Compute Dashboard
Overview: What we will do?
In this post, I will show you how to run an OpenStack instance. The instance
will be accessible through the internet (have a public IP address). The final
topology will like:
Network topology
As you see from the image above, the instance will be connected to a
local network and the local network will be connected to internet.
Network? Yes, the network in here is our own local network. So, your
instances will be not mixed up with the others. You can imagine this as your
own LAN (Local Area Network) in the cloud.
1. Go to Network > Networks and then click Create Network.
2. In Network tab, fill Network Name for example internal and then click Next.
3. In Subnet tab,
1. Fill Network Address with appropriate CIDR, for example
192.168.1.0/24. Use private network CIDR block as the best practice.
2. Select IP Version with appropriate IP version, in this case IPv4.
3. Click Next.
4. In Subnet Details tab, fill DNS Name Servers with 8.8.8.8
(Google DNS) and then click Create.
Now, we will create an instance. The instance is a virtual machine in the cloud,
like AWS EC2. You need the instance to connect to the network that we just
created in the previous step.
1. Go to Compute > Instances and then click Launch Instance.
2. In Details tab,
1. Fill Instance Name, for example Ubuntu 1.
2. Select Flavor, for example m1.medium.
3. Fill Instance Count with 1.
4. Select Instance Boot Source with Boot from Image.
5. Select Image Name with Ubuntu 14.04 amd64 (243.7 MB) if you want install Ubuntu
14.04 in your virtual machine.
3. In Access & Security tab,
1. Click [+] button of Key Pair to import key pair. This key pair is a public
and private key that we will use to connect to the instance from our machine.
2. In Import Key Pair dialog,
1. Fill Key Pair Name with your machine name (for example Edward-Key).
2. Fill Public Key with your SSH public key (usually is in
~/.ssh/id_rsa.pub). See description in Import Key Pair dialog box for
more information. If you are using Windows, you can use Puttygen
to generate key pair.
3. Click Import key pair.
3. In Security Groups, mark/check default.
4. In Networking tab,
1. In Selected Networks, select network that have been created in Step 1, for example internal.
5. Click Launch.
6. If you want to create multiple instances, you can repeat step 1-5. I created one
more instance with instance name Ubuntu 2.
Step 3: Create Router
I guess you already know what router is. In the step 1, we created our network,
but it is isolated. It doesn’t connect to the internet. To make our network has an
internet connection, we need a router that running as the gateway to the internet.
1. Go to Network > Routers and then click Create Router.
2. Fill Router Name for example router1 and then click Create router.
3. Click on your router name link, for example router1, Router Details page.
4. Click Set Gateway button in upper right:
1. Select External networks with external.
2. Then OK.
5. Click Add Interface button.
1. Select Subnet with the network that you have been created in Step 1.
2. Click Add interface.
6. Go to Network > Network Topology. You will see the network topology. In the
example, there are two network, i.e. external and internal, those are bridged by a
router. There are
instances those are joined to internal network.
Now, you can SSH your instances to the floating IP address that you got in
the step 4. If you are using Ubuntu image, the SSH user will be ubuntu.
Result:
Thus the openstack demo worked successfully.
EX NO:8
DATE :
Install Hadoop single node cluster and run simple
applications like wordcount.
Aim:
To Install Hadoop single node cluster and run
simple applications like wordcount.
Steps:
Install Hadoop
Step 1: Click here to download the Java 8 Package. Save this file in your
home directory.
5: Add the Hadoop and Java paths in the bash file (.bashrc). Open. bashrc
Command: vi .bashrc
For applying all these changes to the current Terminal, execute the source
command. Command: source .bashrc
To make sure that Java and Hadoop have been properly installed on your system and can be
accessed through the Terminal, execute the java -version and hadoop version commands.
Command: cd hadoop-2.7.3/etc/hadoop/
Command: ls
All the Hadoop configuration files are located in hadoop-2.7.3/etc/hadoop directory as you
can see in the snapshot below:
core-site.xml informs Hadoop daemon where NameNode runs in the cluster. It contains
configuration settings of Hadoop core such as I/O settings that are common to HDFS &
MapReduce.
Command: vi core-site.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2 <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
3 <configuration>
4 <property>
5 <name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
6 </property>
7 </configuration>
8
Step 8: Edit hdfs-site.xml and edit the property mentioned below inside
configuration tag:
Command: vi hdfs-site.xml
Fig: Hadoop Installation – Configuring hdfs-site.xml
1
2 <?xml version="1.0" encoding="UTF-8"?>
3 <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
4
<property>
5 <name>dfs.replication</name>
6 <value>1</value>
7 </property>
<property>
8
<name>dfs.permission</name>
9 <value>false</value>
10 </property>
</configuration>
11
Step 9: Edit the mapred-site.xml file and edit the property mentioned below
inside configuration tag:
In some cases, mapred-site.xml file is not available. So, we have to create the mapred- site.xml
file using mapred-site.xml template.
Command: vi mapred-site.xml.
Fig: Hadoop Installation – Configuring mapred-site.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
3 <configuration>
4 <property>
5 <name>mapreduce.framework.name</name>
<value>yarn</value>
6
</property>
7 </configuration>
8
Step 10: Edit yarn-site.xml and edit the property mentioned below inside
configuration tag:
Command: vi yarn-site.xml
Step 11: Edit hadoop-env.sh and add the Java Path as mentioned below:
1
2
<?xml version="1.0">
3 <configuration>
4 <property>
5 <name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
6
</property>
7 <property>
8 <name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</
9 name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
1
</property>
0 </configuration>
1
hadoop-env.sh contains the environment variables that are used in the script to run
Hadoop like Java home path, etc.
Command: vi hadoop–env.sh
Command: cd
Command: cd hadoop-2.7.3
This formats the HDFS via NameNode. This command is only executed for the first
time. Formatting the file system means initializing the directory specified by the
dfs.name.dir variable.
Never format, up and running Hadoop filesystem. You will lose all your data stored in
the HDFS.
Step 13: Once the NameNode is formatted, go to hadoop-2.7.3/sbin directory and start all the daemons.
Command: cd hadoop-2.7.3/sbin
Either you can start all daemons with a single command or do it individually.
Command: ./start-all.sh
The NameNode is the centerpiece of an HDFS file system. It keeps the directory tree of all
files stored in the HDFS and tracks all the file stored across the cluster.
Start DataNode:
On startup, a DataNode connects to the Namenode and it responds to the requests from
the Namenode for different operations.
Start ResourceManager:
ResourceManager is the master that arbitrates all the available cluster resources and
thus helps in managing the distributed applications running on the YARN system. Its
work is to manage each NodeManagers and the each application’s ApplicationMaster.
Start NodeManager:
The NodeManager in each machine framework is the agent which is responsible for
managing containers, monitoring their resource usage and reporting the same to the
ResourceManager.
Start JobHistoryServer:
JobHistoryServer is responsible for servicing all job history related requests from
Step 14: To check that all the Hadoop services are up and running, run the
below command.
Command: jps
Result:
Thus the Hadoop one cluster was installed and simple applications
executed successfully.
Ex No: CREATING AND EXECUTING YOUR FIRST CONTAINER USING DOCKER
Date:
Aim:
To create and execute the first container using Docker
Procedure:
Install Docker:
EXPOSE 80
Cleanup (Optional):
Notes:
- This is a basic example, and real-world applications may require
more complex Dockerfiles and configurations.
- Docker Hub (https://hub.docker.com) is a repository for Docker
images. You can explore and use official images or publish your own.
- Docker Compose is a tool for defining and running multi-container
Docker applications. It's useful for more complex setups.
Result:
Ex No: RUN A CONTAINER FROM DOCKER HUB
Date:
Procedure:
Result: