CentOS/RHEL: How To Install and Configure KVM ENV

I would like to install and configure KVM ENV(A virtualized environment with kernel based virtual machine) on my centos or rhel. How do I install and configure KVM hypervisor under centos or rhel operating system? this post will guide you how to install and configure KVM hypervisor so that you can create a virtual machine.

You need to install some virtualization tools and Corresponding Packages of KVM, such as: kvm, qemu-kvm, python-virtinst, libvirt..etc.

1# CentOS install KVM Packages and virtualization tools

To install KVM Packages and other corresponding virtualization tools, issue the following command:

yum install kvm qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools

or

yum groupinstall "Virtualisation Tools" "Virtualization Platform"

yum install python-virtinst

outputs:

Loaded plugins: fastestmirror, refresh-packagekit, security, versionlock

Loading mirror speeds from cached hostfile

 * base: mirrors.pubyun.com

 * extras: mirrors.pubyun.com

 * updates: mirrors.pubyun.com

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package libguestfs-tools.x86_64 1:1.20.11-11.el6 will be installed

--> Processing Dependency: libguestfs-tools-c = 1:1.20.11-11.el6 for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64

--> Processing Dependency: libguestfs = 1:1.20.11-11.el6 for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64

--> Processing Dependency: perl(Win::Hivex) >= 1.2.7 for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64

--> Processing Dependency: perl(XML::Writer) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64

--> Processing Dependency: perl(Sys::Virt) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64

--> Processing Dependency: perl(Sys::Guestfs::Lib) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64

--> Processing Dependency: perl(Sys::Guestfs) for package: 1:libguestfs-tools-1.20.11-11.el6.x86_64

...

2# start libvirtd service 

The libvirtd program is the server side daemon component of the libvirt virtualization management system.

This daemon runs on host servers and performs required management tasks for virtualized guests. This includes activities such as starting, stopping and migrating guests between host servers, configuring and manipulating networking, and managing storage for use by guests.

type the following command:

service libvirtd start

checking the libvirtd status, issue the below command:

service libvirtd status

outputs:

libvirtd (pid  31128) is running...

3# install and configure network bridge

You need to create a network bridege so that the vms can communicate each other or connect to the internet or LAN.Firstly, issue the following command to install brigde-utils package.

yum install bridge-utils

outputs:

[root@osetc]# yum install bridge-utils

Loaded plugins: fastestmirror, refresh-packagekit, security, versionlock

Loading mirror speeds from cached hostfile

 * base: mirrors.pubyun.com

 * extras: mirrors.pubyun.com

 * updates: mirrors.pubyun.com

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package bridge-utils.x86_64 0:1.2-9.el6 will be updated

---> Package bridge-utils.x86_64 0:1.2-10.el6 will be an update

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package               Arch            Version              Repository     Size

================================================================================

Updating:

 bridge-utils          x86_64          1.2-10.el6           base           30 k

Transaction Summary

================================================================================

Upgrade       1 Package(s)

Total download size: 30 k

Downloading Packages:

bridge-utils-1.2-10.el6.x86_64.rpm                       |  30 kB     00:00    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Updating   : bridge-utils-1.2-10.el6.x86_64                               1/2

  Cleanup    : bridge-utils-1.2-9.el6.x86_64                                2/2

  Verifying  : bridge-utils-1.2-10.el6.x86_64                               1/2

  Verifying  : bridge-utils-1.2-9.el6.x86_64                                2/2

Updated:

  bridge-utils.x86_64 0:1.2-10.el6                                              

Complete!

Configuring Network Bridge

Edit the configuration file of network interface “/etc/sysconfig/network-scripts/ifcfg-eth0“, adding the following line and uncomment “IPADDR“, “NETMASK“.

BRIDGE=br0

Then create a new network bridge configuration file named “ifcfg-br0” under “/etc/sysconfig/network-scripts” directory and adding the following lines:

DEVICE=br0

TYPE=Bridge

BOOTPROTO=static

ONBOOT=yes

IPADDR=192.168.1.100

NETMASK=255.255.255.192

DELAY=0

Restart network service

type:

service network restart

done….

You might also like:

Sidebar



back to top