Virtualization

75
Virtualization

description

Virtualization. What is Virtualization. - PowerPoint PPT Presentation

Transcript of Virtualization

Page 1: Virtualization

Virtualization

Page 2: Virtualization

What is Virtualization

Virtualization is a technique of partitioning or dividing the resources of a single server into multiple segregated execution environments. Each of these environments runs independently of the other, thus allowing multiple operating systems to run on the same hardware. This concept has been widely used in the world of mainframe computers over the years, and is now gaining a lot of traction in the world of enterprise IT systems. Each execution environment is called a guest and the server on which they execute is called the host. The software running on the host that acts as a bridge between the host and the guests, and that enables these multiple execution environments is commonly referred to as the Virtual Machine Monitor (VMM) or a Hypervisor.

Page 3: Virtualization

Why Virtualize? Server Consolidation (hard and soft costs) Reduction of Complexity Isolation Platform Uniformity Legacy Support

More effectively manage workloads Provide reliable testing infrastructure Faster deployment/provisioning (golden images)

Page 4: Virtualization

The Virtualization Approach

OS Instances for running specific apps

Fail-over between OS instances

greatly reduces recovery time

Separate components to avoid failure

Enhanced security with “separation”

Auto-provisioning for recovery

Performance penalties

Page 5: Virtualization

Virtualization Overview

Single OS image: Virtuozo Group user processes into resource containers

Hard to get strong isolation

Full virtualization: VMware, VirtualPC, QEMU Run multiple unmodified guest OSes

Hard to efficiently virtualize x86

Para-virtualization: UML, Xen Run multiple guest OSes ported to special arch

Arch Xen/x86 is very close to normal x86

Page 6: Virtualization

Virtual machines

Basic Terminology Host OS: The OS running on a physical machine

Guest OS: The OS running on a virtual machine

Today different approaches Full virtualization: Run an unmodified OS

Paravirtualization: Modification of OS for performance

Emulation: Host OS and Guest OS can have different architecture

Hardware support: Intel-VT, AMD-V

Page 7: Virtualization

XEN

Xen is an open-source paravirtualization technology that provides a platform for running multiple operating systems in parallel on one physical hardware resource, while providing close to native performance. Xen supports several operating systems—Linux

Page 8: Virtualization

Xen vs VMWare Architecture

ParentParent

VMMVMM

HardwareHardware

Guest 2Guest 2Guest 1Guest 1

VMMVMM

HardwareHardware

Host OSHost OS

Guest 1Guest 1 Guest 2Guest 2

Xen Based ArchitectureVMWare Based Architecture

Page 9: Virtualization

Full virtualization Full virtualization provides complete abstraction between the

hardware and the guest operating system. In this scenario, the guest operating system is provided a complete virtual physical environment in which to run and, as such, is unaware that it is running inside a virtual machine. One advantage of full virtualization is that the operating system does not need to be modified in order to run in a virtualized environment. This means that proprietary operating systems such as Windows can be run on Linux systems.

Disadvantages of full virtualization are that performance is slightly reduced as compared to para-virtualization, and some virtualization platforms, such as Xen, require CPUs with special virtualization support built in (such as Intel-VT and AMD-V).

Page 10: Virtualization

Para-Virtualization Para-virtualization requires that a guest operating

system be modified to support virtualization. This typically means that guest operating systems are limited to open source systems such as Linux. It is also not possible to migrate a running guest OS from one server to another. The advantage to this approach, however, is that a para-virtualized guest system comes closer to native performance than a fully virtualized guest, and the latest virtualization CPU support is not needed.

Page 11: Virtualization

Prerequirement

Linux Based O.S.

Hardware support: Intel-VT, AMD-V (for full virtu)

RAM 512 MINIMUM (256 for host and 256 for guest machine)

2 gb Space in Hard Disk.

Page 12: Virtualization

Prerequirement (2) Need to create the yum repository. Follow below steps:

Mkdir /repo Mount /rhel5.iso /repo -o loop

OR Mount /dev/cdrom /repo

Vi /etc/yum.repos.s/local.repo

name=rhel-base baseurl=file:///repo/Server/ enabled=1 gpgcheck=0

[rhel-xen] name=rhel - xen baseurl=file:///repo/VT/ enabled=1 gpgcheck=0

Page 13: Virtualization

Xen Installation

To install Xen Virtualization run blow command:

yum groupinstall virtualization

Need to boot machine with xen kernel. Verify xen kernel by below command:

uname -r

'

Page 14: Virtualization

Creating a Paravirtualized Virtual Machine

Page 15: Virtualization

Xen Management Console To start Xen management console, run virt-manager

Application tab --> System Tools --> Virtual Machine Manager

Page 16: Virtualization

Xen Management Console (2)

This Screen will appear.

Page 17: Virtualization

Xen Management Console (3)

Click on file menu. Select the open

connection. This screen will appear. Click on connect

button.

Page 18: Virtualization

Xen Management Console (4)

This screen will appear. Here select the localhost

and click on new.

Page 19: Virtualization

Xen Management Console (5)

Click on forward.

Page 20: Virtualization

Xen Management Console (6)

Select the type of virtualization.

Page 21: Virtualization

Xen Management Console (7)

Type the name of virtual machine.

Page 22: Virtualization

Xen Management Console (8)

Address of installation source.

Page 23: Virtualization

Xen Management Console (9)

Assign hard drive for virtual machine.

Page 24: Virtualization

Xen Management Console (10)

Select the type of network.

Page 25: Virtualization

Xen Management Console (11)

Specify the memory for virtual machine.

Page 26: Virtualization

Xen Management Console (12)

Wizard is completed, now click on finish.

Page 27: Virtualization

Create a paravirtualized vm from cmd

• virt-install \

• --paravirt \

• --name demo \

• --ram 500 \

• --file /var/lib/xen/images/demo.img \

• --file-size 6 \

• --vnc \

• --location http://download.fedora.redhat.com/pub/fedora/linux/core/6/x86_64/os/

Page 28: Virtualization

Creating a Full Virtualized Virtual Machine

Page 29: Virtualization

Xen Management Console To start Xen management console, run virt-manager

Application tab --> System Tools --> Virtual Machine Manager

Page 30: Virtualization

Xen Management Console (2)

This Screen will appear.

Page 31: Virtualization

Xen Management Console (3)

Click on file menu. Select the open

connection. This screen will appear. Click on connect

button.

Page 32: Virtualization

Xen Management Console (4)

This screen will appear. Here select the localhost

and click on new.

Page 33: Virtualization

Xen Management Console (5)

Click on forward.

Page 34: Virtualization

Xen Management Console (6)

Select the Fully Virtualized Machine

Page 35: Virtualization

Xen Management Console (7)

Locate the iso file of windows.

ORInsert Windows CD.

Select the OS Type. Select the OS Variant.

Page 36: Virtualization

Xen Management Console (8)

Assign hard drive for virtual machine.

Page 37: Virtualization

Xen Management Console (9)

Select the type of network.

Page 38: Virtualization

Xen Management Console (10)

Specify the memory for virtual machine.

Page 39: Virtualization

Xen Management Console (11)

Wizard is completed, now click on finish.

Page 40: Virtualization

Create full virtualized vm from cm

• # virt-install \

• --hvm \

• --name demo \

• --ram 500 \

• --nodisk \

• --livecd \

• --vnc \

• --cdrom /root/fedora7live.iso

Page 41: Virtualization

Xen Resource Management (1)

Connect with localhost.

Page 42: Virtualization

Xen Resource Management (2)

• Click on connect.

Page 43: Virtualization

Xen Resource Management (3)

This screen will appear. Select the Guest OS and

click on details.

Page 44: Virtualization

Xen Resource Management (4)

• Here we can define the number of cpus.

Page 45: Virtualization

Xen Resource Management (5)

• Here we can set the size of memory.

Page 46: Virtualization

Xen Resource Management (6)

• Here we can add more virtual harddisk.

Page 47: Virtualization

Xen Resource Management (7)

• Here we can add more NIC.

Page 48: Virtualization

XEN Live Migration

Migrating whole OS with running applications (kernel-internal state and application-level) rather than single processes

Page 49: Virtualization

Xen Migration type

• Red Hat Virtualization includes the capabilities to support migration of para-virtualized guests between Red Hat Virtualization servers. Migration can either be performed in two ways:

• Offline mode using the command xm migrate VirtualMachineName HostName. In this mode the virtual machine will be stopped on the original host and restarted on the new host.

• Live mode using the --live option for the command xm migrate --live VirtualMachineNameHostName.

Page 50: Virtualization

Why Xen Migration

• Load Balancing.

• Move a staging server to live server.

• Server mentenance.

• Optimize performance of server.

Page 51: Virtualization

Xen Migration Scenario

host1 nfssrvhost2

vm1

Vm1 migration

LAN Connectivity

Vm1 image

Page 52: Virtualization

Xen Migration Requirement

• Xen Migration should be active.

• Configure the NFS for shared storage

• Create paravirtualized virtual machine, which use the NFS as storage.

Page 53: Virtualization

Xen Migration Setup

• To enable the use of migration a few changes must be made to configuration file /etc/xen/xend-config.sxp. By default migration is disabled.

• Need to do changes on both xen host machines.

Page 54: Virtualization

Xen Migration Setup(1)

• Enabling migration.

– Modify the following entries in /etc/xen/xend-config.sxp to enable migration, remove the comments preceding the parameters in the configuration file:

– (xend-relocation-server yes)

– (xend-relocation-port 8002)

– (xend-relocation-address '')

– (xend-relocation-hosts-allow '')

Page 55: Virtualization

Xen Migration Setup(2)

• Restart Xend:

service xend restart

• Verify the Xen relocation server has started and is listening on the dedicated port for Xen migrations (8002):

– # lsof -i :8002

– COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME

– python 3445 root 14u IPv4 10223 TCP *:teradataordbms (LISTEN)

Page 56: Virtualization

Xen Migration Setup(3)

• Setting up the NFS server.

– # mkdir /xentest

– # mount /dev/sdb /xentest

– # cat /etc/exports

– /xentest *(rw,async,no_root_squash)

• Restart the nfs service

– Service nfs restart

Page 57: Virtualization

Xen Migration Setup(4)

• Verify it is exported via NFS:

– # showmount -e et-virt07

– Export list for et-virt07:

– /xentest *

Page 58: Virtualization

Xen Migration Setup(5)

• After starting the NFS server, we can then mount it on host1, host2:

– mount nfssrv:/xen /xen

Page 59: Virtualization

Xen Migration Setup(6)

• Create a guest machine using nfs shared storage on host1 only.

• After complete the installation shutdown the guest machine. Now perform the migration from host1 to host2.

• xm migrate rhel5 host2

Page 60: Virtualization

Xen Migration Setup(7)

• Proceed to start Xen guest on host1

• Now perform the live migration

• xm migrate –live rhel5-2 host2

Note: Guest machine should have it's disk over nfs shared storage.

Page 61: Virtualization

Xen Migration Setup(8)

• Try to open multiple terminal windows on both Xen hosts with the following command:

– watch -n1 xm list

• And ping the guest machine

Page 62: Virtualization

Xen Management Commands

• To connect a remote machine from virt-manager

– virt-manager -c xen+ssh://192.168.1.20/system

Page 63: Virtualization

Xen Management Commands

• To make a clone of exist Virtual machine

– # virt-clone \

– --original demo \

– --name newdemo \

– --file /var/lib/xen/images/newdemo.img

Page 64: Virtualization

Xen Management Commands

• To start a vartual machine

– Xm create machinename -c

Page 65: Virtualization

Xen Management Commands

• To see the list of virtual machines

– # xm listName ID Mem VCPUs State Time(s)Domain-0 0 1302 1 r----- 5809.3WinXP-LVM-HVM 4 256 1 -b---- 31.8fedora.fc6.nfs 1 256 1 -b---- 11.2

Page 66: Virtualization

Xen Management Commands

• Attach to domain domain-id’s console.

– Xm console 121

Page 67: Virtualization

Xen Management Commands

• Immediately terminate the domain domain-id.

– Xm destroy 101

Page 68: Virtualization

Xen Management Commands

• Adding an ISO file as a CD-ROM to a guest configuration file

– ['file:/var/lib/xen/images/win2003sp1.dsk,hda,w',\

– 'file:/xen/trees/ISO/WIN/en_windows_server_2003_with_sp1_standard.iso,hdc:cdrom,r',]

Page 69: Virtualization

Xen Management Commands

• Mount an ISO as a Disk

– xm block-attach guestdomain file://opt/rhel5-2.iso /dev/hdc ro

Page 70: Virtualization

Xen Management Commands

• Adding a file based container as additional storage to a guest.

– dd if=/dev/zero of=FileName.img bs=1M seek=4096 count=0 OR

– dd if=/dev/zero of=FileName.img bs=1M count=4096

– disk = [ 'tap:aio:/var/lib/xen/images/rhel5vm01.dsk,xvda,w', ] OR

– disk = [ 'tap:aio:/var/lib/xen/images/rhel5vm01.dsk,xvda,w',\

– 'tap:aio:/xen/images/oracle.dsk,xvdb,w', ]

Page 71: Virtualization

Xen Management Commands

• Use the following xm commands for monitoring and troubleshooting:

– xm top

– xm dmesg

– xm info

– xm log

– xm uptime

– xm sysrq

– xm dump-core

– xm rename

– xm domid

– xm domname

Page 72: Virtualization

Xen Management Commands

• Starting domains automatically during system boot

– # cd /etc/xen

– # cd auto

– # ls

– # ln -s ../rhel5vm01 .

– # ls -l

– lrwxrwxrwx 1 root root 14 Dec 14 10:02 rhel5vm01 -> ../rhel5vm01

Page 73: Virtualization

Xen Management Commands

• To mount xen guest image

– 1. check the partition on the image

– # fdisk -lu

– The result will be something like this:

– 2. Mount using offset option

– # mount -o loop,offset=106929152 /path/to/image /mnt , where 106929152=208846*512, 208846 is the start of the partition. Using this way, you only mount the second partition and not the whole image

– 3. You can now access your image at /mnt

Page 74: Virtualization

Xen Management tool

• virt-p2v is an experimental live CD for migrating physical machines to virtual machine guests.

• Download P2V from RedHat Website.

– http://et.redhat.com/~rjones/virt-p2v/download.html

• See the documentation and screenshots on below link

– http://et.redhat.com/~rjones/virt-p2v/

Page 75: Virtualization

Convirt• http://www.convirture.com/wiki/index.php?title=Installation#CentOS.2FRed_Hat

_Enterprise_Linux_5.x

– cd /etc/yum.repos.d

– wget --no-cache http://www.convirture.com/repos/definitions/rhel/5.x/convirt.repo

– yum install convirt

– convirt