官术网_书友最值得收藏!

Installing and configuring a KVM

This recipe covers the installing of virtualization tools and packages on RHEL 7.

By default, a RHEL 7 system doesn't come with a KVM or libvirt preinstalled. This can be installed in three ways:

  • Through the graphical setup during the system's setup
  • Via a kickstart installation
  • Through a manual installation from the command line

For this recipe, you should know how to install packages using yum, and your system should be configured to have access to the default RHEL 7 repository (refer to Chapter 8, Yum and Repositories, for more information), which is required for the packages that we will use.

Alternatively, you could install packages from the installation media using rpm, but you'll need to figure out the dependencies yourself.

Check the dependencies of an rpm using the following command:

~]# rpm -qpR <rpm file>

This will output a list of binaries, libraries, and files that you need installed prior to installing this package.

Check which package contains these files through this command:

~]# rpm -qlp <rpm package>

As you can imagine, this is a tedious job and can take quite some time as you need to figure out every dependency for every package that you want to install in this way.

Getting ready

To install a KVM, you will require at least 6 GB of free disk space, 2 GB of RAM, and an additional core or thread per guest.

Check whether your CPU supports a virtualization flag (such as SVM or VMX). Some hardware vendors disable this in the BIOS, so you may want to check your BIOS as well. Run the following command:

~]# grep -E 'svm|vmx' /proc/cpuinfo
flags : ... vmx ...

Alternatively, you can run the following command:

~]# grep -E 'svm|vmx' /proc/cpuinfo
flags : ... svm ...

Check whether the hardware virtualization modules (such as kvm_intel and kvm) are loaded in the kernel using the following command:

~]# lsmod | grep kvm
kvm_intel 155648 0
kvm 495616 1 kvm_intel

How to do it…

We'll look at the three ways of installing a KVM onto your system.

Manual installation

This way of installing a KVM is generally done once the base system is installed by some other means. You need to perform the following steps:

  1. Install the software needed to provide an environment to host virtualized guests with the following command:
    ~]# yum -y install qemu-kvm qemu-img libvirt
    

    The installation of these packages will include quite a lot of dependencies.

  2. Install additional utilities required to configure libvirt and install virtual machines by running this command:
    ~]# yum -y install virt-install libvirt-python python-virthost libvirt-client
    
  3. By default, the libvirt daemon is marked to autostart on each boot. Check whether it is enabled by executing the following command:
    ~]# systemctl status libvirtd
    libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled)
     Active: inactive
     Docs: man:libvirtd(8)
     http://libvirt.org
    
  4. If for some reason this is not the case, mark it for autostart by executing the following:
    ~]# systemctl enable libvirtd
    
  5. To manually stop/start/restart the libvirt daemon, this is what you'll need to execute:
    ~]# systemctl stop libvirtd
    ~]# systemctl start libvirtd
    ~]# systemctl restart libvirtd
    

Kickstart installation

Installing a KVM during kickstart offers you an easy way to automate the installation of KVM instances. Perform the following steps:

  1. Add the following package groups to your kickstarted file in the %packages section:
    @virtualization-hypervisor
    @virtualization-client
    @virtualization-platform
    @virtualization-tools
  2. Start the installation of your host with this kickstart file.

Graphical setup during the system's setup

This is probably the least common way of installing a KVM. The only time I used this was during the course of writing this recipe. Here's how you can do this:

  1. Boot from the RHEL 7 Installation media.
  2. Complete all steps besides the Software selection step.
  3. Go to Software Selection to complete the KVM software selection.
  4. Select the Virtualization host radio button in Base Environment, and check the Virtualization Platform checkbox in Add-Ons for Selected Environment:
  5. Finalize the installation.
  6. On the Installation Summary screen, complete any other steps and click on Begin Installation.

See also

To set up your repositories, check out Chapter 8, Yum and Repositories.

To deploy a system using kickstart, refer to Chapter 2, Deploying RHEL "En Masse".

For more in-depth information about using libvirt, go to http://www.libvirt.org/.

RHEL 7 has certain support limits, which are listed at these locations:

https://access.redhat.com/articles/rhel-kvm-limits

https://access.redhat.com/articles/rhel-limits

主站蜘蛛池模板: 樟树市| 茌平县| 通河县| 徐水县| 泰顺县| 新邵县| 阿合奇县| 池州市| 张家界市| 剑川县| 博湖县| 昔阳县| 方城县| 安吉县| 土默特右旗| 弥勒县| 宣恩县| 山东省| 剑河县| 浦县| 柳江县| 苗栗县| 长沙县| 江源县| 东方市| 新郑市| 灵丘县| 礼泉县| 太原市| 金阳县| 泗阳县| 西昌市| 辛集市| 荥经县| 天祝| 绥化市| 贵港市| 丹凤县| 杭锦旗| 平度市| 井研县|