0% found this document useful (0 votes)
13 views64 pages

Cc-Lab Edited Manual.

The document outlines practical exercises for students at T.J.S Engineering College, including installation of software like VirtualBox and Google App Engine, and executing programming tasks in C and Python. It provides detailed procedures and results for each exercise, demonstrating successful installations and application launches. Additionally, it covers the use of CloudSim for simulating cloud scenarios and running scheduling algorithms.

Uploaded by

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

Cc-Lab Edited Manual.

The document outlines practical exercises for students at T.J.S Engineering College, including installation of software like VirtualBox and Google App Engine, and executing programming tasks in C and Python. It provides detailed procedures and results for each exercise, demonstrating successful installations and application launches. Additionally, it covers the use of CloudSim for simulating cloud scenarios and running scheduling algorithms.

Uploaded by

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

T.J.

S ENGINEERING COLLEGE
(Approved by AICTE &Affiliated to Anna University, Chennai) Peruvoyal, (Near Kavaraipettai),

Gummidipoondi Taluk, Thiruvallur District-601206

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

REG NO :……………………………………….

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

SUBJECT CODE : ………………………………………………

YEAR/SEM : ………………………………………………
T.J.S ENGINEERING COLLEGE
(Approved by AICTE &Affiliated to Anna University, Chennai) Peruvoyal,

(Near Kavaraipettai), Gummidipoondi Taluk,


Thiruvallur District-601206.

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

DEPARTMENT : …………………………………………

SUBJECT CODE /TITLE : …………………………………

YEAR/SEM : ………………………………………

DATE OF EXAMINATION : ……………………………………….

REGISTER
NUMBER :

Certified that this is the Bonafide record of practical work done by the aforesaid student
in the
During the year
.

Laboratory in charge Head of the Department

Internal Examiner External Examiner


INDEX
PAGE STAFF
S.NO DATE NAME OF THE EXERCISE
NUMBER SIGN
EX.NO:01 Install Virtualbox/VMware Workstation with different
DATE: flavours of linux or windows OS on top of windows

AIM:
To Install VMware workstation with different flavours of linux on top of windows

PROCEDURE:
RESULT:
Thus, Virtualbox with different flavours of linux on top of windows was successfully
installed.
EX.NO:02 Install a C compiler in the virtual machine created
DATE: using virtual box and execute Simple Programs

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

****If gcc and / 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]$ gcc sum.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

RESULT:
Thus C Compiler in the virtual machine using Virtual Box was installed and then
simple program was executed successfully.
EX.NO:03 Install Google App Engine. Create hello world app and
other simple web applications using python/java

DATE:

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 install package.

Download the Windows installer – the simplest thing is to download it to your Desktop or another
folder that you remember.
Double Click on the GoogleApplicationEngine installer.

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 First Application

Now you need to create a simple application. We could use the “+” option to have the launcher
make us an application – but instead we will do it by hand to get a better sense of what is going on.
Make a folder for your Google App Engine applications. I am going to make the Folder on my
Desktop called “apps” – the path to this folder is:
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.yaml in 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.py with three lines in it:

print 'Content-Type: text/plain' print ' ' print 'Hello there Chuck'

Then start the GoogleAppEngineLauncher program 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/

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

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

RESULT:
Thus Google App engine was installed to create helloworld App web application using
python
EX.NO:4 Use GAE launcher to launch the web applications.
DATE:

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

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>
<link rel="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.
</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 , run the following command:
https://PROJECT_ID.REGION_ID.r.appspot.com
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:
Each time you press Refresh in your browser – you can see it retrieving the output with a
GET request.

Dealing With Errors

With two files to edit, there are two general categories of errors that you may encounter. If you make
a mistake on the app.yaml file, the App Engine will not start and your launcher will show a yellow
icon near your application:

To get more detail on what is going wrong, take a look at the log for the application:
In this instance – the mistake is mis--‐ indenting the last line in the app.yaml (line 8).

If you make a syntax error in the index.py file, a Python trace back error will appear in your
browser.

The error you need to see is likely to be the last few lines of the output – in this case I made a
Python syntax error on line one of our one--‐ line application.

Reference: http://en.wikipedia.org/wiki/Stack_trace

When you make a mistake in the app.yaml file – you must the fix the mistake and attempt to start
the application again.
If you make a mistake in a file like index.py, you can simply fix the file and press refresh in
your browser – there is no need to restart the server.

Shutting Down the Server

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

OUTPUT:
RESULT:
Thus GAE launcher was initiated and web application was launched successfully.
EX.NO:5 Simulate a cloud scenario using CloudSim and run a
DATE: scheduling algorithm that is not present in CloudSim

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
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-
usingeclipse/. 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 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 where the createDatacenter() method itself initializes the various datacenter characteristics
along with the host list. This is the most important entity without this there is no way the
simulation of hosting the virtual machine is applicable.

private static Datacenter createDatacenter(String name)

List<Host> hostList = new ArrayList<Host>();

List<Pe> peList = new ArrayList<Pe>();

int mips = 1000;

peList.add(new Pe(0, new PeProvisionerSimple(mips)));

int hostId = 0;

int ram = 2048; // host memory (MB)

long storage = 1000000 ; // host storage

int bw = 10000;

hostList.add(

new Host(

hostId,

new RamProvisionerSimple( ram),

number of brokers in the current simulation.


int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;
Initialize the simulation, provided with the current time, number of users and trace flag.
CloudSim.init(num_user, calendar, trace_flag);
Create a Datacenter.
Datacenter datacenter0 = createDatacenter("Datacenter_0");
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 ;

double costPerStorage = 0.001;

double costPerBw = 0.0 ;

LinkedList<Storage> storageList = new LinkedList<Storage>();

DatacenterCharacteristics characteristics = ne w

DatacenterCharacteristics(arch, os, vmm, hostList ,


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");

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

for (int i = 0; i < size; i++)

cloudlet = list.get(i);

Log.print(indent + cloudlet.getCloudletId() + indent +

indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS)

Log.print("SUCCESS");
Log.printLine(indent + indent +

cloudlet.getResourceId()

+ indent + indent + indent +

cloudlet.getVmId()

+ indent + indent +

dft.format(cloudlet.getActualCPUTime())

+ indent + indent +

dft.format(cloudlet.getExecStartTime())

+ indent + indent +

dft.format(cloudlet.getFinishTime()));

OUTPUT:
Once you Run the example the output for cloudsimExample1.java will be displayed like:
CloudsimExample1.java console output

RESULT:
Thus simulation of cloud scenario using cloudsim was done successfully.
EX.NO:6 Find a procedure to transfer the files from one virtual
DATE: machine to another virtual machine.

AIM:
To execute the procedure for transfer the file from one virtual machine to another
virtual machine.
Goto Terminal, [oneadmin@frontend ~]$ onevm list OUTPUT:
ID USER GROUP NAME STATU CPU UMEM HOST TIME
3 oneadmin oneadmin kvm1 runn 2 512M kvm2.saec.com 0d 00h01 2 oneadmin
oneadmin kvm2 runn 2 512M kvm1.saec.com 0d 00h02

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
EX.NO:7 Find a procedure to launch virtual machine using trystack

DATE:
AIM:
To execute the procedure to launch virtual machine using trystack
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
1.3 System must be enabled with KVM mode on both servers
# lsmod | grep -i kvm

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

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 | grep use_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
redhatlsb****

****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

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 -i nfs

1.16 On KVM1 and KVM2 servers ,check NFS #systemctl | grep -i nfs

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 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****


Open Frontend, kvm1, kvm2 (Pwd: Redhat)
Goto FrontEnd ->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 - 0 0 / 100 (0%) 0K / 986.7M (0%)


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

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

Goto Run -> type cmd -> ipcongif Check the IP ADDRESS of your system.
Goto FrontEnd,

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


Inserting Mode in the Editor Copy
the Following Code:

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

OUTPU
T:
ID USER GROU NAME CLUSTE BRIDGE LEASES 1
P R
oneadmin oneadmin private - br0 0

In Frontend, goto Apllication -> 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 oneadmin oneadmin TTYLinux_1.0 default 512M DB No rdy 0

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

Name : TTYLinux_1.0 VCPU:


1
CLICK “CREATE”

Goto Terminal,
[oneadmin@frontend ~]$ onetemplate list OUTPUT:
ID USER GROUP NAME REGTIME
2 oneadmin oneadmin 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 oneadmin oneadmin kvm1 runn 2 512M kvm2.saec.com 0d 00h01 2
oneadmin oneadmin kvm2 runn 2 512M kvm1.saec.com 0d 00h02

RESULT:
Thus procedure to launch virtual machine using trystack was done successfully
EX.NO:08 Install Hadoop single node cluster and run simple
DATE: applications like wordcount.

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 selinux mode 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 #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
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

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
<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>
</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
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
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
[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]$ hdfs namenode -format
[hadoop@hadoop]$ cd $HADOOP_HOME/sbin/
[hadoop@hadoop]$ start-
all.sh
[hadoop@hadoop]$ jps i browser
n
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:


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++;


} 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=wrdcn

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]$ javac wrdcnt.java

***Run the java file***

$java wrdcnt
OUTPUT:

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

You might also like