安装虚拟化

本章介绍在openEuler中安装虚拟化组件的方法。

最低硬件要求

在openEuler系统中安装虚拟化组件,最低硬件要求:

  • AArch64处理器架构:ARMv8以上并且支持虚拟化扩展
  • x86_64处理器架构:支持VT-x
  • 2核CPU
  • 4GB的内存
  • 16GB可用磁盘空间

安装虚拟化核心组件

安装方法

前提条件

  • 已经配置yum源。配置方式请参见《openEuler 21.03 管理员指南》。
  • 安装操作需要root用户权限。

安装步骤

  1. 安装QEMU组件。

    1. # yum install -y qemu
  2. 安装libvirt组件。

    1. # yum install -y libvirt
  3. 启动libvirtd服务。

    1. # systemctl start libvirtd

安装虚拟化 - 图1 说明:
KVM模块已经集成在openEuler内核中,因此不需要单独安装。

验证安装是否成功

  1. 查看内核是否支持KVM虚拟化,即查看/dev/kvm和/sys/module/kvm文件是否存在,命令和回显如下:

    1. $ ls /dev/kvm
    2. /dev/kvm
    1. $ ls /sys/module/kvm
    2. parameters uevent

    若上述文件存在,说明内核支持KVM虚拟化。若上述文件不存在,则说明系统内核编译时未开启KVM虚拟化,需要更换支持KVM虚拟化的Linux内核。

  2. 确认QEMU是否安装成功。若安装成功则可以看到QEMU软件包信息,命令和回显如下:

    1. $ rpm -qi qemu
    2. Name : qemu
    3. Epoch : 2
    4. Version : 4.0.1
    5. Release : 10
    6. Architecture: aarch64
    7. Install Date: Wed 24 Jul 2019 04:04:47 PM CST
    8. Group : Unspecified
    9. Size : 16869484
    10. License : GPLv2 and BSD and MIT and CC-BY
    11. Signature : (none)
    12. Source RPM : qemu-4.0.0-1.src.rpm
    13. Build Date : Wed 24 Jul 2019 04:03:52 PM CST
    14. Build Host : localhost
    15. Relocations : (not relocatable)
    16. URL : http://www.qemu.org
    17. Summary : QEMU is a generic and open source machine emulator and virtualizer
    18. Description :
    19. QEMU is a generic and open source processor emulator which achieves a good
    20. emulation speed by using dynamic translation. QEMU has two operating modes:
    21. * Full system emulation. In this mode, QEMU emulates a full system (for
    22. example a PC), including a processor and various peripherials. It can be
    23. used to launch different Operating Systems without rebooting the PC or
    24. to debug system code.
    25. * User mode emulation. In this mode, QEMU can launch Linux processes compiled
    26. for one CPU on another CPU.
    27. As QEMU requires no host kernel patches to run, it is safe and easy to use.
  3. 确认libvirt是否安装成功。若安装成功则可以看到libvirt软件包信息,命令和回显如下:

    1. $ rpm -qi libvirt
    2. Name : libvirt
    3. Version : 5.5.0
    4. Release : 1
    5. Architecture: aarch64
    6. Install Date: Tue 30 Jul 2019 04:56:21 PM CST
    7. Group : Unspecified
    8. Size : 0
    9. License : LGPLv2+
    10. Signature : (none)
    11. Source RPM : libvirt-5.5.0-1.src.rpm
    12. Build Date : Mon 29 Jul 2019 08:14:57 PM CST
    13. Build Host : 71e8c1ce149f
    14. Relocations : (not relocatable)
    15. URL : https://libvirt.org/
    16. Summary : Library providing a simple virtualization API
    17. Description :
    18. Libvirt is a C toolkit to interact with the virtualization capabilities
    19. of recent versions of Linux (and other OSes). The main package includes
    20. the libvirtd server exporting the virtualization support.
  4. 查看libvirt服务是否启动成功。若服务处于“Active”状态,说明服务启动成功,可以正常使用libvirt提供的virsh命令行工具,命令和回显如下:

    1. $ systemctl status libvirtd
    2. libvirtd.service - Virtualization daemon
    3. Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
    4. Active: active (running) since Tue 2019-08-06 09:36:01 CST; 5h 12min ago
    5. Docs: man:libvirtd(8)
    6. https://libvirt.org
    7. Main PID: 40754 (libvirtd)
    8. Tasks: 20 (limit: 32768)
    9. Memory: 198.6M
    10. CGroup: /system.slice/libvirtd.service
    11. 40754 /usr/sbin/libvirtd