提示:本次记录介绍根据在X86机器中,安装KVM服务的过程,仅供参考
提示:安装前需确保服务器可以支持与互联网互通,在安装过程中会需要下载外网依赖
整合服务器,使服务器利用率大化:虚拟化技术可使企业级的服务器运行多个虚拟机,从而有效控制了服务器数量的膨胀,大大提高了服务器利用率。另外,通过对未充分利用的服务器的整合,企业不再需要为新项目另外购置硬件,因此,减少了资金投入,降低了供电、制冷和场地方面的运营成本。
提示:以下是本篇文章正文内容,下面案例可供参考
uname -r
4.18.0-358.el8.x86_64
查询内核名称uname -s
Linux
主机的硬件架构名称uname -m
x86_64
二、检查本机是否支持虚拟化
cpu是否支持虚拟化或是否物理开启虚拟化
使用grep -E '(vmx|svm)' /proc/cpuinfo
或cat /proc/cpuinfo | grep vmx
命令
grep -E '(vmx|svm)' /proc/cpuinfo
# 展示如下信息标识cpu支持虚拟化
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
cat /proc/cpuinfo | grep vmx
# 展示如下信息标识cpu支持虚拟化
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip md_clear arch_capabilities
安装
安装kvm依赖
采用yum方式安装显示安装的工具有:libvirt、virt-install、qemu-kvm、qeum-img、wget;下面我们一次对对各版本进行逐一验证
yum info libvirt
名称 : libvirt
版本 : 8.0.0
发布 : 10.module_el8.7.0+1218+f626c2ff
架构 : x86_64
大小 : 0.0
源 : libvirt-8.0.0-10.module_el8.7.0+1218+f626c2ff.src.rpm
仓库 : @System
来自仓库 : appstream
概况 : Library providing a simple virtualization API
URL : https://libvirt.org/
协议 : LGPLv2+
描述 : 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.
yum info virt-install
名称 : virt-install
版本 : 3.2.0
发布 : 4.el8
架构 : noarch
大小 : 33 k
源 : virt-manager-3.2.0-4.el8.src.rpm
仓库 : @System
来自仓库 : appstream
概况 : Utilities for installing virtual machines
URL : https://virt-manager.org/
协议 : GPLv2+
描述 : Package includes several command line utilities, including virt-install
: (build and install new VMs) and virt-clone (clone an existing virtual
: machine).
yum info qemu-kvm
名称 : qemu-kvm
时期 : 15
版本 : 6.2.0
发布 : 20.module_el8.7.0+1218+f626c2ff.1
架构 : x86_64
大小 : 0.0
源 : qemu-kvm-6.2.0-20.module_el8.7.0+1218+f626c2ff.1.src.rpm
仓库 : @System
来自仓库 : appstream
概况 : QEMU is a machine emulator and virtualizer
URL : http://www.qemu.org/
协议 : GPLv2 and GPLv2+ and CC-BY
描述 : qemu-kvm is an open source virtualizer that provides hardware
: emulation for the KVM hypervisor. qemu-kvm acts as a virtual
: machine monitor together with the KVM kernel modules, and emulates the
: hardware for a full system such as a PC and its associated peripherals.
yum info qeum-img
名称 : qemu-img
时期 : 15
版本 : 6.2.0
发布 : 20.module_el8.7.0+1218+f626c2ff.1
架构 : x86_64
大小 : 8.2 M
源 : qemu-kvm-6.2.0-20.module_el8.7.0+1218+f626c2ff.1.src.rpm
仓库 : @System
来自仓库 : appstream
概况 : QEMU command line tool for manipulating disk images
URL : http://www.qemu.org/
协议 : GPLv2 and GPLv2+ and CC-BY
描述 : This package provides a command line tool for manipulating disk images.
yum info wget
名称 : wget
版本 : 1.19.5
发布 : 10.el8
架构 : x86_64
大小 : 2.8 M
源 : wget-1.19.5-10.el8.src.rpm
仓库 : @System
来自仓库 : appstream
概况 : A utility for retrieving files using the HTTP or FTP protocols
URL : http://www.gnu.org/software/wget/
协议 : GPLv3+
描述 : GNU Wget is a file retrieval utility which can use either the HTTP or
: FTP protocols. Wget features include the ability to work in the
: background while you are logged out, recursive retrieval of
: directories, file name wildcard matching, remote file timestamp
: storage and comparison, use of Rest with FTP servers and Range with
: HTTP servers to retrieve files over slow or unstable connections,
: support for Proxy servers, and configurability.
等待安装完成
yum install libvirt virt-install qemu-kvm wget -y
yum list installed qemu-img wget libvirt virt-install qemu-kvm
已安装的软件包
libvirt.x86_64 8.0.0-10.module_el8.7.0+1218+f626c2ff @appstream
qemu-img.x86_64 15:6.2.0-20.module_el8.7.0+1218+f626c2ff.1 @appstream
qemu-kvm.x86_64 15:6.2.0-20.module_el8.7.0+1218+f626c2ff.1 @appstream
virt-install.noarch 3.2.0-4.el8 @appstream
wget.x86_64 1.19.5-10.el8 @appstream
启动 libvirtdsystemctl start libvirtd.service
查看运行状态
systemctl status libvirtd.service
libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-12-01 05:57:34 UTC; 2s ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 320125 (libvirtd)
Tasks: 21 (limit: 32768)
Memory: 16.6M
CGroup: /system.slice/libvirtd.service
├─ 78916 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
├─ 78917 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
└─320125 /usr/sbin/libvirtd --timeout 120
12月 01 05:57:34 wcuu-nat-7230394803.local systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
12月 01 05:57:34 wcuu-nat-7230394803.local systemd[1]: libvirtd.service: Found left-over process 78917 (dnsmasq) in control group while starting unit. Igno>12月 01 05:57:34 wcuu-nat-7230394803.local systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
12月 01 05:57:34 wcuu-nat-7230394803.local systemd[1]: Starting Virtualization daemon...
12月 01 05:57:34 wcuu-nat-7230394803.local systemd[1]: Started Virtualization daemon.
12月 01 05:57:35 wcuu-nat-7230394803.local dnsmasq[78916]: read /etc/hosts - 6 addresses
12月 01 05:57:35 wcuu-nat-7230394803.local dnsmasq[78916]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
12月 01 05:57:35 wcuu-nat-7230394803.local dnsmasq-dhcp[78916]: read /var/lib/libvirt/dnsmasq/default.hostsfile
检查KVMlsmod | grep kvm
kvm_intel 323584 0
kvm 905216 1 kvm_intel
irqbypass 16384 1 kvm
任何事情可繁可简,重在与你如何看待它。
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧