赞
踩
要查看您的系统是否支持硬件虚拟化 (HV),请运行以下命令:
$ cat /proc/cpuinfo | egrep "vmx|svm"
在输出中,查看标志列表。如果您发现vmx
(对于 Intel 处理器)或svm
(对于 AMD),则系统支持硬件虚拟化。
注意:如果您在支持 HV 的系统上安装 KVM 时遇到问题,请检查您的 BIOS 以查看是否启用了 HV。要启用 HV,请参阅主机 BIOS 的文档。
宿主机网卡配置:
- [root@anolise ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno1 | grep "#" -v
- DEVICE=eno1
- ONBOOT=yes
- BRIDGE=br0
宿主机桥接网桥配置:
- [root@anolise ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0 | grep "#" -v
- TYPE=Bridge
- BOOTPROTO=static
- NAME=br0
- UUID=c7d2fb1c-fce5-4f9c-a9e1-cca185807ee2
- DEVICE=br0
- ONBOOT=yes
- IPADDR=10.0.0.29
- PREFIX=24
- GATEWAY=10.0.0.1
- DNS1=114.114.114.114
- systemctl restart libvirtd
- systemctl restart NetworkManager
二、安装KVM
$ yum install @virt
启动并启用libvirtd服务
systemctl enable --now libvirtd
三、安装KVM所需工具包
- yum groupinstall "Virtualization Host"
-
- yum install virt-manager libvirt virt-manager libvirt-client virt-install virt-viewer -y
virt-manager 启动虚拟机管理,创建虚拟机。
四、虚拟机详情
- <domain type="kvm">
- <name>linux2020</name>
- <uuid>8e93d8fe-d261-4cc4-9e81-a84fa2bb4a4c</uuid>
- <metadata>
- <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
- <libosinfo:os id="http://libosinfo.org/linux/2020"/>
- </libosinfo:libosinfo>
- </metadata>
- <memory unit="KiB">4194304</memory>
- <currentMemory unit="KiB">4194304</currentMemory>
- <vcpu placement="static">2</vcpu>
- <os>
- <type arch="x86_64" machine="pc-q35-rhel8.6.0">hvm</type>
- <boot dev="hd"/>
- </os>
- <features>
- <acpi/>
- <apic/>
- </features>
- <cpu mode="host-passthrough" check="none" migratable="on"/>
- <clock offset="utc">
- <timer name="rtc" tickpolicy="catchup"/>
- <timer name="pit" tickpolicy="delay"/>
- <timer name="hpet" present="no"/>
- </clock>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <pm>
- <suspend-to-mem enabled="no"/>
- <suspend-to-disk enabled="no"/>
- </pm>
- <devices>
- <emulator>/usr/libexec/qemu-kvm</emulator>
- <disk type="file" device="disk">
- <driver name="qemu" type="qcow2" discard="unmap"/>
- <source file="/mnt/os/aliyun_3_x64_20G_nocloud_alibase_20220907.qcow2"/>
- <target dev="vda" bus="virtio"/>
- <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
- </disk>
- <disk type="file" device="disk">
- <driver name="qemu" type="raw"/>
- <source file="/mnt/os/seed.img"/>
- <target dev="vdb" bus="virtio"/>
- <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
- </disk>
- <controller type="usb" index="0" model="qemu-xhci" ports="15">
- <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
- </controller>
- <controller type="pci" index="0" model="pcie-root"/>
- <controller type="pci" index="1" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="1" port="0x10"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
- </controller>
- <controller type="pci" index="2" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="2" port="0x11"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
- </controller>
- <controller type="pci" index="3" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="3" port="0x12"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
- </controller>
- <controller type="pci" index="4" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="4" port="0x13"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
- </controller>
- <controller type="pci" index="5" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="5" port="0x14"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
- </controller>
- <controller type="pci" index="6" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="6" port="0x15"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x5"/>
- </controller>
- <controller type="pci" index="7" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="7" port="0x16"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x6"/>
- </controller>
- <controller type="pci" index="8" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="8" port="0x17"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x7"/>
- </controller>
- <controller type="pci" index="9" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="9" port="0x18"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0" multifunction="on"/>
- </controller>
- <controller type="pci" index="10" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="10" port="0x19"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x1"/>
- </controller>
- <controller type="pci" index="11" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="11" port="0x1a"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x2"/>
- </controller>
- <controller type="pci" index="12" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="12" port="0x1b"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x3"/>
- </controller>
- <controller type="pci" index="13" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="13" port="0x1c"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x4"/>
- </controller>
- <controller type="pci" index="14" model="pcie-root-port">
- <model name="pcie-root-port"/>
- <target chassis="14" port="0x1d"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x5"/>
- </controller>
- <controller type="sata" index="0">
- <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
- </controller>
- <controller type="virtio-serial" index="0">
- <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
- </controller>
- <interface type="bridge">
- <mac address="52:54:00:1e:9f:11"/>
- <source bridge="br0"/>
- <model type="virtio"/>
- <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
- </interface>
- <serial type="pty">
- <target type="isa-serial" port="0">
- <model name="isa-serial"/>
- </target>
- </serial>
- <console type="pty">
- <target type="serial" port="0"/>
- </console>
- <channel type="unix">
- <target type="virtio" name="org.qemu.guest_agent.0"/>
- <address type="virtio-serial" controller="0" bus="0" port="1"/>
- </channel>
- <input type="tablet" bus="usb">
- <address type="usb" bus="0" port="1"/>
- </input>
- <input type="mouse" bus="ps2"/>
- <input type="keyboard" bus="ps2"/>
- <graphics type="vnc" port="-1" autoport="yes">
- <listen type="address"/>
- </graphics>
- <audio id="1" type="none"/>
- <video>
- <model type="vga" vram="16384" heads="1" primary="yes"/>
- <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
- </video>
- <memballoon model="virtio">
- <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
- </memballoon>
- <rng model="virtio">
- <backend model="random">/dev/urandom</backend>
- <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
- </rng>
- </devices>
- </domain>
五、虚拟机网络配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0 文件名视实际情况而定
防火墙配置
安装配置SSH,可以远程连接进行管理操作。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。