• No results found

Virtualization on Linux Using KVM and libvirt. Matt Surico Long Island Linux Users Group 11 March, 2014

N/A
N/A
Protected

Academic year: 2021

Share "Virtualization on Linux Using KVM and libvirt. Matt Surico Long Island Linux Users Group 11 March, 2014"

Copied!
23
0
0

Loading.... (view fulltext now)

Full text

(1)

Virtualization on Linux

Virtualization on Linux

Using KVM and libvirt

Using KVM and libvirt

Matt Surico

Long Island Linux Users Group 11 March, 2014

(2)

What will we talk about?

What will we talk about?

● Rationalizing virtualization ● Virtualization basics

● How does it work under Linux? ● Setting up a virtual host

(3)

Why virtualize? - Part 1

Why virtualize? - Part 1

(4)

Why virtualize? - Part 2

Why virtualize? - Part 2

(5)

Other reasons to virtualize

Other reasons to virtualize

● Ease of creating new servers (cloning) ● Ad-hoc projects (proof of concept)

● Experimentation with new distributions ● Self-Instructional situations

(6)

Virtualization Architecture

Virtualization Architecture

● One key component is the hypervisor.

● A hypervisor is software (or hardware, or even

firmware) that creates an interface between a

guest operating system and a virtual host so that virtual machines can be run.

● The hypervisor's job is to create and/or to

present a virtual operating platform to the virtual machine (an abstraction).

(7)

Hypervisor Diagrams

Hypervisor Diagrams

● We will briefly look at two general types of

hypervisors:

– Native (aka “Bare Metal”, or “Type 1”) – Hosted (aka “Type 2”)

(8)

Bare Metal Hypervisor

Bare Metal Hypervisor

(9)

Hosted Hypervisor

Hosted Hypervisor

(10)

KVM

KVM

● Simply put, this allows the Linux kernel to be a

hypervisor

● Has been in the kernel mainline since 2.6.20

● Contains virtualization extensions (Intel VT and

AMD-V), and loadable kernel modules (kvm.ko plus either kvm-intel.ko or kvm-amd.ko)

● Exposes the /dev/kvm interface to a host running

(11)

libvirt

libvirt

● C library with package bindings for many other languages like

Ruby, Java, python, perl, etc.

● A toolkit for managing virtualization ● Provides:

– Remote management using TLS encryption and x509 certificates

– Remote management authenticating with Kerberos and SASL

– Local access control using PolicyKit

– Zero-conf discovery using Avahi multicast-DNS

– Management of virtual machines, virtual networks and storage

(12)

libvirt diagram

(13)

How to check your CPU

How to check your CPU

● Use /proc/cpuinfo and look at the flags. There are different flags for Intel vs. AMD

● Intel

vmx = Intel VT-x (basic virtualization) - required

ept = Extended Page Tables

vpid = decreases TLB flushes during context switching between

guests

● AMD

svm = AMD SVM (basic virtualization) - required

(14)

Building the demo

Building the demo

● We'll take a brief walk through the steps taken to

prepare the laptop for today's demo

– Verify the CPU will work – Add storage to laptop

– Install CentOS 6.4 (the host OS) – Include virtualization packages

● Once these steps are done, virtual machines can

(15)

Build: CPU/RAM

Build: CPU/RAM

● The CPU in the laptop is AMD A4-3305M (dual core, 800 MHz, 512 KB cache) ● The command used to check the processor was:

[matt@aquila ~]$ grep flags /proc/cpuinfo | uniq

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx

mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid aperfmperf pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt cpb npt lbrv svm_lock nrip_save pausefilter

● Laptop has 3 GB RAM

● FYI: Home machine (dedicated virtual host) has Intel(R) Core(TM) i5-3570K CPU,

(16)

Build: Adding storage

Build: Adding storage

● Laptop has a single internal hard drive, dual boot

Ubuntu 13.04 and “a certain proprietary OS that came with the laptop.”

● Current hard drive didn't have enough space to setup

a third operating system plus the virtual disks for multiple VMs

● Used an external USB 3.0 drive (500 GB)

● Allows for total removal of the storage to operate the

(17)

Build: Partitioning storage

Build: Partitioning storage

During the installation of CentOS 6.4, the external drive showed up as /dev/sdb, so it was partitioned as such:

● /dev/sdb1 = /boot (1 GB) ● /dev/sdb2 = swap (4 GB)

● /dev/sdb3 = Physical Volume for LVM (the rest of the

drive)

– vg_kvm = Volume Group (~460 GB) – 334 GB allocated to logical volumes

(18)

Build: Logical Volumes

Build: Logical Volumes

[matt@aquila ~]$ sudo lvs vg_kvm LV VG Attr LSize libvirtKVMLV vg_kvm -wi-ao--- 300.00g rootKVMLV vg_kvm -wi-ao--- 15.00g usrKVMLV vg_kvm -wi-ao--- 15.00g varKVMLV vg_kvm -wi-ao--- 4.00g

● /dev/mapper/vg_kvm-libvirtKVMLV on /var/lib/libvirt type ext4 ● /dev/mapper/vg_kvm-rootKVMLV on / type ext4

● /dev/mapper/vg_kvm-usrKVMLV on /usr type ext4 ● /dev/mapper/vg_kvm-varKVMLV on /var type ext4

(19)

Build: CentOS installation

Build: CentOS installation

● CentOS 6.4 installed with “Virtual Host”

profile.

● Also added some other graphical

convenience packages

● Important: under Virtualization, pick

“Virtualization Tools”

(20)

Working with VMs

Working with VMs

Several Open Source tools available:

● virsh: command line, provided by libvirt ● Virtual Machine Manager: GUI

● oVirt: web application

(21)

Networking

Networking

● One or more virtual networks may be

created within the virtual host

● Virtual machines may be outfitted with one

or more virtual NICs

● The dnsmasq lightweight server provides

DNS and DHCP services for the virtual network

(22)

Networking: libvirt

(23)

Time for a demo!

Time for a demo!

What we'll see:

● Use of virsh and virt-manager

● Creating and managing VMs (including

cloning)

● Creating and managing virtual networks ● Provisioning additional storage for VMs

References

Related documents

There are several approaches in assessing genetic similarity between breeding material (i.e. inbred lines, hybrids, populations, landraces and races), which include

• Determine whether it is feasible to put all public and non-public Commission and Committee meeting records (agendas, packages and minutes) from 1943 to 1992 in searchable format

The design team considered QR codes strategic to provide increased value to the customer and contextualized information during production stages, RFID strategic to identify

Further- more, if we also consider that the three focal reserves repre- sented w51.3% of total coral reef habitat within all six reserves and assume that the three unsampled

Organizations typically use an incoherent strategy towards BI deployment, characterized by different departments or business units using different BI tools.. The decision is

High performance, open source hypervisor based on the Red Hat Enterprise Linux kernel with the Kernel- based Virtual Machine (KVM) hypervisor technology.. Delivered as the RHEV-H

high performance, open source hypervisor based on the red hat enterprise linux kernel with the Kernel- based Virtual Machine (KVM) hypervisor technology.. delivered as the rheV-h

Mirror A (active) Mirror B (active) Primary I/O path Primary I/O path VPLEX interconnect (dark fibre) VPLEX Clusters VPLEX Witness (virtual machine).. All