EX.
NO :1
Lab on web services
Aim:
To design, develop, and deploy a simple RESTful web service using Python Flask and understand
its deployment on a cloud platform.
Objectives
To understand the concept of web services in cloud computing
To develop REST APIs using Flask
To deploy a Python web application on a cloud platform
Software Requirements
Python 3.8 or above
Flask 2.0 or above
Google Cloud Platform / AWS (any one)
Web browser
Hardware Requirements
Computer with minimum 4 GB RAM
Internet connection
Algorithm
1. Import Flask, request, and jsonify modules.
2. Create a Flask application instance.
3. Create an in-memory data store.
4. Define REST endpoints using HTTP methods (GET, POST).
5. Run the Flask application.
6. Deploy the application on a cloud platform.
PROGRAM :
from flask import Flask, jsonify, request
app = Flask(__name__)
# Sample in-memory data store
data_store = {
"1": {"name": "John Doe", "age": 30},
"2": {"name": "Jane Doe", "age": 25}
@[Link]('/users', methods=['GET'])
def get_users():
return jsonify(list(data_store.values()))
@[Link]('/users/<string:user_id>', methods=['GET'])
def get_user(user_id):
user = data_store.get(user_id)
if user:
return jsonify(user)
else:
return jsonify({"error": "User not found"}), 404
@[Link]('/users', methods=['POST'])
def create_user():
user_data = [Link]
new_user_id = str(len(data_store) + 1)
data_store[new_user_id] = user_data
return jsonify(user_data), 201
if __name__ == '__main__':
[Link](debug=True)
Output
GET /users → Displays list of users
GET /users/1 → Displays user details
POST /users → Adds a new user
Result
Thus, a RESTful web service was successfully developed using Flask and deployed on
a cloud platform
[Link] :-
Lab on IPC, messaging, publish/subscribe
Aim
To study and implement Inter-Process Communication (IPC), Messaging, and
Publish/Subscribe communication model using Python, and to understand their significance in
cloud computing environments.
Objectives
To understand the concept of Inter-Process Communication.
To implement message-based communication between processes.
To study and implement the Publish/Subscribe model.
To understand the role of messaging models in cloud computing
Software / Hardware Requirements
Hardware Requirements
Processor: Intel / AMD based system
RAM: Minimum 4 GB
Software Requirements
Operating System: Linux / Ubuntu / Windows
Programming Language: Python 3.x
Tools/Libraries:
o multiprocessing
o queue
o paho-mqtt
MQTT Broker: Mosquitto (Local)
2(a) : IPC using Message Queue
Algorithm
1. Create a message queue.
2. Create a sender process to send data.
3. Create a receiver process to receive data.
4. Execute both processes concurrently.
Program
from multiprocessing import Process, Queue
def sender(q):
[Link]("Hello from Sender Process")
def receiver(q):
msg = [Link]()
print("Received:", msg)
if __name__ == "__main__":
q = Queue()
p1 = Process(target=sender, args=(q,))
p2 = Process(target=receiver, args=(q,))
[Link]()
[Link]()
[Link]()
[Link]()
Output
Received: Hello from Sender Process
2(b): Messaging using Producer–Consumer Model
Algorithm
1. Create a message queue.
2. Producer sends messages to the queue.
3. Consumer reads messages from the queue.
Program
import queue
q = [Link]()
# Producer
for i in range(5):
[Link](f"Message {i+1}")
# Consumer
while not [Link]():
print("Consumed:", [Link]())
Output
Consumed: Message 1
Consumed: Message 2
Consumed: Message 3
Consumed: Message 4
Consumed: Message 5
2©: Publish/Subscribe using MQTT
Algorithm
1. Start MQTT broker.
2. Create a publisher to send messages to a topic.
3. Create a subscriber to receive messages.
4. Observe message delivery.
Publisher Program
import [Link] as mqtt
import time
client = [Link]()
[Link]("localhost", 1883, 60)
for i in range(5):
[Link]("cloud/lab", f"Message {i+1}")
print("Published Message", i+1)
[Link](1)
[Link]()
Subscriber Program
import [Link] as mqtt
def on_message(client, userdata, msg):
print("Received:", [Link]())
client = [Link]()
[Link]("localhost", 1883, 60)
[Link]("cloud/lab")
client.on_message = on_message
client.loop_forever()
Output
Received: Message 1
Received: Message 2
Received: Message 3
Received: Message 4
Received: Message 5
Applications
Cloud microservices communication
Event-driven cloud systems
IoT data processing
Real-time messaging systems
Result
Thus, Inter-Process Communication, Messaging, and Publish/Subscribe mechanisms were
successfully implemented using Python and their role in cloud computing was studied.
[Link] :-
Install VirtualBox / VMware Workstation with different flavors of Linux or
windows OS on top of windows7 or 8.
AIM
To Install VirtualBox / VMware Workstation with different flavors of Linux or windows OS on
top of win
PROCEDURE:
Steps to install Virtual Box:
[Link] the Virtual box exe and click the exe file…and select next button..
[Link] the next button..:-
[Link] the next button :-
4. Click the YES button :-
[Link] the install button
6. Then installation was completed. The show virtual box icon on desktop screen….
Steps to import Open nebula sandbox:
[Link] Virtual box
[Link] import Appliance
[Link] [Link] file
[Link] go to setting, select Usb and choose USB 1.1
[Link] Start the Open Nebula
[Link] using username: root, password:opennebul
Steps to create Virtual Machine through open nebula
1. Open Browser, type localhost:9869
2. Login using username: one admin, password: open nebula
3. Click on instances, select VMs then follow the steps to create Virtual machine
a. Expand the + symbol
b. Select user one admin
c. Then enter the VM name ,no. of instance, CPU.
d. Then click on create button.
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 [Link],
[Link], [Link], [Link] 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.
[Link] :-
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:
Steps to import .ova file:
[Link] Virtual box
2. File →import Appliance
3. Browse ubuntu_gt6.ova file
4. Then go to setting, select Usb and choose USB 1.1
5. Then Start the ubuntu_gt6
[Link] using username: dinesh, password:99425.
Steps to run c program:
1. Open the terminal
2. Type cd /opt/axis2/axis2-1.7.3/bin then press enter
3. gedit hello.c
4. gcc hello.c
5. ./[Link]
Type cd /opt/axis2/axis2-1.7.3/bin then press enter
Type gedit first.c
Type the c program
Running the C program:-
Display the output:
APPLICATIONS:
Simply running all programs in grid environment.
RESULT:
Thus the simple C programs executed successfully.
[Link] :-
Create an Amazon EC2 instance and set up a web-server on the instance and associate an IP
address with the instance. In the process, create a security group allowing access to port 80 on
the instance.
Aim ;-
To create an Amazon Elastic Compute Cloud (EC2) instance using the AWS Management
Console and connect to it securely using an SSH key pair.
Software Requirements
AWS Account
Web Browser (Google Chrome / Firefox)
Terminal (Linux/macOS) or PuTTY (Windows)
Hardware Requirements
Computer system with internet access
PROCEDURE :-
Steps to Create EC2 Instance in AWS (Amazon)
Follow the below steps to create an EC2 instance in AWS (Amazon):
Step 1: Login and Navigate to EC2 Dashboard
Log in to your AWS Management Console.
From the Services menu, choose EC2 under the Compute section.
Under Resources, click Instances (Running) to view running instances (if any).
Under Resources >> Click on "Instances running" -- It will show if any EC2 instances are
running or not.
Step 2: Launch a New Instance
Click Launch Instance.
On the "Launch an Instance" page, enter a name for your instance (e.g., my-first-ec2-
server).
You'll now configure your server settings.
Step 3: Choose Amazon Machine Image
Select an Amazon Machine Image (AMI), which is the OS for your server.
For beginners, choose Amazon Linux 2, Ubuntu, or Windows, depending on your
needs.
AMIs come preconfigured with OS and some software like templates.
Step 4: Select Instance Type
Select the instance type (defines CPU and memory).
For Free Tier, choose [Link] — 1 vCPU and 1 GB RAM.
Avoid selecting higher types like [Link], [Link], etc., unless needed, as they may
incur charges.
Step 5: Configure Key Pair
1. EC2 instances use SSH key pairs for secure access.
2. Click Create new key pair:
Enter a name.
Choose file format: .pem for Linux/macOS or .ppk for Windows (for PuTTY).
Download the key file and save it securely (you won’t be able to download it again).
3. Select the created key pair from the dropdown.
Creating key pair
Step 6: Network and Storage Configuration
1. Network Settings: Use the default VPC and subnet unless you have specific networking
needs.
2. Firewall (Security Group): Allow SSH (port 22) for Linux or RDP (port 3389) for
Windows.
3. Storage Settings:
Free Tier allows up to 30 GB of General Purpose SSD (gp2).
Keep default (8 GB) or increase as needed.
Step 7: Review and Launch
Review all configurations to ensure they are Free Tier eligible.
Click Launch Instance.
You will see a confirmation page. Click View Instances to see your new server being
initialized.
Steps to Connect Terminal Using SSH-Key
Once your instance is launched, secure access is essential. Follow the below steps to know how
to connect using a terminal and your key pair.
Step 1: Locate Connection Details
Select the server to which you want to connect and click on the connect button at the top of that
instance as shown in the image below.
Step 2: Copy the SSH Command
Copy the SSH key which is right following the example it will acct as a key-pair to connect to
EC2-Instance.
Step 3: Use Terminal
Open the terminal and go to the folder where your .pem file is located and paste the key that you
have copied in AWS and paste it in the terminal.
To know whether you connected to EC2-Instance perfectly or not you can check the IP-
Address of the instance if the IP is displaying then you have connected successfully.
[Link]: 6 :-
Do the same with OpenStack
Aim
To create a virtual machine (instance) using OpenStack, configure network and security rules,
associate a floating IP address, and deploy a web server accessible through port 80.
Hardware Requirements
System with minimum 4 GB RAM
Internet / LAN connectivity
Software Requirements
Operating System: Linux (Ubuntu preferred)
OpenStack (DevStack / Private Cloud Setup)
Web Browser
SSH Client
Theory
OpenStack
OpenStack is an open-source cloud computing platform used to build and manage private and
public clouds. It provides Infrastructure as a Service (IaaS) similar to Amazon EC2.
Main OpenStack components:
Nova – Compute service
Neutron – Networking service
Glance – Image service
Keystone – Identity service
Horizon – Dashboard
Floating IP
A Floating IP is a public IP address that allows external access to an OpenStack instance from
outside the private network.
Security Group
A security group in OpenStack acts as a virtual firewall that controls inbound and outbound
traffic to instances.
Procedure
Step 1: Login to OpenStack Dashboard (Horizon)
1. Open browser and enter OpenStack dashboard URL
2. Login using provided credentials
Step 2: Create Key Pair
1. Navigate to Project → Compute → Key Pairs
2. Click Create Key Pair
3. Download and save the key file
Step 3: Create Security Group
1. Navigate to Project → Network → Security Groups
2. Create a new security group
3. Add inbound rules:
o SSH – Port 22 – Source: [Link]/0
o HTTP – Port 80 – Source: [Link]/0
Step 4: Launch Instance
1. Navigate to Project → Compute → Instances
2. Click Launch Instance
3. Select instance name
4. Choose image (Ubuntu / Cirros)
5. Select flavor
6. Assign key pair and security group
7. Launch the instance
Step 5: Allocate and Associate Floating IP
1. Go to Project → Network → Floating IPs
2. Allocate a new floating IP
3. Associate the floating IP with the instance
Step 6: Connect to Instance via SSH
ssh -i [Link] ubuntu@<Floating-IP>
Step 7: Install Web Server (Apache)
sudo apt update
sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2
Step 8: Create Sample Web Page
echo "<h1>Welcome to OpenStack Cloud Lab</h1>" | sudo tee /var/www/html/[Link]
Step 9: Access Web Server
1. Copy the floating IP address
2. Paste it in the browser
3. Verify web page output
Commands Used
sudo apt install apache2 -y
sudo systemctl start apache2
Output
The web page “Welcome to OpenStack Cloud Lab” is displayed in the browser using the
floating IP address.
[Link]: 7 :-
Install Google App Engine. Create a hello world app and other simple web applications
using python/java.
Aim:
Aim:
To Install Google App Engine. Create hello world app and other simple web
applications using python/java.
Procedure:
1. Install Google Plugin for Eclipse
Read this guide – how to install Google Plugin for Eclipse. If you install the
Google App Engine Java SDK together with “Google Plugin for Eclipse“, then go
to step 2, Otherwise, get the Google App Engine Java SDK and extract it.
2. Create New Web Application Project
In Eclipse toolbar, click on the Google icon, and select “New Web Application
Project…”
Figure – New Web Application Project
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 “[Link]“, Google App Engine need this to run
and deploy the application.
File : [Link]
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app
xmlns="[Link]
<application></application>
<version>1</version>
<!-- Configure [Link] -->
<system-properties>
<property name="[Link]"
value="WEB-INF/[Link]"/> </system-properties>
</appengine-web-app>
4. Run it local
Right click on the project and run as “Web Application“.
Eclipse console :
//...
INFO: The server is running at [Link]
30 Mac 2012 [Link] PM
[Link] start INFO: The
admin console is running at [Link]
Copy
Access URL [Link] see output
5. Deploy to Google App EngineRegister an account on
[Link] and create an application ID for your web
application.
In this demonstration, I created an application ID, named “mkyong123”, and put it
in [Link].
File : [Link]
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="[Link]
<application>mkyong123</application> <version>1</version>
<!-- Configure [Link] -->
<system-properties>
<property name="[Link]"
value="WEB-INF/[Link]"/> </system-properties>
</appengine-web-app>
Copy
To deploy, see following steps:
Result :
Thus the simple application was created successfully.
[Link]: 8 :-
Start a Docker container and set up a web-server (e.g. apache2 or Python
based Flask micro web framework) on the instance. Map the host directory as
a data volume for the container
Aim :
To start a Docker container, deploy a web server (Apache2 / Flask) inside the
container, and map a host directory as a data volume to the container.
Hardware Requirements
System with minimum 4 GB RAM
Internet connectivity
Software Requirements
Operating System: Linux / Ubuntu
Docker Engine
Web Browser
Procedure
Step 1: Install Docker
sudo apt update
sudo apt install [Link] -y
sudo systemctl start docker
sudo systemctl enable docker
Step 2: Create Host Directory
mkdir dockerdata
cd dockerdata
echo "<h1>Welcome to Docker Cloud Lab</h1>" > [Link]
Step 3: Run Apache Web Server Container with Volume Mapping
sudo docker run -d \
--name webcontainer \
-p 8080:80 \
-v $(pwd):/usr/local/apache2/htdocs/ \
httpd
Step 4: Verify Running Container
sudo docker ps
Step 5: Access Web Server
1. Open a web browser
2. Enter URL: [Link]
3. Verify the displayed web page
Commands Used
docker run
docker ps
docker build
Output
The web page is successfully displayed from the Docker container, and data is
shared between the host and container using volume mapping.
[Link]: 9 :-
Find a procedure to transfer the files from one virtual machine to another
virtual machine. Similarly, from one container to another container.
AIM :
To Find a procedure to transfer the files from one virtual machine to
another virtual machine. Similarly, from one container to another container
Steps:
[Link] 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.
[Link] can enable drag and drop too with the same method (Click on the
machine, settings, general, advanced, drag and drop: set to bidirectional )
[Link] 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.
[Link] 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.
[Link] 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:
[Link] Browser, type localhost:9869
[Link] using username: oneadmin, password: opennebula
[Link] follow the steps to migrate VMs
[Link] on infrastructure
[Link] clusters and enter the cluster name
[Link] select host tab, and select all host
[Link] select Vnets tab, and select all vnet
[Link] select datastores tab, and select all datastores
[Link] then choose host under infrastructure tab
[Link] on + symbol to add new host, name the host then click on create.
[Link] instances, select VMs to migrate then follow the steps
[Link] on 8th icon ,the drop down list display
[Link] migrate on that ,the popup window display
c. On that select the target host to migrate then click on migrate.
Host:SACET
Host:one-sandbox
After Migration:
APPLICATIONS:
Easily migrate your virtual machine from one pc to another.
Result:
Thus the file transfer between VM was successfully completed…..
9(b) File Transfer Between Two Docker Containers
Using docker cp Command
Procedure
Method 1: Using docker cp Command
Procedure
1. Identify source and destination container names
2. Copy file from source container to host
3. Copy file from host to destination container
Commands
docker cp container1:/app/[Link] ./[Link]
docker cp [Link] container2:/app/[Link]
Method 2: Using Shared Docker Volume
Procedure
1. Create a Docker volume
2. Attach the same volume to multiple containers
3. Share files through the volume
Commands
docker volume create sharedvol
docker run -d --name c1 -v sharedvol:/data ubuntu
docker run -d --name c2 -v sharedvol:/data ubuntu
Output
Files are successfully transferred between:
One Docker container to another Docker container
[Link]: 10 :-
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:
OpenStack is an open-source software cloud computing platform.
OpenStack is primarily used for deploying an infrastructure as a service (IaaS)
solution like Amazon Web Service (AWS). In other words, you can make your own
AWS by using OpenStack. If you want to try out OpenStack, TryStack is the
easiest and free way to do [Link] order to try OpenStack in TryStack, you must
register yourself by joining TryStack Facebook Group. The acceptance of group
needs a couple days because it’s approved manually. After you have been accepted
in the TryStack Group, you can log in TryStack.
[Link] Homepage I assume that you already join to the Facebook Group and login to the
[Link] you log in to the TryStack, you will see the Compute Dashboard 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.
Step 1: Create Network
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.
[Link] to Network > Networks and then click Create Network.
[Link] Network tab, fill Network Name for example internal and then click Next.
[Link] Subnet tab,
[Link] Network Address with appropriate CIDR, for example192.168.1.0/24. Use private
network CIDR block as the best practice.
[Link] IP Version with appropriate IP version, in this case IPv4.
[Link] Next.
[Link] Subnet Details tab, fill DNS Name Servers with [Link] (Google DNS) and then click
Create.
Step 2: Create Instance
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 [Link].
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.
[Link] 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.
[Link] Security Groups, mark/check default.
[Link] Networking tab,
[Link] Selected Networks, select network that have been created in Step 1, for example
internal.
[Link] Launch.
[Link] 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.
Step 4: Configure Floating IP Address
Floating IP address is public IP address. It makes your instance is accessible from the
internet. When you launch your instance, the instance will have a private network IP, but no
public IP. In OpenStack, the public Ips is collected in a pool and managed by admin (in our
case is TryStack). You need to request a public
(floating) IP address to be assigned to your instance.
1. Go to Compute > Instance.
2. In one of your instances, click More > Associate Floating IP.
3. In IP Address, click Plus [+].
4. Select Pool to external and then click Allocate IP.
5. Click Associate.
6. Now you will get a public IP, e.g. [Link], for your instance.
Step 5: Configure Access & Security
OpenStack has a feature like a firewall. It can whitelist/blacklist your in/out connection. It is
called Security Group.
1. Go to Compute > Access & Security and then open Security Groups tab.
2. In default row, click Manage Rules.
3. Click Add Rule, choose ALL ICMP rule to enable ping into your instance, and then click
Add.
4. Click Add Rule, choose HTTP rule to open HTTP port (port 80), and then click Add.
5. Click Add Rule, choose SSH rule to open SSH port (port 22), and then click Add.
6. You can open other ports by creating new rules.
Step 6: SSH to Your Instance
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.
[Link] :11
Install Hadoop single node cluster and run simple applications like word
count.
Aim:
To Install Hadoop single node cluster and run simple applications like
wordcount.
PROGRAM
Steps:
Install Hadoop
Step 1: Click here to download the Java 8 Package. Save this file in your
home directory.
Step 2: Extract the Java Tar File.
Command: tar -xvf [Link]
Fig: Hadoop Installation – Extracting Java Files
Step 3: Download the Hadoop 2.7.3 Package.
Command: wget
[Link]
Fig: Hadoop Installation – Downloading Hadoop
Step 4: Extract the Hadoop tar File.
Command: tar -xvf [Link]
Fig: Hadoop Installation – Extracting Hadoop Files
Step 5: Add the Hadoop and Java paths in the bash file (.bashrc).
Open. bashrc file. Now, add Hadoop and Java Path as shown below.
Command: vi .bashrc
Fig: Hadoop Installation – Setting Environment Variable
Then, save the bash file and close it.
For applying all these changes to the current Terminal, execute the source command.
Command: source .bashrc
Fig: Hadoop Installation – Refreshing environment variables
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: java -version
Fig: Hadoop Installation – Checking Java Version
Command: hadoop version
Fig: Hadoop Installation – Checking Hadoop Version
Step 6: Edit the Hadoop Configuration files.
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:
configuration tag:
[Link] contains configuration settings of HDFS daemons (i.e. NameNode,
DataNode, Secondary NameNode). It also includes the replication factor and block
size of HDFS.
Command: vi [Link]
Fig: Hadoop Installation – Configuring [Link]
Step 9: Edit the [Link] file and edit the property mentioned below
inside configuration tag:
[Link] contains configuration settings of MapReduce application like number
of JVM that can run in parallel, the size of the mapper and the reducer process, CPU
cores available for a process, etc.
In some cases, [Link] file is not available. So, we have to create the mapred-
[Link] file using [Link] template.
Command: cp [Link] [Link]
Command: vi [Link]
Fig: Hadoop Installation – Configuring [Link]
Step 10: Edit [Link] and edit the property mentioned below inside
configuration tag:
[Link] contains configuration settings of ResourceManager and NodeManager
like application memory management size, the operation needed on program &
algorithm, etc.
Command: vi [Link]
Step 11: Edit [Link] and add the Java Path as mentioned below:
[Link] contains the environment variables that are used in the script to run
Hadoop like Java home path, etc.
Command: vi hadoop–[Link]
Fig: Hadoop Installation – Configuring [Link]
Step 12: Go to Hadoop home directory and format the NameNode.
Command: cd
Command: cd hadoop-2.7.3
Command: bin/hadoop namenode -format
Fig: Hadoop Installation – Formatting NameNode
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 [Link] 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: ./[Link]
The above command is a combination of [Link], [Link] & mr-
[Link]
Or you can run all the services individually as below:
Start NameNode:
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.
Command: ./[Link] start namenode
Start DataNode:
On startup, a DataNode connects to the Namenode and it responds to the requests
from the Namenode for different operations.
Command: ./[Link] start datanode
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 Application Master
Command: ./[Link] start resourcemanager
Fig: Hadoop Installation – Starting ResourceManager
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.
Command: ./[Link] start nodemanager
Fig: Hadoop Installation – Starting NodeManager
Start JobHistoryServer:
JobHistoryServer is responsible for servicing all job history related requests from client.
Command: ./[Link] start historyserver
Step 14: To check that all the Hadoop services are up and running, run the below
command.
Command: jps
Fig: Hadoop Installation – Checking Daemons
Step 15: Now open the Mozilla browser and go to
localhost:50070/[Link] to check the NameNode interface.
Fig: Hadoop Installation – Starting WebUI
Congratulations, you have successfully installed a single node Hadoop cluster
Result:
Thus the Hadoop one cluster was installed and simple applications
executed successfully.
[Link] :12
Utilize OpenFaaS – Serverless computing framework and demonstrate basic
event driven function invocation.
Aim :
To deploy and invoke a serverless function using OpenFaaS and
demonstrate event-driven execution.
PROGRAM :
Step 1: Install Docker (if not installed)
sudo apt update
sudo apt install [Link] -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
newgrp docker
Step 2: Install OpenFaaS CLI (faas-cli)
curl -sSL [Link] | sudo sh
faas-cli version
Step 3: Deploy OpenFaaS (Using Docker Swarm) Initialize Docker Swarm
docker swarm init
Deploy OpenFaaS Stack
git clone [Link]
cd faas
./deploy_stack.sh
Step 4: Access OpenFaaS Gateway
docker service ls
Open browser:
[Link]
Default credentials:
Username: admin
Password:
docker secret inspect basic-auth-password -f '{{.[Link]}}' | base64 –decode
Step 5: Create a Serverless Function (Event Driven)
Create a Python Function
faas-cli new hello-event --lang python3
cd hello-event
Step 6: Write Function Code
def handle(event, context):
name = [Link]('utf-8')
if not name:
name = "World"
return f"Hello {name}! Event received successfully."
Step 7: Deploy the Function
faas-cli build -f [Link]
faas-cli deploy -f [Link]
Step 8: Invoke Function (Event Trigger)
Invoke using CLI
echo "OpenFaaS" | faas-cli invoke hello-event
Output
Hello OpenFaaS! Event received successfully.
Step 9: Invoke via HTTP (Event-Driven)
curl -X POST [Link] -d "Serverless"
Output
Hello Serverless! Event received successfully.
Result
Thus, OpenFaaS serverless framework was successfully utilized to create and invoke an
event-driven function.
[Link] :13
Simulate a cloud scenario using CloudSim and run a scheduling algorithm that is
not present in CloudSim
Aim
To simulate a cloud computing environment using CloudSim and execute a custom
Priority-Based Cloudlet Scheduling algorithm.
Cloud Scenario Simulated
User → Broker → Datacenter → Host → VM → Cloudlets
Step 1: Create Custom Cloudlet Scheduler
[Link]
import [Link].*;
import [Link].*;
public class PriorityCloudletScheduler extends CloudletSchedulerTimeShared {
@Override
public double cloudletSubmit(Cloudlet cloudlet, double fileTransferTime) {
List<Cloudlet> list = getCloudletExecList();
[Link](cloudlet);
[Link](list, (c1, c2) ->
[Link]([Link](), [Link]()));
return [Link](cloudlet, fileTransferTime);
}
}
Step 2: Main Simulation Program
[Link]
import [Link].*;
import [Link];
import [Link].*;
public class CloudSimCustomScheduling {
public static void main(String[] args) {
[Link](1, [Link](), false);
Datacenter dc = createDatacenter("Datacenter1");
DatacenterBroker broker = new DatacenterBroker("Broker1");
int brokerId = [Link]();
Vm vm = new Vm(0, brokerId, 1000, 1, 512,
1000, 10000, "Xen",
new PriorityCloudletScheduler());
[Link]([Link](vm));
UtilizationModel um = new UtilizationModelFull();
Cloudlet c1 = new Cloudlet(1, 4000, 1, 300, 300, um, um, um);
Cloudlet c2 = new Cloudlet(2, 2000, 1, 300, 300, um, um, um);
Cloudlet c3 = new Cloudlet(3, 3000, 1, 300, 300, um, um, um);
[Link](1);
[Link](5); // Highest
[Link](3);
[Link](brokerId);
[Link](brokerId);
[Link](brokerId);
[Link]([Link](c1, c2, c3));
[Link]();
[Link]();
[Link]("Execution Order:");
for (Cloudlet cl : [Link]()) {
[Link]("Cloudlet ID: " + [Link]()
+ " Priority: " + [Link]());
}
}
static Datacenter createDatacenter(String name) {
List<Pe> peList = [Link](new Pe(0,
new PeProvisionerSimple(1000)));
Host host = new Host(0,
new RamProvisionerSimple(2048),
new BwProvisionerSimple(10000),
1000000, peList,
new VmSchedulerTimeShared(peList));
DatacenterCharacteristics dcChar =
new DatacenterCharacteristics(
"x86", "Linux", "Xen",
[Link](host),
10, 3, 0.05, 0.1, 0.1);
try {
return new Datacenter(name, dcChar,
new VmAllocationPolicySimple([Link](host)),
new ArrayList<>(), 0);
} catch (Exception e) {
return null;
}
}
}
OUTPUT
Execution Order:
Cloudlet ID: 2 Priority: 5
Cloudlet ID: 3 Priority: 3
Cloudlet ID: 1 Priority: 1