共计 6062 个字符,预计需要花费 16 分钟才能阅读完成。
一、说明
1、硬件:需要在BIOS内开启CPU虚拟化支持;各硬件开启方式不同,这块大家自行百度。
2、系统:最小化安装,Update系统,关闭SELinux和防火墙。
二、安装部署
1、执行命令(egrep ‘(vmx|svm)’ /proc/cpuinfo)查看系统CPU是否支持VT功能,结果中有vmx(Intel)或svm(AMD)字样就说明CPU支持。
2、安装虚拟化包组:dnf group install -y “Virtualization Host”
# dnf group install -y "Virtualization Host"
Last metadata expiration check: 0:00:06 ago on Sun 20 Jul 2025 09:24:40 PM CST.
Dependencies resolved.
==================================================================================================================
Package Arch Version Repository Size
==================================================================================================================
Upgrading:
NetworkManager x86_64 1:1.52.0-4.el9_6 baseos 2.3 M
NetworkManager-libnm x86_64 1:1.52.0-4.el9_6 baseos 1.9 M
......此处省略......
sscg x86_64 3.0.0-7.el9 appstream 45 k
Installing Environment Groups:
Virtualization Host
Installing Groups:
Base
Core
Standard
Virtualization Hypervisor
Virtualization Tools
Transaction Summary
==================================================================================================================
Install 227 Packages
Upgrade 40 Packages
Total download size: 1.0 G
Downloading Packages:
(1/267): device-mapper-event-libs-1.02.202-6.el9.x86_64.rpm 198 kB/s | 31 kB 00:00
......此处省略......
(267/267): iwl7260-firmware-25.30.13.0-151.2.el9_6.noarch.rpm 2.3 MB/s | 66 MB 00:27
------------------------------------------------------------------------------------------------------------------
Total 17 MB/s | 1.0 GB 00:59
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: kmod-kvdo-8.2.5.10-161.el9.x86_64 1/1
Running scriptlet: linux-firmware-20250604-151.2.el9_6.noarch 1/1
Preparing : 1/1
Upgrading : glibc-common-2.34-168.el9_6.20.x86_64 1/307
......此处省略......
Running scriptlet: glibc-2.34-168.el9_6.19.x86_64 307/307
/usr/lib/sysusers.d/libvirt-qemu.conf:1: Conflict with earlier configuration for group 'kvm', ignoring line.
Verifying : device-mapper-event-libs-9:1.02.202-6.el9.x86_64 1/307
......此处省略......
Verifying : glibc-headers-2.34-168.el9_6.19.x86_64 307/307
Upgraded:
NetworkManager-1:1.52.0-4.el9_6.x86_64 NetworkManager-libnm-1:1.52.0-4.el9_6.x86_64
......此处省略......
systemd-rpm-macros-252-51.el9_6.1.noarch systemd-udev-252-51.el9_6.1.x86_64
Installed:
PackageKit-1.2.6-1.el9.x86_64
......此处省略......
xfsdump-3.1.12-4.el9_3.x86_64
Complete!
3、安装相关管理软件包:dnf install -y virt-install virt-manager virt-viewer openssh-askpass xorg-x11-server-utils xorg-x11-utils xorg-x11-xauth xorg-x11-xinit
# dnf install -y virt-install virt-manager virt-viewer openssh-askpass xorg-x11-server-utils xorg-x11-utils xorg-x11-xauth xorg-x11-xinit
Last metadata expiration check: 0:17:05 ago on Sun 20 Jul 2025 09:24:40 PM CST.
Dependencies resolved.
==================================================================================================================
Package Architecture Version Repository Size
==================================================================================================================
Installing:
openssh-askpass x86_64 8.7p1-45.el9.rocky.0.1 appstream 17 k
......此处省略......
libvirt-daemon-kvm x86_64 10.10.0-7.3.el9_6 appstream 29 k
Transaction Summary
==================================================================================================================
Install 27 Packages
Upgrade 1 Package
Total download size: 5.9 M
Downloading Packages:
(1/28): python3-argcomplete-1.12.0-5.el9.noarch.rpm 197 kB/s | 61 kB 00:00
......此处省略......
(28/28): libxml2-2.9.13-10.el9_6.x86_64.rpm 3.6 MB/s | 746 kB 00:00
------------------------------------------------------------------------------------------------------------------
Total 4.0 MB/s | 5.9 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : libxml2-2.9.13-10.el9_6.x86_64 1/29
......此处省略......
Verifying : libxml2-2.9.13-9.el9_6.x86_64 29/29
Upgraded:
libxml2-2.9.13-10.el9_6.x86_64
Installed:
gtk-vnc2-1.3.0-2.el9.x86_64 gtksourceview4-4.8.1-5.el9.x86_64
......此处省略......
xorriso-1.5.4-5.el9_5.x86_64
Complete!
4、启动libvirtd服务并设置服务自启动:systemctl enable –now libvirtd.service
# systemctl enable --now libvirtd.service
Created symlink /etc/systemd/system/multi-user.target.wants/libvirtd.service → /usr/lib/systemd/system/libvirtd.service.
Created symlink /etc/systemd/system/sockets.target.wants/libvirtd.socket → /usr/lib/systemd/system/libvirtd.socket.
Created symlink /etc/systemd/system/sockets.target.wants/libvirtd-ro.socket → /usr/lib/systemd/system/libvirtd-ro.socket.
Created symlink /etc/systemd/system/sockets.target.wants/libvirtd-admin.socket → /usr/lib/systemd/system/libvirtd-admin.socket.
# systemctl status libvirtd.service
● libvirtd.service - libvirt legacy monolithic daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; preset: disabled)
Active: active (running) since Sun 2025-07-20 21:44:41 CST; 9s ago
TriggeredBy: ● libvirtd-admin.socket
● libvirtd.socket
● libvirtd-ro.socket
Docs: man:libvirtd(8)
https://libvirt.org/
Main PID: 5808 (libvirtd)
Tasks: 22 (limit: 32768)
Memory: 50.4M
CPU: 472ms
CGroup: /system.slice/libvirtd.service
├─5808 /usr/sbin/libvirtd --timeout 120
├─5911 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-scr>
└─5912 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-scr>
Jul 20 21:44:41 kvm-server01 systemd[1]: Started libvirt legacy monolithic daemon.
Jul 20 21:44:41 kvm-server01 dnsmasq[5911]: started, version 2.85 cachesize 150
Jul 20 21:44:41 kvm-server01 dnsmasq[5911]: compile time options: IPv6 GNU-getopt DBus no-UBus no-i18n IDN2 DHCP >
Jul 20 21:44:41 kvm-server01 dnsmasq-dhcp[5911]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Jul 20 21:44:41 kvm-server01 dnsmasq-dhcp[5911]: DHCP, sockets bound exclusively to interface virbr0
Jul 20 21:44:41 kvm-server01 dnsmasq[5911]: reading /etc/resolv.conf
Jul 20 21:44:41 kvm-server01 dnsmasq[5911]: using nameserver 192.168.80.254#53
Jul 20 21:44:41 kvm-server01 dnsmasq[5911]: read /etc/hosts - 2 addresses
Jul 20 21:44:41 kvm-server01 dnsmasq[5911]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jul 20 21:44:41 kvm-server01 dnsmasq-dhcp[5911]: read /var/lib/libvirt/dnsmasq/default.hostsfile
5、重启系统:reboot
6、使用支持 X11 转发的终端(如 MobaXterm)通过 SSH 连接至服务器,执行 virt-manager 命令,即可调用图形化界面管理 KVM。
# virt-manager
正文完
发表至: KVM
2025-07-20