You are on page 1of 80

S.A.

ENGINEERING COLLEGE
(Autonomous Institution)
Accredited by MBA, NAAC with ‘A’ grade & ISO 9001:2015 Certified Institution
POONAMALLEE – AVADI ROAD
THIRUVERKADU POST, CHENNAI – 600 077

RECORD OF LABORATORY WORK

Subject Code : CS8711

Subject Name : CLOUD COMPUTING LABORATORY

Name : AAKASH N

Reg.No : 111917104001

Branch : Computer Science & Engineering

Year/ Semester : IV /VII

Academic Year : 2020-2021(ODD)

Faculty Incharge(s): Mr. S. Muthukumarasamy /Mr.V.Kaliraj/Mrs.B.CynthiaSherin


S.A. ENGINEERING COLLEGE
(AUTONOMOUS)
POONAMALLEE – AVADI MAIN ROAD
THIRUVERKADU, CHENNAI – 600 077

CERTIFICATE

Name……………………………….AAKASH N…………….………………………..

Year…. IV…Semester…….VII……Branch……….Computer Science and Engineering…….

University Register No: ………………..………111917104001……………..….…………

Certified that this is the bonafide record of work done by the above student in the CS8711-
Cloud Computing Laboratory during the Academic year 2020 – 2021.

Signature of Head of Department Signature of Lab Incharge

………………………CS8711 / CLOUD COMPUTING LABORATORY……………..

Submitted for the End Semester Examination held on ……………………………………


at S.A. Engineering college.
Signature of Examiners:

Internal Examiner External Examiner


S.A. ENGINEERING COLLEGE

(Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

VISION
To conceive our department as Centre of Academic Excellence by catering quality education with
ethical standards
MISSION
● To create a conducive atmosphere to achieve active professionalism by fortifying academic
proficiency with ethical standards
● To enhance the confidence level to develop sustainable solution to upgrade the society forever
● To empower the students with prerequisite professional skills for enhancing employability and
entrepreneurship, continuing education and research

PROGRAMME EDUCATIONAL OBJECTIVES

1. To enable graduates to pursue higher education and research, or have a successful career in
industries associated with Computer Science and Engineering, or as entrepreneurs.
2. To ensure that graduates will have the ability and attitude to adapt to emerging technological
changes.

PROGRAMME SPECIFIC OUTCOMES

1. To analyze, design and develop computing solutions by applying foundational concepts of


Computer Science and Engineering.
2. To apply software engineering principles and practices for developing quality software for
scientific and business applications.
3. To adapt to emerging Information and Communication Technologies (ICT) to innovate ideas
and solutions to existing/novel problems.
PROGRAMME OUTCOMES (POs)
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,
and an engineering specialization to the solution of complex engineering problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences,
and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.

4. Conduct investigations of complex problems: Use research-based knowledge and research


methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional engineering solutions
in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.

8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.

9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.

11. Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.

12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
SYLLABUS
CS8711 CLOUD COMPUTING LABORATORY LTPC0042

OBJECTIVES:

 To develop web applications in cloud


 To learn the design and development process involved in creating a cloud based application
 To learn to implement and use parallel programming using Hadoop

LIST OF EXPERIMENTS

1. Install Virtualbox/VMware Workstation with different flavours of linux or windows OS on top of


windows7 or 8.

2. Install a C compiler in the virtual machine created using virtual box and execute Simple Programs

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

4. Use GAE launcher to launch the web applications.

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. Find a procedure to launch virtual machine using trystack (Online Openstack Demo Version)

8. Install Hadoop single node cluster and run simple applications like wordcount.

TOTAL: 60 PERIODS

OUTCOMES:

On completion of this course, the students will be able to:

 Configure various virtualization tools such as Virtual Box, VMware workstation.


 Design and deploy a web application in a PaaS environment.
 Learn how to simulate a cloud environment to implement new schedulers.
 Install and use a generic cloud environment that can be used as a private cloud.
 Manipulate large data sets in a parallel environment.
S.A. ENGINEERING COLLEGE

(Autonomous Institution)
DEPARTMENT OF CSE
SUBJECT/SUB.CODE : CS8711 / CLOUD COMPUTING LABORATORY

ACADEMIC YEAR : 2020-2021(ODD)


COURSE OUTCOMES:
Upon the successful completion of the Course, the Student would be able to

CS8711.1 :ConfigurevariousvirtualizationtoolssuchasVirtualBox,VMwareworkstation.
CS8711.2 :DesignanddeployawebapplicationinaPaaSenvironment.
CS8711.3 :Learnhowtosimulateacloudenvironmenttoimplementnewschedulers.
CS8711.4 :Installanduseagenericcloudenvironmentthatcanbeusedasaprivatecloud.
CS8711.5 :Manipulatelargedatasetsinaparallelenvironment.
CS8711.6 : Install Hadoop single node cluster and run simple applications

COs PO 1 PO 2 PO 3 PO 4 PO 5 PO 6 PO 7 PO 8 PO 9 PO 10PO 11PO 12PSO1 PSO2 PSO3

CS8711.1 1 3 2 3

CS8711.2 1 3 2 2 2

CS8711.3 2 1 1 1 1

CS8711.4 1 1 2 2 1

CS8711.5 2 1 2 1 1

CS8711.6 2 1 2 2

Enter correlation levels as 1,2and 3


1 Slight(Low) 2 Moderate(Medium) 3 Substantial (High)
S.A. ENGINEERING COLLEGE
(Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
SUBJECT/SUB.CODE : CS8711 CLOUD COMPUTING LABORATORY
ACADEMIC YEAR : 2020-2021(ODD)
INDEX

S.NO DATE NAME OF THE EXPERIMENT PAGE MARKS


NO.
InstallVirtualbox/

1 20/07/2020 VMwareWorkstationwithdifferentflavoursoflinuxor 09 20
windowsOSontopofwindows
InstallaCcompilerinthevirtualmachinecreat

2 03/08/2020 edusingvirtualboxandexecuteSimpleProgra 19 20
ms
InstallGoogleAppEngine.Createhelloworldappa
3 10/08/2020 21 20
ndothersimplewebapplicationsusingpython/java.

4 17/08/2020 UseGAElaunchertolaunchthewebapplications. 25 20

SimulateacloudscenariousingCloudSimandrunasc
5 07/09/2020 34 20
hedulingalgorithmthatisnotpresentinCloudSim.

Findaproceduretotransferthefilesfromonevirtualmac
6 14/09/2020 43 20
hinetoanothervirtualmachine.
Findaproceduretolaunchvirtualmachineusingtrystac
7 05/10/2020 47 20
k
InstallHadoopsinglenodeclusterandrunsimpleapplica
8 12/10/2020 tionslikewordcount. 62 20

Content beyond syllabus- Cloud setup


9 14/09/2020 74
installation(OPEN NEBULA)
CS8711- Cloud Computing Laboratory REG NO:111917104059

EX.NO:01InstallVirtualbox/VMwareWorkstationwith different
DATE:20/07/2020 flavoursoflinuxorwindowsOSontopofwindows

AIM:

To InstallVMware workstation withdifferentflavoursoflinuxontopofwindows

PROCEDURE:

8
CS8711- Cloud Computing Laboratory REG NO:111917104059

9
CS8711- Cloud Computing Laboratory REG NO:111917104059

10
CS8711- Cloud Computing Laboratory REG NO:111917104059

11
CS8711- Cloud Computing Laboratory REG NO:111917104059

12
CS8711- Cloud Computing Laboratory REG NO:111917104059

13
CS8711- Cloud Computing Laboratory REG NO:111917104059

14
CS8711- Cloud Computing Laboratory REG NO:111917104059

15
CS8711- Cloud Computing Laboratory REG NO:111917104059

16
CS8711- Cloud Computing Laboratory REG NO:111917104059

RESULT:

ThusVirtualboxwithdifferentflavoursoflinuxontopofwindows was successfully installed.

17
CS8711- Cloud Computing Laboratory REG NO:111917104059

EX.NO:02InstallaCcompilerinthevirtualmachinecreated
DATE:03/08/20 usingvirtualboxandexecuteSimplePrograms

AIM:

To install a C Compiler in the virtual machine using Virtual Box and then to execute simple program

PROCEDURE:

****If gccand / or g++ and it’s related Development Tools are not installed in your system by default, you
can install the latest available from the repositories as follow****

[frontend@frontend Desktop]$ vi sum.c

PROGRAM :

STEP 1: Press ‘i’ for insert mode


STEP 2: Type the following code:

#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter two numbers to add, separated by a space: ");
scanf("%d%d",&a,&b);
c = a + b;
printf("The sum of 2 numbers is: %d\n",c);
return 0;
}

TYPE [SHIFT + : + w + q] altogether

OUTPUT:

[frontend@frontend Desktop]$ gccsum.c -o sum


[frontend@frontend Desktop]$ ./sum
Enter two numbers to add, Separated by a space: 145 216
The sum of 2 numbers is : 361

18
CS8711- Cloud Computing Laboratory REG NO:111917104059

RESULT:

Thus C Compiler in the virtual machine using Virtual Box was installed and then simple program was
executed successfully.
19
CS8711- Cloud Computing Laboratory REG NO:111917104059

EX.NO:03InstallGoogleAppEngine.Createhelloworldappand
DATE:10/08/20 othersimplewebapplicationsusingpython/java

AIM:

To install Google App engine to create helloworld App web application using python

PROCEDURE:

This procedure describes the installation of the Google App Engine Software Development Kit (SDK) on
a Microsoft Windows and running a simple “hello world” application.
The App Engine SDK allows you to run Google App Engine Applications on your local computer. It
simulates the run-‐time environment of the Google App Engine infrastructure.
Pre-Requisites: Python 2.5.4

If you don't already have Python 2.5.4 installed in your computer, download and Install Python 2.5.4
from:
http://www.python.org/download/releases/2.5.4/
Download and Install
You can download the Google App Engine SDK by going to:
http://code.google.com/appengine/downloads.html
and download the appropriate installpackage.

Download the Windows installer – the simplest thing is to download it to your Desktop or another
folder that youremember.

20
CS8711- Cloud Computing Laboratory REG NO:111917104059

Double Click on the GoogleApplicationEngineinstaller.

Click through the installation wizard, and it should install the App Engine. If you do not have Python 2.5,
it will install Python 2.5 as well.
Once the install is complete you can discard the downloaded installer

Making your FirstApplication

21
CS8711- Cloud Computing Laboratory REG NO:111917104059

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 goingon.
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:
C:\Documents and Settings\csev\Desktop\apps

And then make a sub-‐folder in within apps called “ae-01-trivial” – the path to this folder would be:
C:\ Documents and Settings \csev\Desktop\apps\ae-01-trivial

Using a text editor such as JEdit (www.jedit.org), create a file called app.yamlin the
ae-01-trivial folder with the following contents:

application: ae-01-trivial version: 1


runtime: python api_version: 1
handlers:
- url: /.*
script: index.py

Note: Please do not copy and paste these lines into your text editor – you might end up with strange
characters – simply type them into your editor.
Then create a file in the ae-01-trivial folder called index.pywith three lines in it:

print 'Content-Type: text/plain' print ' '


print 'Hello there Chuck'
Then start the GoogleAppEngineLauncherprogram that can be found under Applications. Use the File
-> Add Existing Application command and navigate into the apps directory and select the ae-01-trivial
folder.

Once you have added the application, select it so that you can control the application using the launcher.

Once you have selected your application and press Run. After a few moments your application will start
and the launcher will show a little green icon next to your application. Then press Browse to open a
browser pointing at your application which is running at http://localhost:8080/

22
CS8711- Cloud Computing Laboratory REG NO:111917104059

Paste http://localhost:8080 into your browser and you should see your application as follows:

Just for fun, edit the index.pyto change the name “Chuck” to your own name and press Refresh in the
browser to verify your updates.

RESULT:

Thus Google App engine was installed to create helloworld App web application using python

23
CS8711- Cloud Computing Laboratory REG NO:111917104059

EX.NO:4UseGAElaunchertolaunchthewebapplications.
DATE: 17/08/20

AIM:

To launch the web applications using GAE launcher.

PROCEDURE:

You can use Google App Engine to host a static website. Static web pages can contain client-side
technologies such as HTML, CSS, and JavaScript. Hosting your static site on App Engine can cost less than
using a traditional hosting provider, as App Engine provides a free tier.

Sites hosted on App Engine are hosted on the REGION_ID.r.appspot.com subdomain, such as [my-project-


id].uc.r.appspot.com. After you deploy your site, you can map your own domain name to your App Engine-
hosted website.

Creating a website to host on Google App Engine


Basic structure for the project
This guide uses the following structure for the project:
 app.yaml: Configure the settings of your App Engine application.
 www/: Directory to store all of your static files, such as HTML, CSS, images, and JavaScript.
 css/: Directory to store stylesheets.
 style.css: Basic stylesheet that formats the look and feel of your site.
 images/: Optional directory to store images.
 index.html: An HTML file that displays content for your website.
 js/: Optional directory to store JavaScript files.
 Other asset directories.
Creating the app.yaml file
The app.yaml file is a configuration file that tells App Engine how to map URLs to your static files. In the
following steps, you will add handlers that will load www/index.html when someone visits your website,
and all static files will be stored in and called from the www directory.

24
CS8711- Cloud Computing Laboratory REG NO:111917104059

Create the app.yaml file in your application's root directory:


1. Create a directory that has the same name as your project ID. You can find your project ID in
the Console.
2. In directory that you just created, create a file named app.yaml.
3. Edit the app.yaml file and add the following code to the file:
runtime: python27
api_version:1
threadsafe:true

handlers:
- url:/
  static_files: www/index.html
  upload: www/index.html

- url:/(.*)
  static_files: www/\1
  upload: www/(.*)

More reference information about the app.yaml file can be found in the app.yaml reference documentation.


Creating the index.html file
Create an HTML file that will be served when someone navigates to the root page of your website. Store
this file in your www directory.
<html>
  <head>
    <title>Hello, world!</title>
    <linkrel="stylesheet"type="text/css"href="/css/style.css">
  </head>
  <body>
    <h1>Hello, world!</h1>
    <p>
      This is a simple static HTML file that will be served from Google App
      Engine.
25
CS8711- Cloud Computing Laboratory REG NO:111917104059

    </p>
  </body>
</html>

Deploying your application to App Engine


When you deploy your application files, your website will be uploaded to App Engine. To deploy your app,
run the following command from within the root directory of your application where the app.yaml file is
located:
gcloud app deploy

Optional flags:
 Include the --project flag to specify an alternate Cloud Console project ID to what you initialized as
the default in the gcloud tool. Example: --project [YOUR_PROJECT_ID]
 Include the -v flag to specify a version ID, otherwise one is generated for you. Example: -v
[YOUR_VERSION_ID]
Viewing your application
To launch your browser and view the app at https://PROJECT_ID.REGION_ID.r.appspot.com, run the
following command:
gcloud app browse
Watching the Log

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:

26
CS8711- Cloud Computing Laboratory REG NO:111917104059

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.yamlfile, the App Engine will not start and your launcher will show a yellow icon near
your application:

27
CS8711- Cloud Computing Laboratory REG NO:111917104059

To get more detail on what is going wrong, take a look at the log for the application:

Inthisinstance– the mistake is mis-‐indentingthelastlineintheapp.yaml(line 8).

If you make a syntax error in the index.pyfile, 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
28
CS8711- Cloud Computing Laboratory REG NO:111917104059

When you make a mistake in the app.yamlfile – 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.

Shutting Down the Server

To shut down the server, use the Launcher, select your application and press the
Stop button.

OUTPUT:

29
CS8711- Cloud Computing Laboratory REG NO:111917104059

30
CS8711- Cloud Computing Laboratory REG NO:111917104059

31
CS8711- Cloud Computing Laboratory REG NO:111917104059

RESULT:

Thus GAE launcher was initiated and web application was launched successfully.

32
CS8711- Cloud Computing Laboratory REG NO:111917104059

EX.NO:5SimulateacloudscenariousingCloudSimandruna
DATE:07/09/20 schedulingalgorithmthatisnotpresentinCloudSim

AIM:

To simulate cloud scenario using cloudsim and to run a scheduling algorithm.

PROCEDURE:

CloudSim is a simulation toolkit that supports the modeling and simulation of the core functionality of cloud,
like job/task queue, processing of events, creation of cloud entities(datacenter, datacenter brokers, etc),
communication between different entities, implementation of broker policies, etc. This toolkit allows to:
 Test application services in a repeatable and controllable environment.
 Tune the system bottlenecks before deploying apps in an actual cloud.
 Experiment with different workload mix and resource performance scenarios on simulated infrastructure
for developing and testing adaptive application provisioning techniques
Core features of CloudSim are:
 The Support of modeling and simulation of large scale computing environment as federated cloud data
centers, virtualized server hosts, with customizable policies for provisioning host resources to virtual
machines and energy-aware computational resources
 It is a self-contained platform for modeling cloud’s service brokers, provisioning, and allocation policies.
 It supports the simulation of network connections among simulated system elements.
 Support for simulation of federated cloud environment, that inter-networks resources from both private
and public domains.
 Availability of a virtualization engine that aids in the creation and management of multiple independent
and co-hosted virtual services on a data center node.
 Flexibility to switch between space shared and time shared allocation of processing cores to virtualized
services.
How to download Cloudsim?
Cloudsim project source code, as well as compiled jars files, are published through the GitHub project
page: https://github.com/Cloudslab/cloudsim. By default, the project page displays the source code(based
on maven build tool) of the current release
33
CS8711- Cloud Computing Laboratory REG NO:111917104059
Every version except 5.0(still under development) contains 4 asset files example description for each asset file
is as follows:
 cloudsim-4.0.tar.gz: This file contains the compiled JAR file that can be directly used into the custom
simulation implementation where there is no need to change in the source code of cloudsim simulation
engine. This version is Linux specific.
 cloudsim-4.0.zip: This is the same as above the only difference is that it is windows specific.
 Source code(zip): This file contains the complete source code of the cloudsim simulation framework
project. As the cloudsim uses the maven build tool for its DevOps. Therefore to set up this project you
require to
 use an IDE that supports maven project imports. How do you identify that its a maven based project?
 you will find a “pom.xml” file in the project root folder. This zip is windows operating system specific
file.
 Source code(tar.gz): This file contains a similar structure as mentioned above, but it is specific to
 Linux
How to install?
Cloudsim setup is very easy, for this you may follow the following link: cloudsim-setup-using-eclipse/. This
link describes in detail all the steps that are required to successfully configure the Cloudsim 3.0.3 version.
The cloudsim 3.0.3 version is best to start with that once you understand the basic working and architecture
then you can move to any latest version.
How cloudsim work?
As it is already mentioned that the cloudsim allows to model and simulate the cloud system components,
therefore to support its function different set of classes has been developed by its developers like:
 To simulating the regions and datacenters the class named “Datacenter.java” is available in
org.cloudbus.cloudsim package.
 To simulate the workloads for cloud, the class named as “Cloudlet.java” is available in
org.cloudbus.cloudsim package.
 To simulate the load balancing and policy-related implementation the classes named
“DatacenterBroker.java”, “CloudletScheduler.java”, “VmAllocationPolicy.java”, etc are available under
org.cloudbus.cloudsim package.
 Now because all the different simulated hardware models are required to communicate with each other
to share the simulation work updates for this cloudsim has implemented a discrete event simulation
34
CS8711- Cloud Computing Laboratory REG NO:111917104059
engine that keeps track of all the task assignments among the different simulated cloud components.
How to run my first cloudsim simulation scenario?
Once you have completed your installation/setup and understand the basic working of the cloudsim, the next
step is to implement your own custom scenario. Any simulation will go through the following steps:
 Initialize the CloudSim with the current clock time and this will also initialize the core
CloudInformationService entity.
 Create Datacenter(s) as Datacenters are the resource providers in CloudSim. We need at list one of
them to run a CloudSim simulation.
 Create Broker to simulate the user workload scheduling as well as virtual machine allocation and
placements.
 Create one/more virtual machine and submit to the broker for further submitting it to the respective
DataCenters for its placement and execution management during the simulation run.
 Create one/more Cloudlet and submit the cloudlet list to the broker for further task scheduling on the
active virtual machines for its processing during the simulation run.
 Starts the simulation, this will initiate all the entities and components created above and put them into
execution for supporting various simulation operations.
 Stop the simulation, concludes simulation and flush all the entities & components before the exit of a
simulation run.
 Print results when the simulation is over, where you will be able to display which cloudlet executed on
which virtual machine along with how much time it spent in execution, its start time as well as its finish
time.
The main() method is the pointer from where the execution of this example starts
public static void main(String[] args)
There are eleven steps that are followed in each example with some variation in them, specified as follows:
 Set the Number of users for the current simulation. This user count is directly proportional to a number
brokers in the current simulation.
intnum_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
booleantrace_flag = false;
 Initialize the simulation, provided with the current time, number of users and trace flag.
CloudSim.init(num_user, calendar, trace_flag);
35
CS8711- Cloud Computing Laboratory REG NO:111917104059
 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 DatacentercreateDatacenter(String name)
{
List<Host>hostList = new ArrayList<Host>();
List<Pe>peList = new ArrayList<Pe>();
intmips = 1000;
peList.add(new Pe(0, new PeProvisionerSimple(mips)));
inthostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
intbw = 10000;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
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;
36
CS8711- Cloud Computing Laboratory REG NO:111917104059
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);
Datacenterdatacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList),
storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
 Create a Datacenter broker.
DatacenterBroker broker = createBroker();
intbrokerId = broker.getId();
Where the createBroker() method initializes the entity object from DatacenterBroker class
private static DatacenterBrokercreateBroker()
{
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
37
CS8711- Cloud Computing Laboratory REG NO:111917104059
}
 Create a Virtual Machine(s).
vmlist = new ArrayList<Vm>();
intvmid = 0;
intmips = 1000;
long size = 10000;
int ram = 512;
long bw = 1000;
intpesNumber = 1;
String vmm = "Xen";
Vmvm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());

vmlist.add(vm);
 Submit Virtual Machine to Datacenter broker.
broker.submitVmList(vmlist);
 Create Cloudlet(s) by specifying their characteristics.
cloudletList = new ArrayList<Cloudlet>();
int id = 0;
long length = 400000;
long fileSize = 300;
long outputSize = 300;
UtilizationModelutilizationModel = new UtilizationModelFull();
Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel,
utilizationModel);

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

cloudletList.add(cloudlet);
38
CS8711- Cloud Computing Laboratory REG NO:111917104059
 Submit Cloudlets to Datacenter broker.
broker.submitCloudletList(cloudletList);
 Send call to Start Simulation.
CloudSim.startSimulation();
 Once no more event to execute, send the call to Stop Simulation.
CloudSim.stopSimulation();
 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
+ "Data center ID" + indent + "VM ID" +
indent + "Time" + indent
+ "Start Time" + indent + "Finish Time");

DecimalFormatdft = new DecimalFormat("###.##");


for (inti = 0; i< size; i++)
{
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent +
indent);
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS)
{

39
CS8711- Cloud Computing Laboratory REG NO:111917104059
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()));
}
}
}
OUTPUT:
Once you Run the example the output for cloudsimExample1.java will be displayed like:

CloudsimExample1.java console output

40
CS8711- Cloud Computing Laboratory REG NO:111917104059

RESULT:

Thus simulation of cloud scenario using cloudsim was done successfully.

41
CS8711- Cloud Computing Laboratory REG NO:111917104059

EX.NO:6Findaproceduretotransferthefilesfromonevirtual
DATE:14/09/20 machinetoanothervirtualmachine.

AIM:

To execute the procedure for transfer the file from one virtual machine to another virtual

machine.

42
CS8711- Cloud Computing Laboratory REG NO:111917104059

43
CS8711- Cloud Computing Laboratory REG NO:111917104059

44
CS8711- Cloud Computing Laboratory REG NO:111917104059

Goto Terminal,
[oneadmin@frontend ~]$onevm list
OUTPUT:
ID USER GROUP NAME STATU CPU UMEM HOST TIME
3 oneadminoneadmin kvm1 runn 2 512M kvm2.saec.com 0d 00h01
2 oneadminoneadmin kvm2 runn 2 512M kvm1.saec.com 0d 00h02

45
CS8711- Cloud Computing Laboratory REG NO:111917104059
Goto Browser , Virtual Resources-> Virtual Machine ->

Click ->oneadmin -> Migrate [live]

Select host -> click “Migrate”

RESULT:

Thus procedure for transferring the files from one virtual machine to another machine was executed

successfully

46
CS8711- Cloud Computing Laboratory REG NO:111917104059

EX.NO:7Findaproceduretolaunchvirtualmachineusingtrystack
DATE:05/10/20

AIM:

To execute the procedure to launch virtual machine using trystack

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, TryStackis the
easiest and free way to do it.
In order to try OpenStack in TryStack, you must register yourself by joining TryStackFacebookGroup. 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.

TryStack.org Homepage
I assume that you already join to the Facebook Group and login to the dashboard. After youlog in to the
TryStack, you will see the Compute Dashboard like:

47
CS8711- Cloud Computing Laboratory REG NO:111917104059

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 be like

48
CS8711- Cloud Computing Laboratory REG NO: 111917104059

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.

1. Go to Network > Networks and then click CreateNetwork.


2. In Network tab, fill Network Name for example internal and then clickNext.
3. In Subnettab,
1. Fill Network Address with appropriate CIDR, for example 192.168.1.0/24. Use private
network CIDR block as the bestpractice.
2. Select IP Version with appropriate IP version, in this caseIPv4.
3. ClickNext.
4. In Subnet Details tab, fill DNS Name Servers with 8.8.8.8 (Google DNS) and then clickCreate.

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 LaunchInstance.


2. In Detailstab,
1. Fill Instance Name, for example Ubuntu1.
2. Select Flavor, for examplem1.medium.
3. Fill Instance Count with1.
4. Select Instance Boot Source with Boot fromImage.
5. Select Image Name with Ubuntu 14.04 amd64 (243.7 MB) if you want installUbuntu
14.04 in your virtual machine.
3. In Access &Securitytab,
1. Click [+] button of Key Pair to import key pair. This key pair is a public and private
keythat we will use to connect to the instance from ourmachine.
2. In Import Key Pairdialog,
1. Fill Key Pair Name with your machine name (for exampleEdward-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 Puttygento generate keypair.
3. Click Import keypair.
3. In Security Groups, mark/checkdefault.
4. In Networkingtab,
1. In Selected Networks, select network that have been created in Step 1, for exampleinternal.
5. ClickLaunch.
6. If you want to create multiple instances, you can repeat step 1-5. I created one more
instance with instance name Ubuntu2.

Step 3: Create Router

49
CS8711- Cloud Computing Laboratory REG NO: 111917104059

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 CreateRouter.


2. Fill Router Name for example router1 and then click Createrouter.
3. Click on your router name link, for example router1, Router Detailspage.
4. Click Set Gateway button in upperright:
1. Select External networks withexternal.
2. ThenOK.
5. Click Add Interfacebutton.
1. Select Subnet with the network that you have been created in Step 1.
2. Click Addinterface.
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. Thereare
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 FloatingIP.
3. In IP Address, click Plus[+].
4. Select Pool to external and then click AllocateIP.
5. ClickAssociate.
6. Now you will get a public IP, e.g. 8.21.28.120, for yourinstance.

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 Groupstab.
2. In default row, click ManageRules.
3. Click Add Rule, choose ALL ICMP rule to enable ping into your instance, and then clickAdd.
4. Click Add Rule, choose HTTP rule to open HTTP port (port 80), and then clickAdd.
5. Click Add Rule, choose SSH rule to open SSH port (port 22), and then clickAdd.
6. You can open other ports by creating newrules.

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.

Output:

50
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.1 Host file Entry in centos 7


***** Add following entry in /etc/hosts file on kvm1 kvm2 frontend *****
#vi /etc/hosts
192.168.35.135 frontend1.cnl.com frontend1
192.168.35.136 kvm2.cnl.com kvm2
192.168.35.137 kvm1.cnl.com kvm1

1.2 Check system is enabled VT or Not in both servers


# grep -E 'svm|vmx' /proc/cpuinfo

51
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.3 System must be enabled with KVM mode on both servers


# lsmod | grep -ikvm

1.4 Modify selinux mode on both servers


#vi /etc/selinux/configSELINUX=permissive
#vi /etc/sysconfig/selinuxSELINUX=permissive

1.5 Enable nfs home directory usage in selinux on both servers


#getsebool -a | grepuse_nfs_home_dirs
#setsebool -P use_nfs_home_dirs 1

52
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.6 Disable firewalld in both servers


# systemctl disable firewalld
# systemctl stop firewalld
# systemctl status firewalld

1.7 Reboot all 3 servers


# shutdown –r now

1.8 Check nfs SE Boolean settings only in kvm1 and kvm2 servers
# systemctl status firewalld|grep -i active
****Active: inactive (dead)****
# getsebool -a | grepuse_nfs_home_dirs

1.9 Install EPEL repo on all the servers


# yum install epel-release
Add the OpenNebula repository in all three machines:
# cat<< EOT > /etc/yum.repos.d/opennebula.repo
[opennebula]
name=opennebula
baseurl=http://downloads.opennebula.org/repo/4.8/CentOS/7/x86_64
enabled=1
gpgcheck=0
EOT /

1.10 Install the required packages in frontend1 server


# yum -y install opennebula-server opennebula-sunstone

53
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.11 Install the required packages in kvm1 and kvm2 servers


# yum -y install opennebula-node-kvm

1.12 Install the gems package and dependencies in frontend1 servers


**On frontend1, now run install_gems to install all the gem dependencies (Select Cent-OS/Redhat)**
# /usr/share/one/install_gems
****lsb_release command not found. If you are using a RedHat based distribution install redhat-
lsb****
****Select your distribution or press enter to continue without installing dependencies****
0. Ubuntu/Debian
1. CentOS/RedHat
2. SUSE
****PRESS 1 AND ENTER (because we are using Centos 7)****
****Press Enter wherever asked, and Y when asked to install via yum (will be asked multiple
times)****

1.13 On Frontend1 server, configure and start the services


There are two main processes that must be started, the main OpenNebula daemon: oned, and the
graphical user interface: sunstone.
Sunstone listens only in the loopback interface by default for security reasons. To change it
edit /etc/one/sunstone-server.conf and change :host: 127.0.0.1 to :host: 0.0.0.0.****on 31th line
Now we can start the services

# serviceopennebula-sunstone start
Check to see service is enabled for different runlevels to start on reboot;
# chkconfig --list 2>/dev/null|grep -i open
opennebula 0:off 1:off 2:on 3:on 4:on 5:on 6:off
opennebula-sunstone 0:off 1:off 2:on 3:on 4:on 5:on 6:off

54
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.14 On Frontend1 server, configure NFS service


Export /var/lib/one/ from the frontend to the worker nodes. To do so add the following to the
/etc/exports file in the frontend:
#vi /etc/exports
/var/lib/one/ *(rw,sync,no_subtree_check,no_root_squash,insecure)
# exportfs –ra On KVM1 and KVM2 servers ,check NFS
# showmount -e frontend1
****Refresh the NFS exports by doing on FRONT end 1****
#systemctl status nfs.service
#systemctl start nfs.service
#systemctl enable nfs-server.service
****On kvm1 and kvm2****
#systemctl status nfs-client.target
#systemctl start nfs-client.target
#systemctl enable nfs-client.target
1.15 On frontend1 server ,check NFS
#systemctl| grep -infs

1.16 On KVM1 and KVM2 servers ,check NFS


#systemctl | grep -infs

1.17 On KVM1 and KVM2 servers , mount /var/lib/one from frontend1


**** opennebulaoneadminhomedir****
#vi /etc/fstab
frontend1.cnl.com:/var/lib/one/ /var/lib/one/ nfssoft,intr,rsize=8192,wsize=8192 0 0

55
CS8711- Cloud Computing Laboratory REG NO: 111917104059

# mount -a -t nfs
# df -h /var/lib/one (check to see if it is mounted)
Reboot kvm1 and kvm2 to see if homedirs are mounted on reboot
# df -h /var/lib/one (check to see if it is mounted)
1.18.On frontend1 server configure ssh public key
OpenNebula will need to SSH passwordlessly from any node (including the frontend) to any other
node.
Add the following snippet to ~/.ssh/config as oneadmin so it doesn’t prompt to add the keys to the
known_hosts file:
# su - oneadmin
$ cat<< EOT > ~/.ssh/config
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
EOT

On KVM1 and KVM2 servers ,start the services:


# systemctl status messagebus.service
# systemctl status libvirtd.service
# systemctl start messagebus.service
# systemctl start libvirtd.service
On KVM1 and KVM2 servers ,configure the bridging for instances:

56
CS8711- Cloud Computing Laboratory REG NO: 111917104059

You will need to have your main interface connected to a bridge. We will do the following example
with ens3 but the name of the interface may vary. An OpenNebularequirements is that the name of the
bridge should be the same in all nodes.
#vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
DEVICE=eno16777736
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet

****BRIDGE=br0****
#vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no

****Reboot kvm1 and kvm2 to see if devices are configured****


# ip route show | grep -i " br0"
****Using browser, open http://frontend1:9869****

****Password is here****
****On frontend1****

57
CS8711- Cloud Computing Laboratory REG NO: 111917104059

#su - oneadmin
#cat ~/.one/one_auth

****Copy that key into your browser password field****

Open Frontend, kvm1, kvm2 (Pwd: Redhat)

GotoFrontEnd ->Right Click-> Open In Terminal

[frontend@frontend Desktop]$su

Password:redhat

[root@frontend Desktop]#su – oneadmin

OUTPUT:

Last login: Wed Aug 21 09:27:42 IST 2019 on pts/0

[oneadmin@frontend ~]$onehost list

OUTPUT:

ID NAME CLUSTER RVM ALLOCATED_CPU ALLOCATED_MEM STAT

0 kvm1.saec.com - 0 0 / 100 (0%) 0K / 986.7M (0%) on

1 kvm2.saec.com - 0 0 / 100 (0%) 0K / 986.7M (0%) on

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Goto Run -> type cmd ->ipcongif

Check the IP ADDRESS of your system.

GotoFrontEnd,

[oneadmin@frontend ~]$ vi /var/tmp/mynetwork.one

Press i for Inserting Mode in the Editor

Copy the Following Code:

58
CS8711- Cloud Computing Laboratory REG NO: 111917104059

NAME = "private"
BRIDGE = br0
AR = [
TYPE = IP4,
IP = 192.168.35.150,
SIZE = 10
]

Press ESC, and then Shift+ : + w + q (altogether)

[oneadmin@frontend ~]$ onevnet create /var/tmp/mynetwork.one


ID: 1
[oneadmin@frontend ~]$ onevnet list

OUTPUT:

ID USER GROUP NAME CLUSTER BRIDGE LEASES


1 oneadminoneadmin private - br0 0

In Frontend, gotoApllication -> Mozilla Firefox


url: http://frontend:9869
Go to Virtual Resources -> Images -> Click Add + Symbol

Name : TTYLinux_1.0
Type: Select “DATABLOCK “
Image Location : Select “Empty Datablock”
Size: 512
FS: qcow2
CLICK “CREATE”
Goto Terminal,
[oneadmin@frontend ~]$oneimage list
ID USER GROUP NAME DATASTORE SIZE TYPE PER STAT RVMS
2 oneadminoneadmin TTYLinux_1.0 default 512M DB No rdy 0

Go to Virtual Resources -> Templates -> Click Add + Symbol

59
CS8711- Cloud Computing Laboratory REG NO: 111917104059

Name : TTYLinux_1.0
VCPU: 1
CLICK “CREATE”

Goto Terminal,
[oneadmin@frontend ~]$onetemplate list
OUTPUT:
ID USER GROUP NAME REGTIME
2 oneadminoneadmin TTYLinux_1.o 08/21 12:38:42

Goto Virtual Resources -> Templates -> click the file

Now click Instantiate ->


VM NAME : kvm1
Click -> Instantiate

Now click Instantiate ->


VM NAME : kvm2
Click -> Instantiate

Goto Terminal,
[oneadmin@frontend ~]$onevm list

OUTPUT:
ID USER GROUP NAME STATU CPU UMEM HOST TIME
3 oneadminoneadmin kvm1 runn 2 512M kvm2.saec.com 0d 00h01
2 oneadminoneadmin kvm2 runn 2 512M kvm1.saec.com 0d 00h02

60
CS8711- Cloud Computing Laboratory REG NO: 111917104059

RESULT:

Thus procedure to launch virtual machine using trystack was done successfully

61
CS8711- Cloud Computing Laboratory REG NO: 111917104059

EX.NO:8InstallHadoopsinglenodeclusterandrunsimple
DATE:12/10/20 applicationslikewordcount.

AIM:

To install Hadoop single node cluster and run simple applications like wordcount

PROCEDURE:
Step 1:Log on to your Cent OS machine by root
User name->root
Password->redhat
Step2:Disable your firewall & set the selinuxmodePermissive
#systemctl disable firewalld
# systemctl stop firewalld
# systemctl status firewalld

#setenforce 0
#getenforce

Uninstall your previous java version:


#yum erase java*
Install epel release:
#yum install epel-release
Install new java version (java 1.8.0_91)
#yum install java 1.8.0*
Adding hadoop user:
#useraddhadoop
62
CS8711- Cloud Computing Laboratory REG NO: 111917104059

#hadooppasswd
Enter your password here:___________________
Retype your pass word:______________________
Switch to hadoop user:
#su – hadoop
Key generation:
#key-gen **(on root)**
#ssh-copy-id hadoop@hadoop12
$key-gen (on hadoop)
$ ssh-copy-id root@hadoop12

Now install hadoop utility by follow link:


$ cd ~
$ wget http://apache.claz.org/hadoop/common/hadoop-2.6.1/hadoop-2.6.1.tar.gz
Un patch the tar file:
$ tar xzf hadoop-2.6.1.tar.gz
Move unpatched file into hadoop directory:
$ mv hadoop-2.6.1 hadoop
Setup Environment Variables
First we need to set environment variable uses by hadoop. Edit ~/.bashrc file and append following
values at end of file.
$vi ~/.bashrc
export HADOOP_HOME=/home/hadoop/hadoop
63
CS8711- Cloud Computing Laboratory REG NO: 111917104059

export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin

Now apply the changes in current running environment


$ source ~/.bashrc
Now edit $HADOOP_HOME/etc/hadoop/hadoop-env.sh file and set JAVA_HOME environment
variable. Change the JAVA path as per install on your system.
$vi $HADOOP_HOME/etc/hadoop/hadoop-env.sh
Delete previous path
Add this path export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.91-1.b14.el7_2.x86_64

64
CS8711- Cloud Computing Laboratory REG NO: 111917104059

Now apply the changes in current running environment


cd $HADOOP_HOME/etc/hadoop
Edit core-site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>

Edit hdfs-site.xml

65
CS8711- Cloud Computing Laboratory REG NO: 111917104059

<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>file:///home/hadoop/hadoopdata/hdfs/namenode</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>file:///home/hadoop/hadoopdata/hdfs/datanode</value>
</property>
</configuration>

Edit mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
66
CS8711- Cloud Computing Laboratory REG NO: 111917104059

</configuration>

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

Format Namenode
Now format the namenode using following command, make sure that Storage directory is
$ hdfsnamenode –format

67
CS8711- Cloud Computing Laboratory REG NO: 111917104059

Now run start-dfs.sh script.


$ start-dfs.sh

Now run start-yarn.sh script:


$ start-yarn.sh

Access Hadoop Services in Browser


HadoopNameNode started on port 50070 default. Access your server on port 50070 in your favorite
web browser.
http://IP_ADDRESS:50070

68
CS8711- Cloud Computing Laboratory REG NO: 111917104059

Then check datanodes :


***In Datanode the single node was added***

open hadoop
[desktop@hadoop]$ su
Password: redhat
[root@hadoop]$ ifconfig
[root@hadoop]$ vi /etc/hosts
system ip hadoop.saec.com hadoop
Esc Shift + : wq
[root@hadoop]$ java -version
[root@hadoop]$ su - hadoop
[hadoop@hadoop]$ hadoop version

69
CS8711- Cloud Computing Laboratory REG NO: 111917104059

[hadoop@hadoop]$ cd $HADOOP_HOME/etc/hadoop
[hadoop@hadoop]$ vi core-site.xml
[hadoop@hadoop]$ vi hdfs-site.xml
[hadoop@hadoop]$ vi mapred-site.xml
[hadoop@hadoop]$ vi yarn-site.xml
[hadoop@hadoop]$ hdfsnamenode -format
[hadoop@hadoop]$ cd $HADOOP_HOME/sbin/
[hadoop@hadoop]$ start-all.sh
[hadoop@hadoop]$ jps
in browser localhost:50070
green page configured capacity-17.5GB
in browser localhost:50075->datanode
in browser localhost:50090->secondary name node
in browser localhost:8088->cluster

Accessing port 8088:

Accessing 50090 port:

70
CS8711- Cloud Computing Laboratory REG NO: 111917104059

Accessing 500075 Port:

Type the following code:

[root@hadoop]$ vi wrdcnt.java

Press i for insert mode.

**Type the following program

public class wrdcnt


{
Static int i,str1,c=0,res;
static intwordcount(String s)
{
Char ch[]= new char[s.length()];
for(i=0;i<s.length();i++)
{
ch[i]= s.charAt(i);
if( ((i>0)&&(ch[i]!=' ')&&(ch[i-1]==' ')) || ((ch[0]!=' ')&&(i==0)) )
c++;
71
CS8711- Cloud Computing Laboratory REG NO: 111917104059

}
return c;
}
public static void main (String args[])
{ String str1="The hadoop is a opensource frame work here we use hadoop 2.6.0 ";
res=wrdcnt.wordcount(str1);
System.out.println("The number of words in the String are : "+res);
System.out.println("the word is:"+str1);
}
}
save it by esc shift:wq

***Then compile the java file using below command***

[root@hadoop]$javacwrdcnt.java

***Run the java file***

$java wrdcnt

OUTPUT:

72
CS8711- Cloud Computing Laboratory REG NO: 111917104059

RESULT:

Thus installation of Hadoop single node cluster and running of simple applications like wordcount was
executed successfully.

73
CS8711- Cloud Computing Laboratory REG NO: 111917104059

EX.NO:9Content beyond syllabus- Cloud Computing lab setup in


DATE:14/09/20 OPEN NEBULA

Aim:

To install OPEN NEBULA in Cloud Computing

Procedure:

1.2 Host file Entry in centos 7

***** Add following entry in /etc/hosts file on kvm1 kvm2 frontend *****

#vi /etc/hosts
192.168.35.135 frontend1.cnl.com frontend1
192.168.35.136 kvm2.cnl.com kvm2
192.168.35.137 kvm1.cnl.com kvm1

1.2 Check system is enabled VT or Not in both servers

# grep -E 'svm|vmx' /proc/cpuinfo

1.3 System must be enabled with KVM mode on both servers

# lsmod | grep -ikvm

74
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.4 Modify selinux mode on both servers

#vi /etc/selinux/configSELINUX=permissive

#vi /etc/sysconfig/selinuxSELINUX=permissive

1.5 Enable nfs home directory usage in selinux on both servers

#getsebool -a | grepuse_nfs_home_dirs
#setsebool -P use_nfs_home_dirs 1

1.6 Disable firewalld in both servers


# systemctl disable firewalld
# systemctl stop firewalld
# systemctl status firewalld

75
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.7 Reboot all 3 servers


# shutdown –r now

1.8 Check nfs SE Boolean settings only in kvm1 and kvm2 servers
# systemctl status firewalld|grep -i active
****Active: inactive (dead)****
# getsebool -a | grepuse_nfs_home_dirs

1.9 Install EPEL repo on all the servers


# yum install epel-release
Add the OpenNebula repository in all three machines:
# cat<< EOT > /etc/yum.repos.d/opennebula.repo
[opennebula]
name=opennebula
baseurl=http://downloads.opennebula.org/repo/4.8/CentOS/7/x86_64
enabled=1
gpgcheck=0
EOT /

1.10 Install the required packages in frontend1 server


# yum -y install opennebula-server opennebula-sunstone

1.11 Install the required packages in kvm1 and kvm2 servers


# yum -y install opennebula-node-kvm

1.12 Install the gems package and dependencies in frontend1 servers


**On frontend1, now run install_gems to install all the gem dependencies (Select Cent-OS/Redhat)**
# /usr/share/one/install_gems
****lsb_release command not found. If you are using a RedHat based distribution install redhat-
lsb****
****Select your distribution or press enter to continue without installing dependencies****
0. Ubuntu/Debian
1. CentOS/RedHat
2. SUSE
****PRESS 1 AND ENTER (because we are using Centos 7)****
****Press Enter wherever asked, and Y when asked to install via yum (will be asked multiple
times)****
76
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.13 On Frontend1 server, configure and start the services


There are two main processes that must be started, the main OpenNebula daemon: oned, and the
graphical user interface: sunstone.
Sunstone listens only in the loopback interface by default for security reasons. To change it
edit /etc/one/sunstone-server.conf and change :host: 127.0.0.1 to :host: 0.0.0.0.****on 31th line

Now we can start the services

# serviceopennebula-sunstone start
Check to see service is enabled for different runlevels to start on reboot;
# chkconfig --list 2>/dev/null|grep -i open
opennebula 0:off 1:off 2:on 3:on 4:on 5:on 6:off
opennebula-sunstone 0:off 1:off 2:on 3:on 4:on 5:on 6:off

1.14 On Frontend1 server, configure NFS service


Export /var/lib/one/ from the frontend to the worker nodes. To do so add the following to the
/etc/exports file in the frontend:
#vi /etc/exports
/var/lib/one/ *(rw,sync,no_subtree_check,no_root_squash,insecure)
# exportfs –raOn KVM1 and KVM2 servers ,check NFS
# showmount -e frontend1
****Refresh the NFS exports by doing on FRONT end 1****
#systemctl status nfs.service
#systemctl start nfs.service
#systemctl enable nfs-server.service
****On kvm1 and kvm2****
#systemctl status nfs-client.target
#systemctl start nfs-client.target
#systemctl enable nfs-client.target

1.15 On frontend1 server ,check NFS


#systemctl| grep -infs

1.16 On KVM1 and KVM2 servers ,check NFS


#systemctl | grep -infs

77
CS8711- Cloud Computing Laboratory REG NO: 111917104059

1.17 On KVM1 and KVM2 servers , mount /var/lib/one from frontend1


**** opennebulaoneadminhomedir****
#vi /etc/fstab
frontend1.cnl.com:/var/lib/one/ /var/lib/one/ nfssoft,intr,rsize=8192,wsize=8192 0 0

# mount -a -t nfs
# df -h /var/lib/one (check to see if it is mounted)

Reboot kvm1 and kvm2 to see if homedirs are mounted on reboot

# df -h /var/lib/one (check to see if it is mounted)

1.18.On frontend1 server configure ssh public key


OpenNebula will need to SSH passwordlessly from any node (including the frontend) to any other
node.
Add the following snippet to ~/.ssh/config as oneadmin so it doesn’t prompt to add the keys to the
known_hosts file:
# su - oneadmin
$ cat<< EOT > ~/.ssh/config
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
EOT

On KVM1 and KVM2 servers ,start the services:


# systemctl status messagebus.service
# systemctl status libvirtd.service
# systemctl start messagebus.service
# systemctl start libvirtd.service
On KVM1 and KVM2 servers ,configure the bridging for instances:
You will need to have your main interface connected to a bridge. We will do the following example
with ens3 but the name of the interface may vary. An OpenNebularequirements is that the name of the
bridge should be the same in all nodes.
#vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

DEVICE=eno16777736
BOOTPROTO=none
78
CS8711- Cloud Computing Laboratory REG NO: 111917104059

NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet

****BRIDGE=br0****
#vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no

****Reboot kvm1 and kvm2 to see if devices are configured****


# ip route show | grep -i " br0"
****Using browser, open http://frontend1:9869****

****Password is here****
****On frontend1****
#su - oneadmin
#cat ~/.one/one_auth

****Copy that key into your browser password field****

79
CS8711- Cloud Computing Laboratory REG NO: 111917104059

Output:

Result:
Thus installation of OPEN NEBULA Cloud setup is executed successfully.

80

You might also like