41
Operating System Level Virtualization Reza Farivar

Operating System Level Virtualization Reza Farivar

Embed Size (px)

Citation preview

Page 1: Operating System Level Virtualization Reza Farivar

Operating System Level Virtualization

Reza Farivar

Page 2: Operating System Level Virtualization Reza Farivar

Types of virtualization

• Native, full• Hardware assisted • Para-virtualization • OS level

– Containers– Jails– Chroot– Zones– Open-VZ Virtuozzo

Page 3: Operating System Level Virtualization Reza Farivar

Native and Full Virtualization• the virtual machine simulates enough hardware to

allow an unmodified "guest" OS (one designed for the same CPU) to be run in isolation.

• Examples:– VirtualBox– Virtual PC– Vmware– QEMU– Win4Lin– XEN/Virtual Iron

Page 4: Operating System Level Virtualization Reza Farivar

Hardware enabled virtualization

• the virtual machine has its own hardware and allows a guest OS to be run in isolation.

• Intel VT (IVT)• AMD virtualization (AMD-V)• Examples:

– VMware Fusion– Parallels Desktop for Mac– Parallels Workstation

Page 5: Operating System Level Virtualization Reza Farivar

Partial virtualization

• the virtual machine simulates multiple instances of much (but not all) of an underlying hardware environment, particularly address spaces.

Page 6: Operating System Level Virtualization Reza Farivar

Paravirtualization

• the virtual machine does not necessarily simulate hardware, but instead (or in addition) offers a special API that can only be used by modifying the "guest" OS.

• Terminologies– Hypervisor, hypercall– Enomalism

• Examples:– XEN, KVM, Win4Lin 9x

Page 7: Operating System Level Virtualization Reza Farivar

Operating system-level virtualization

• virtualizing a physical server at the operating system level, enabling multiple isolated and secure virtualized servers to run on a single physical server.

• Examples:– Parallels Workstation– Linux-VServer, Virtuozzo– OpenVZ, Solaris Containers– FreeBSD Jails– Chroot ?

Page 8: Operating System Level Virtualization Reza Farivar

Comparison

Page 9: Operating System Level Virtualization Reza Farivar

Thinner Containers, better performance

Page 10: Operating System Level Virtualization Reza Farivar

10

What is the Trade-Off?

Page 11: Operating System Level Virtualization Reza Farivar

11

Feature Comparison

Hypervisor Container

Multiple Kernels X

Load Arbitrary Modules X

Local Administration All

Live Migration OpenVZ

Live System Update X Zap

Page 12: Operating System Level Virtualization Reza Farivar

12

Xen 3.0 Guest VM

I/O Path•Process to Guest OS•Guest OS to IDD

Resource Control•Driver Domain

• Map Virtual Devices• CFQ for disk• HTB for network

Security Isolation•Hypervisor•Access Physical Level

• PCI Address• Virtual Memory

Resource Control•Hypervisor

• Allocate Resources• Schedule VMs

Schedules All VMs•Guest VM & IDD Scheduled•Two levels scheduling in Guest

Page 13: Operating System Level Virtualization Reza Farivar

13

VServer 2.0 Guest VM

Security Isolation•Access to Logical Objects

• Context ID Filter• User IDs• SHM & IPC address• File system Barriers

Resource Control•Map Container to

• HTB for Network• CFQ for Disk

•Logical Limits• Processes• Open FD• Memory Locks

Optimizations•File-level Copy-on-write

I/O Path•Process to COS

Scheduler•Single Level•Token Bucket Filterpreserves O(1) scheduler

Page 14: Operating System Level Virtualization Reza Farivar

14

VServer Implementation

• 8,700 lines across 350+ files– Leverage existing implementations– Applied to Logical Resources

• Not architecture specific– MIPS, ARM, SPARC, etc..– Low Overhead

Page 15: Operating System Level Virtualization Reza Farivar

15

Guest Comparison

Xen 3.0 VServer 2.0

Level of Virtualization Physical Logical

Resource Control HTB, CFQ, etc HTB, CFQ, etc

Scheduler 2-levels: Hyp + Guest 1-level

I/O Path 3 transfers 2 transfer

Page 16: Operating System Level Virtualization Reza Farivar

16

Configuration

Kernel Linux VServer 2.0 Xen 3.0.4

Version 2.6.16.33

Distribution Fedora Core 5

File system Independent LVM Partitions

Scheduler O(1) O(1)+TBF Credit

Machine HP DL360 G4p

CPU 2 x 1 core Xeon with 2MB L2

Network 2 Port GbE

Memory 4 GB

Hardware

System Software

Page 17: Operating System Level Virtualization Reza Farivar

17

Disk I/O: Write

Page 18: Operating System Level Virtualization Reza Farivar

18

CPU & Memory Performance

Page 19: Operating System Level Virtualization Reza Farivar

19

Performance at Scale - UP

Page 20: Operating System Level Virtualization Reza Farivar

Solaris Zones

Page 21: Operating System Level Virtualization Reza Farivar

Solaris Zones

Page 22: Operating System Level Virtualization Reza Farivar

Types of Zones

Page 23: Operating System Level Virtualization Reza Farivar

Zone Daemons

Page 24: Operating System Level Virtualization Reza Farivar

Zone File Systems

Page 25: Operating System Level Virtualization Reza Farivar

Zones Networking

Page 26: Operating System Level Virtualization Reza Farivar

Zones Resource Capping

Page 27: Operating System Level Virtualization Reza Farivar

OpenVZ

• Requires both the host and guest OS to be Linux

• Claim: There is only a 1–3% performance penalty for OpenVZ as compared to using a standalone server

• The basis of Virtuozzo Containers– By Parallels– Claim: 300% more virtual servers than hypervisor

solutions

Page 28: Operating System Level Virtualization Reza Farivar

OpenVZ: Less overhead

Page 29: Operating System Level Virtualization Reza Farivar

OpenVZ: LAMP Throuput

Page 30: Operating System Level Virtualization Reza Farivar

OpenVZ: LAMP Response Time

Page 31: Operating System Level Virtualization Reza Farivar

OpenVZ Components

Page 32: Operating System Level Virtualization Reza Farivar

OpenVZ Kernel Virtualization

Page 33: Operating System Level Virtualization Reza Farivar

OpenVZ Kernel Resource management

Page 34: Operating System Level Virtualization Reza Farivar

OpenVZ Checkpointing

Page 35: Operating System Level Virtualization Reza Farivar

OpenVZ Control Interface

Page 36: Operating System Level Virtualization Reza Farivar

LXC Linux Containers

Page 37: Operating System Level Virtualization Reza Farivar

• Better isolation as compared to a chroot (chroot jail).• Low overhead. LXC uses minimal resources in terms of RAM

and hard drive space without the overhead of installing a guest OS in a virtual machine ( VMWare / VirtualBox / KVM ).

• Applications and services (servers) run at native speed.• There is support for Linux containers in libvirt .• Linux containers work well with btrfs .• No special hardware is required, runs on 32 and 64 bit processors.• Linux containers are Open source.• Unlike XEN or OpenVZ , no patch is required to the kernel.

What are LXC Linux Containers?

Page 38: Operating System Level Virtualization Reza Farivar

• Create control group filesystem as the root user.# mkdir -p /cgroup# mount none -t cgroup /cgroup

Add to fstab so it will be there after a reboot.# vi /etc/fstab and add line belownone /cgroup cgroup defaults 0 0

• Applications to install.# apt-get install libvirt-bin debootstrap

• We need to download and install this pkg.lxc_0.7.2-1_amd64.deb# dpkg -i lxc_0.7.2-1_amd64.deb

LXC Linux Containers on Ubuntu with CentOs Clients

Page 39: Operating System Level Virtualization Reza Farivar

• # Create a container# lxc-create -f /path/to/{CONTAINER_NAME}/main/config/file -n {CONTAINER_NAME}# lxc-create -f /etc/lxc/lxc-centos.conf -n centos

Create a rootfs directory# mkdir /var/lib/lxc/centos/rootfs

• Copy files you worked on earlier.# cp -r /home/yourhomeidirectory/LXC/Centos5-x86_64/* /var/lib/lxc/{CONTAINER_NAME}/rootfs# cp -r /home/yourhomeidirectory/LXC/Centos5-x86_64/* /var/lib/lxc/centos/rootfs

• Create this file for creating and setup default devices for your containers.# vi  /usr/local/bin/lxc-config and add information below, also only needs to be run once for every new container you create.

Step1: Create a container

Page 40: Operating System Level Virtualization Reza Farivar

• # cd /var/lib/lxc/CONTAINER_NAME}/rootfs/# cd /var/lib/lxc/centos/rootfs/# /usr/local/bin/lxc-config # fix /dev

• Chrooting into the rootfs file system for centos# chroot /var/lib/lxc/centos/rootfs/

Setup root password for your container.# passwd root

• Start or Remove some services from running# chkconfig sshd on# chkconfig httpd on# chkconfig xinetd off# chkconfig sendmail off

•When finish type exit to finish chroot session.

Step2: Chroot session

Page 41: Operating System Level Virtualization Reza Farivar

• Destroy container and files# lxc-destroy -n {CONTAINER_NAME}# lxc-destroy -n centos

Start container# lxc-start -n {CONTAINER_NAME} init# lxc-start -n centos init

• Stop container# lxc-stop -n {CONTAINER_NAME}# lxc-stop -n centos

• Connect to tty console# lxc-console -n centos -t 1 doesn’t seem to work for me.

• Check your configuration# lxc-checkconfig

• List containers# lxc-lsIf you receive this error lxc-ls warning, got bogus unix line, reinstall uml-utiilities# sudo apt-get –reinstall install uml-utilities

• Is it RUNNING or STOPPED# lxc-info -n {CONTAINER_NAME}# lxc-info -n centos

Step3: Delete container and files