安装虚拟化
本章介绍在openEuler中安装虚拟化组件的方法。
最低硬件要求
在openEuler系统中安装虚拟化组件,最低硬件要求:
- AArch64处理器架构:ARMv8以上并且支持虚拟化扩展
- x86_64处理器架构:支持VT-x
- 2核CPU
- 4GB的内存
- 16GB可用磁盘空间
安装虚拟化核心组件
安装方法
前提条件
- 已经配置yum源。配置方式请参见《openEuler 22.03 LTS SP1 管理员指南》。
- 安装操作需要root用户权限。
安装步骤
安装QEMU组件。
# yum install -y qemu
安装libvirt组件。
# yum install -y libvirt
启动libvirtd服务。
# systemctl start libvirtd
说明:
KVM模块已经集成在openEuler内核中,因此不需要单独安装。
验证安装是否成功
查看内核是否支持KVM虚拟化,即查看/dev/kvm和/sys/module/kvm文件是否存在,命令和回显如下:
$ ls /dev/kvm /dev/kvm
$ ls /sys/module/kvm parameters uevent
若上述文件存在,说明内核支持KVM虚拟化。若上述文件不存在,则说明系统内核编译时未开启KVM虚拟化,需要更换支持KVM虚拟化的Linux内核。
确认QEMU是否安装成功。若安装成功则可以看到QEMU软件包信息,命令和回显如下:
[root@localhost ~]# rpm -qi qemu Name : qemu Epoch : 10 Version : 6.2.0 Release : 65.oe2203sp1 Architecture: x86_64 Install Date: Thu 11 May 2023 12:09:25 AM CST Group : Unspecified Size : 21829066 License : GPLv2 and BSD and MIT and CC-BY-SA-4.0 Signature : RSA/SHA256, Tue 27 Dec 2022 11:19:34 PM CST, Key ID 007fb747fb37bc6f Source RPM : qemu-6.2.0-65.oe2203sp1.src.rpm Build Date : Tue 27 Dec 2022 05:51:21 PM CST Build Host : dc-64g.compass-ci URL : http://www.qemu.org Summary : QEMU is a generic and open source machine emulator and virtualizer Description : QEMU is a FAST! processor emulator using dynamic translation to achieve good emulation speed. QEMU has two operating modes: Full system emulation. In this mode, QEMU emulates a full system (for example a PC), including one or several processors and various peripherals. It can be used to launch different Operating Systems without rebooting the PC or to debug system code. User mode emulation. In this mode, QEMU can launch processes compiled for one CPU on another CPU. It can be used to launch the Wine Windows API emulator (https://www.winehq.org) or to ease cross-compilation and cross-debugging. You can refer to https://www.qemu.org for more infortmation.
确认libvirt是否安装成功。若安装成功则可以看到libvirt软件包信息,命令和回显如下:
[root@localhost ~]# rpm -qi libvirt Name : libvirt Version : 6.2.0 Release : 49.oe2203sp1 Architecture: x86_64 Install Date: Thu 11 May 2023 12:10:05 AM CST Group : Unspecified Size : 0 License : LGPLv2+ Signature : RSA/SHA256, Tue 27 Dec 2022 10:52:12 PM CST, Key ID 007fb747fb37bc6f Source RPM : libvirt-6.2.0-49.oe2203sp1.src.rpm Build Date : Tue 27 Dec 2022 06:01:20 PM CST Build Host : dc-64g.compass-ci URL : https://libvirt.org/ Summary : Library providing a simple virtualization API Description : Libvirt is a C toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes). The main package includes the libvirtd server exporting the virtualization support.
查看libvirt服务是否启动成功。若服务处于“active”状态,说明服务启动成功,可以正常使用libvirt提供的virsh命令行工具,命令和回显如下:
$ systemctl status libvirtd ● libvirtd.service - Virtualization daemon Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2019-08-06 09:36:01 CST; 5h 12min ago Docs: man:libvirtd(8) https://libvirt.org Main PID: 40754 (libvirtd) Tasks: 20 (limit: 32768) Memory: 198.6M CGroup: /system.slice/libvirtd.service ─40754 /usr/sbin/libvirtd
文档捉虫