Jump to content
xisto Community
yordan

Learn How To Setup A Virtualized Environment With Kvm

Recommended Posts

Today we will learn how to configure a hardware server hosting several virtual machines.

Why should we learn how to manage virtual machines? Because virtualization is the leading architecture in today’s computing world.

In standalone machines, unused cpu power is a waste of money. Virtualization allows us creating several machines, several database servers, web servers, application servers, Linux servers as well as Windows servers, all of them in the same physical box, but fully independent from each other. The physical cpu power is shared between the servers as you decide it.

For maintenance purposes also, it’s the ideal case. You create several web servers, and you are able to power down one while the other one continues working.

Several virtualization environments are available today. Here I will talk about KVM installation on CentOS.

We will learn how to install


  • The server hosting the partitions.
  • The administration workstation which will create and manage the partitions.

Why should we create two servers?

Because in a real world, if you are the system administrator, you will have to administrate several servers from a single administration point – your own laptop in your office.

Each time you will add a server, you install only the server, the administration client is installed only once, until you break it or overuse it.

The server needs only cpu power and a lot of fast disks and Ethernet power. No graphics needed because in a real datacentre, the console will be used only once and then removed in order to save place and electrical power.

The administration workstation does not need a lot of cpu power (because you don’t type so fast…) but it needs a reasonable graphic adapter because you love clicking icons.

Of course, the client and the server can be installed on the same hardware, but in the present document I will discuss separately the server part (without graphics but with server software) and the administration workstation (with graphics and with client software).

Both will be installed from the same CentOS DVD.

 

 

Installing the Centos KVM server

As usually, boot on the install DVD.

When you see the first screen, click “install or upgrade”

You will see the CentOs Screen (figure A1) press next.

Posted Image

 

Choose your language (figure a2 I choose English of course)

Posted Image

 

Choose your keyboard, chose the way you use your disks (basic storage, no SAN nor NAS), then “Discard any Data”, choose your hostname, your location, choose the root password, “use all space” on the disk, you will see the file system creation confirmation.

And now comes the real interesting part, choosing the software to be installed.

We are going to install a virtualization server, so we choose “Virtual host” (see figure a3 below)

Posted Image

 

We don’t need any more software for a virtualization server. Howerver, if you hate Linux command lines, or if you feel lazy, you could also have considered adding graphics, and so one. See figure a6 below.

Posted Image

 

 

That’s all, the installation process starts, figure a4

Posted Image

 

 

Let’s have a coffee until the installation ends. In the meanwhile you will see information displayed, like “installing libvirt” or “installing yum”.

Which is a good thing, because we will use libvirt, of course, and we will probably want to update it using yum.

At the end you see the “congrats please reboot” screen.

Posted Image

 

Installing the CentOS administration client

Boot on the CentOs installation DVD. You will see the Centos6 splash screen. Accept the default option “Install or upgrade an existing system”(figure B1)

Posted Image

 

 

Skip the “testing the media option”, except if you don’t trust your install DVD. For instance you could check your media once, and for the next installs you skip the test.

(figure B2)

Posted Image

 

You could eventually experience problems with the graphic adapters. (fig B3)

Posted Image

 

If you have this kind of problems with your graphic adapters, don’t panic. Simply reboot your virtual system, and on the splash screen, instead of choosing the default “install”, hit the “escape” key.

You will see the “boot:” prompt, type the words “linux vnc" (figure b4)

Posted Image

 

 

You will see the system booting, activating the Ethernet adapter, and telling you to manually connect your vnc client to the IP address where a vnc server is listening (figure B5)

Posted Image

 

 

Open the vnc client and continue the graphic installation.

As usual, choose the language, keyboard , city (figure b6)

Posted Image

 

As usual, give the root password, and allow formatting the filesystems on disk.

At the software selection screen choose “Minimal Desktop” (figure b7)

Posted Image

The installation will start, you will see a lot of sentences “installing blah-blah”, like the one shown below (figure b8)

Posted Image

 

 

 

 

then will come the final message “Congratulations, your CentOS installation is complete, please reboot”

After reboot, connect to your system, and start a command-line console.

 

Type

yum install libvirt virt-manager

This will install a lot of rpm’s, the ones needed by libvirt.

Then, type the following commands in order configure the libvirtd starting, and start it now.

[root@kvmcli2 ~]# chkconfig --level 3 libvirtd on[root@kvmcli2 ~]# chkconfig --level 5 libvirtd on[root@kvmcli2 ~]# service libvirtd startStarting libvirtd daemon:                                  [  OK  ][root@kvmcli2 ~]#

We could also update our system now,

Type the following :

 yum update

You will see :

Transaction Summary================================================================================Install       1 Package(s)Upgrade     111 Package(s)Total download size: 235 MIs this ok [y/N]: yDownloading Packages:

Now we are ready to start the virtual manager graphic environment.

Click Applications à System Tools à Virtual Machine Manager

(see figure B9 here below)

Posted Image

 

Simply ignore the warning “The following packages are not installed: qemu-kvm”, we don’t really need them for our current purpose, so answer “no” to the question “would you like to install them”.

Now you see the Virtual Machine Manager screen (figure b10 below)

Posted Image

 

 

 

Ignore the error message concerning the default hypervisor, we are going to create it now :D

Click File à Add Connection

As shown on the screenshot (figure b11),

Hypervisor QEMU/KVM

Method : SSh

Username : root

Hostname : the name or the IP address of the server system.

Posted Image

 

 

 

You will see the usual question “are you sure you want to continue connecting?” (figure b12)

Posted Image

 

When prompted, enter the root password, and you will see “123.456.789.101 (QEMU) – Connecting”

And now you are ready. Your Virtual Machine Manager is connected, and you can see the existing virtual machine, my first machine is shutoff and is named “windows”

Posted Image

 

 

Having a working server and a virtual machine manager available and connected, we are able to create our first partition.

 

Create a new partition.

Right-click on the virtualization server (on the QEMU word) and chose “new”

Step 1of5 is giving the virtual partition name, I name mine “mycentos” figure b14.

Posted Image

 

 

I want to install from my centos DVD, so for step 2 I click “use CDROM or DVD”, see figure b15

Posted Image

 

Click “Forward”, fill the cpu, memory and disk size assignments, and as soon as all the creation steps are finished you see the virtual machine booting on the CentOS bootdisk.

The CentOS installation is a standard one, exactly as a real system. Complete the keyboard, language and other usual settings, and you have a fully usable partition.

You can see my two partitions (fig b17) here, and you can see that the “mycentos” partition is using 100% of the allowed cpu.

Posted Image

 

 

 

 

You are ready to enjoy your virtual server. Probably your first steps will be checking the Ethernet settings, configure the Remote Desktop settings, and connect from your office PC! You will be able to see that it behaves exactly as a standard standalone system.

 

 

If you see a message saying like “KVM is not available” (fig. b16)

Posted Image

 

In order to see if the kernel modules are loaded, type the following :

$ cat /proc/cpuinfo |grep -E "vmx|svm"flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave lahf_lm arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpidflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave lahf_lm arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid

If you see something, this means that the the kernel modules have been loaded. Then, check that the virtualization extensions are available in the bios. If you cannot activate them, this means that you did not buy the ideal hardware for that purpose. You will still be able to learn how to install and configure virtual partitions, simply each action will seem teeeerribly looooong :D

 

 

And now, what comes next?

Now you have learned how to install a virtualization server hosting several virtual machines, using CentOS Linux, the free Community Enterprise Operating System.

For a commercial use, your company will probably prefer purchasing a commercial Linux distro, with a fully efficient customer service and on-field support. Then, simply re-install your test systems with the RedHat version, and learn the differences between the free and the commercial Linux systems!

Share this post


Link to post
Share on other sites

Nice tutorial @yordan....How would you compare this with Oracle virtual box.... I mean it is more commonly used and there is more active developement as well as user support..... Are there any performance, usability differences ????

Share this post


Link to post
Share on other sites

Here is a nice comparison between the virtualization techniques available today, have a look :

http://virtualization.softwareinsider.com/saved_compare/Xen-vs-KVM-vs-VirtualBox-Comparison-of-Open-Source-Virtualization-Software

I think that you have to know how KVM works, because it's the open-source environment. You have to test it before buying the commercial versions, in order to enjoy the differences.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.