Virtualization With KVM On A CentOS 5.2 Server
|
Submitted by falko (Contact Author) (Forums) on Thu, 2009-04-09 16:23. :: CentOS | KVM | Virtualization
Virtualization With KVM On A CentOS 5.2 ServerVersion 1.0 This guide explains how you can install and use KVM for creating and running virtual machines on a CentOS 5.2 server. I will show how to create image-based virtual machines and also virtual machines that use a logical volume (LVM). KVM is short for Kernel-based Virtual Machine and makes use of hardware virtualization, i.e., you need a CPU that supports hardware virtualization, e.g. Intel VT or AMD-V. I do not issue any guarantee that this will work for you!
1 Preliminary NoteI'm using a CentOS 5.2 server with the hostname server1.example.com and the IP address 192.168.0.100 here as my KVM host. We also need a desktop system where we install virt-manager so that we can connect to the graphical console of the virtual machines that we install. I'm using an Ubuntu 8.10 desktop here.
2 Installing KVMCentOS 5.2 KVM Host: Run system-config-securitylevel and set SELinux to Permissive (virt-install will not work if you set SELinux to Disabled). Then check if your CPU supports hardware virtualization - if this is the case, the command egrep '(vmx|svm)' --color=always /proc/cpuinfo should display something, e.g. like this: [root@server1 ~]# egrep '(vmx|svm)' --color=always /proc/cpuinfo If nothing is displayed, then your processor doesn't support hardware virtualization, and you must stop here. Now we import the GPG keys for software packages: rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* To install KVM and virtinst (a tool to create virtual machines), we run yum install kvm kmod-kvm qemu libvirt python-virtinst Then reboot the system: reboot After the reboot, the KVM kernel module should be loaded: lsmod | grep kvm [root@server1 ~]# lsmod | grep kvm (This output is from a system with an AMD-V processor. If your system uses an Intel VT CPU, it should display something like kvm_intel.) To check if KVM has successfully been installed, run virsh -c qemu:///system list It should display something like this: [root@server1 ~]# virsh -c qemu:///system list If it displays an error instead, then something went wrong. Next we need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems in the network. To do this, we install the package bridge-utils... yum install bridge-utils ... and configure a bridge. Create the file /etc/sysconfig/network-scripts/ifcfg-br0 (please use the BOOTPROTO, BROADCAST, IPADDR, NETMASK and NETWORK values from the /etc/sysconfig/network-scripts/ifcfg-eth0 file): vi /etc/sysconfig/network-scripts/ifcfg-br0
Modify /etc/sysconfig/network-scripts/ifcfg-eth0 as follows (comment out BOOTPROTO, BROADCAST, IPADDR, NETMASK, and NETWORK and add BRIDGE=br0): vi /etc/sysconfig/network-scripts/ifcfg-eth0
Restart the network... /etc/init.d/network restart ... and run ifconfig It should now show the network bridge (br0): [root@server1 ~]# ifconfig
3 Installing virt-viewer Or virt-manager On Your Ubuntu 8.10 DesktopUbuntu 8.10 Desktop: We need a means of connecting to the graphical console of our guests - we can use virt-manager (see KVM Guest Management With Virt-Manager On Ubuntu 8.10) for this. I'm assuming that you're using an Ubuntu 8.10 desktop. Run sudo aptitude install virt-manager to install virt-manager. (If you're using a Fedora 10 desktop, you can install virt-manager as follows: Become root... su ... and run yum install virt-manager )
|



Recent comments
1 day 4 hours ago
1 day 9 hours ago
1 day 14 hours ago
1 day 16 hours ago
2 days 6 hours ago
2 days 6 hours ago
2 days 11 hours ago
2 days 18 hours ago
2 days 18 hours ago
2 days 20 hours ago