KVM stands for Kernel-based Virtual machine and is an open source linux hypervisor. It runs on x86 plateforms and necessits the activation of processor dedicated instructions Intel-VT or AMD-V.
KVM is developped by Red Hat and is the base for their virtualization platform RHEV (Red Hat Entreprise Virtualization). KVM is also used as main hypervisor in the Proxmox VE distribution and is integrated to Joyent SmartOS.
It appears that this solution perfectly fit in small to medium environments. The setup is not so difficult and this product is easy to use with virt-manager (for those who are familiar with VMware, it is a tool like vSphere client).
In this example I will use a CentOS 6 with the following partition scheme.
— Disk 1 (system) : traditional
— Disk 2 (VMs) : LVM
As we might need, one day, to extend the size of our VM storage, using LVM is a good idea. Of course there are other solutions like DAS, NAS or SAN storage.
I also assume that you set up RAID (hardware or software).
KVM installation :
#yum update #yum kvm kmod-kvm qemu kvm-qemu-img libvirt virt-install #wget http://pkgs.repoforge.org/qemu/qemu-0.9.1-1.el3.rf.x86_64.rpm #yum install qemu-0.9.1-1.el3.rf.x86_64.rpm #modprobe kvm-intel #usermod -G kvm -a remoteuser #chown root:kvm /dev/kvm chmod 0660 /dev/kvm
Network bridge setup (be very careful with the syntax) :
#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-br0 #vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 HWADDR=00:18:8B:58:07:3B ONBOOT=yes BRIDGE=br0 #vim /etc/sysconfig/network-scripts/ifcfg-br0 DEVICE=br0 TYPE=Bridge BOOTPROTO=static ONBOOT=yes IPADDR=10.1.0.3 NETMASK=255.255.255.0 #vim /etc/sysctl.conf net.ipv4.ip_forward = 1 net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 #/sbin/sysctl -p (to reload sysctl settings)
On the KVM server install SSH and configure it as wanted :
# aptitude install openssh-server # vim /etc/ssh/sshd_config
Install the virt-manager package on your remote station :
#aptitude install virt-manager
Virt-manager is a very handy tool that allows you to :
– Create VMs
– Clone VMs
– Access VMs console
– Control basic KVM features
Virt-manager is an application written in Python. It uses the famous libvirt to interact with the hypervisors. This software supports Xen, QEMU and KVM hypervisors. Note that virt-manager is also developped by RedHat being a part of their RedHat Emerging Technology Project program (http://et.redhat.com/).
This tools relies on an SSH connection so it is relatively secured.
Tips when cloning virtual machines : in order to avoid conflicts (duplicate addresses for example) you can use the following procedure :
– Pause or shut down source VM
– Clone the VM
– Start the new VM
– Modify network parameters
– Restart the source VM
KVM is very promising alternative for those who want to set up virtualization at a lower cost. Day-to-day management is made easy through the use of virt-manager but you also take all the benefits of a Linux operating system (stability, configurability…).
I want to mention that virt-manager is not the only tool to manage KVM hypervisor. The oVirt project provide a feature rich interface to manage multiple servers. This a very interesting solution and the links are here after.