December 9, 2015 - David Sokolik

Install KVM Qemu virtualization on CentOS

How to install KVM qemu virtualization on CentOS:

First what is KVM, KVM are the acronyms for: Kernel-Bases Virtual Machine and it is the hottest trend in the virtualization world the development had progressed enough so it is now stable for us in production environments and many enterprises are shifting towards KVM from the generic Hyper-V or ESXi platforms.

One of the biggest advantages of KVM is that is absolutely  free  of charge and includes many of the feature you get with paid software for a complete list please visit the official KVM website (KVM-Features), another big advantage is that KVM is the default compute resource for OpenStack now if you have never heard of OpenStack I highly recommend going to their website and doing some reading but in a one liner, OpenStack is a combination of software to manage a complete virtualization solution that includes, web management interface, compute nodes, networking nodes for SDN and various storage technologies such as block storage and object storage.

In this small how-to I am going to use CentOS as my base OS, you are able to install KVM on almost any Linux distribution.

We are first required to download the necessary packages and as we are using CentOS we will be using the yum package manager

Notice: All commands shown below must run as root, also please note that they will perform changes to your network configuration on the CentOS.

1) Issuing yum command to install the required packages:

yum -y install qemu-kvm libvirt virt-install bridge-utils virt-manager

2) Checking that the KVM modules are loaded successfully

lsmod | grep kvm

2.1) The out put should look similar to this:

kvm_intel       138567  0
kvm             441119  1 kvm_intel

3) Now we start and enable auto start of the libvirtd daemon

systemctl start libvirtd && systemctl enable libvirtd

4) Now we start manipulating the networking, First we will add the bridge interface:

nmcli c add type bridge autoconnect yes con-name br0 ifname br0

5) Now we will set the IP address of the bridge interface:

nmcli c modify br0 ipv4.addresses 172.0.0.2/24 ipv4.method manual

Note: In this example I have used 172.0.0.2/24 but you can assign any IP address based on your own network topology

6) Now we will configure the gateway for the bridge:

nmcli c modify br0 ipv4.gateway 172.0.0.1

7) Now we will configure the DNS server address for the bridge:

nmcli c modify br0 ipv4.dns 10.0.0.1

8) Now we will delete our current interface:

nmcli c delete ens32

9) Now we will add the physical interface to our virtual bridge:

nmcli c add type bridge-slave autoconnect yes con-name ens32 ifname ens32 master br0

Note: I have used interface ‘ens32’ for this example your actual interface name might be different so please make sure to use your actual device name.

10) Now we preform a restart to the network to make sure the changes are been fully committed and have taken into affect:

systemctl stop NetworkManager; systemctl start NetworkManager

 

Note: It is highly recommended that you issues all of these commands in one batch as this will cause you to lose network connectivity to the CentOS.

You can now verify the settings by issuing one of the following commands:

ifconfig

or

ip addr

KVM / Virtualization & Cloud CentOS / KVM / Qemu / virt-manager /

Leave a Reply

Your email address will not be published. Required fields are marked *