当前位置:   article > 正文

龙蜥(Anolis)OS8.6安装配置KVM虚拟机_龙蜥操作系统虚拟机安装

龙蜥操作系统虚拟机安装

一、检查您的系统是否支持硬件虚拟化

要查看您的系统是否支持硬件虚拟化 (HV),请运行以下命令:

$ cat /proc/cpuinfo | egrep "vmx|svm"

       在输出中,查看标志列表。如果您发现vmx(对于 Intel 处理器)或svm (对于 AMD),则系统支持硬件虚拟化。

       注意:如果您在支持 HV 的系统上安装 KVM 时遇到问题,请检查您的 BIOS 以查看是否启用了 HV。要启用 HV,请参阅主机 BIOS 的文档。

宿主机网卡配置:

  1. [root@anolise ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno1 | grep "#" -v
  2. DEVICE=eno1
  3. ONBOOT=yes
  4. BRIDGE=br0

宿主机桥接网桥配置:

  1. [root@anolise ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0 | grep "#" -v
  2. TYPE=Bridge
  3. BOOTPROTO=static
  4. NAME=br0
  5. UUID=c7d2fb1c-fce5-4f9c-a9e1-cca185807ee2
  6. DEVICE=br0
  7. ONBOOT=yes
  8. IPADDR=10.0.0.29
  9. PREFIX=24
  10. GATEWAY=10.0.0.1
  11. DNS1=114.114.114.114
  1. systemctl restart libvirtd
  2. systemctl restart NetworkManager

二、安装KVM

$ yum install @virt

启动并启用libvirtd服务

systemctl enable --now libvirtd

三、安装KVM所需工具包

  1. yum groupinstall "Virtualization Host"
  2. yum install virt-manager libvirt virt-manager libvirt-client virt-install virt-viewer -y

virt-manager 启动虚拟机管理,创建虚拟机。

四、虚拟机详情

  1. <domain type="kvm">
  2. <name>linux2020</name>
  3. <uuid>8e93d8fe-d261-4cc4-9e81-a84fa2bb4a4c</uuid>
  4. <metadata>
  5. <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
  6. <libosinfo:os id="http://libosinfo.org/linux/2020"/>
  7. </libosinfo:libosinfo>
  8. </metadata>
  9. <memory unit="KiB">4194304</memory>
  10. <currentMemory unit="KiB">4194304</currentMemory>
  11. <vcpu placement="static">2</vcpu>
  12. <os>
  13. <type arch="x86_64" machine="pc-q35-rhel8.6.0">hvm</type>
  14. <boot dev="hd"/>
  15. </os>
  16. <features>
  17. <acpi/>
  18. <apic/>
  19. </features>
  20. <cpu mode="host-passthrough" check="none" migratable="on"/>
  21. <clock offset="utc">
  22. <timer name="rtc" tickpolicy="catchup"/>
  23. <timer name="pit" tickpolicy="delay"/>
  24. <timer name="hpet" present="no"/>
  25. </clock>
  26. <on_poweroff>destroy</on_poweroff>
  27. <on_reboot>restart</on_reboot>
  28. <on_crash>destroy</on_crash>
  29. <pm>
  30. <suspend-to-mem enabled="no"/>
  31. <suspend-to-disk enabled="no"/>
  32. </pm>
  33. <devices>
  34. <emulator>/usr/libexec/qemu-kvm</emulator>
  35. <disk type="file" device="disk">
  36. <driver name="qemu" type="qcow2" discard="unmap"/>
  37. <source file="/mnt/os/aliyun_3_x64_20G_nocloud_alibase_20220907.qcow2"/>
  38. <target dev="vda" bus="virtio"/>
  39. <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
  40. </disk>
  41. <disk type="file" device="disk">
  42. <driver name="qemu" type="raw"/>
  43. <source file="/mnt/os/seed.img"/>
  44. <target dev="vdb" bus="virtio"/>
  45. <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
  46. </disk>
  47. <controller type="usb" index="0" model="qemu-xhci" ports="15">
  48. <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
  49. </controller>
  50. <controller type="pci" index="0" model="pcie-root"/>
  51. <controller type="pci" index="1" model="pcie-root-port">
  52. <model name="pcie-root-port"/>
  53. <target chassis="1" port="0x10"/>
  54. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
  55. </controller>
  56. <controller type="pci" index="2" model="pcie-root-port">
  57. <model name="pcie-root-port"/>
  58. <target chassis="2" port="0x11"/>
  59. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
  60. </controller>
  61. <controller type="pci" index="3" model="pcie-root-port">
  62. <model name="pcie-root-port"/>
  63. <target chassis="3" port="0x12"/>
  64. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
  65. </controller>
  66. <controller type="pci" index="4" model="pcie-root-port">
  67. <model name="pcie-root-port"/>
  68. <target chassis="4" port="0x13"/>
  69. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
  70. </controller>
  71. <controller type="pci" index="5" model="pcie-root-port">
  72. <model name="pcie-root-port"/>
  73. <target chassis="5" port="0x14"/>
  74. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
  75. </controller>
  76. <controller type="pci" index="6" model="pcie-root-port">
  77. <model name="pcie-root-port"/>
  78. <target chassis="6" port="0x15"/>
  79. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x5"/>
  80. </controller>
  81. <controller type="pci" index="7" model="pcie-root-port">
  82. <model name="pcie-root-port"/>
  83. <target chassis="7" port="0x16"/>
  84. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x6"/>
  85. </controller>
  86. <controller type="pci" index="8" model="pcie-root-port">
  87. <model name="pcie-root-port"/>
  88. <target chassis="8" port="0x17"/>
  89. <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x7"/>
  90. </controller>
  91. <controller type="pci" index="9" model="pcie-root-port">
  92. <model name="pcie-root-port"/>
  93. <target chassis="9" port="0x18"/>
  94. <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0" multifunction="on"/>
  95. </controller>
  96. <controller type="pci" index="10" model="pcie-root-port">
  97. <model name="pcie-root-port"/>
  98. <target chassis="10" port="0x19"/>
  99. <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x1"/>
  100. </controller>
  101. <controller type="pci" index="11" model="pcie-root-port">
  102. <model name="pcie-root-port"/>
  103. <target chassis="11" port="0x1a"/>
  104. <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x2"/>
  105. </controller>
  106. <controller type="pci" index="12" model="pcie-root-port">
  107. <model name="pcie-root-port"/>
  108. <target chassis="12" port="0x1b"/>
  109. <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x3"/>
  110. </controller>
  111. <controller type="pci" index="13" model="pcie-root-port">
  112. <model name="pcie-root-port"/>
  113. <target chassis="13" port="0x1c"/>
  114. <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x4"/>
  115. </controller>
  116. <controller type="pci" index="14" model="pcie-root-port">
  117. <model name="pcie-root-port"/>
  118. <target chassis="14" port="0x1d"/>
  119. <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x5"/>
  120. </controller>
  121. <controller type="sata" index="0">
  122. <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
  123. </controller>
  124. <controller type="virtio-serial" index="0">
  125. <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
  126. </controller>
  127. <interface type="bridge">
  128. <mac address="52:54:00:1e:9f:11"/>
  129. <source bridge="br0"/>
  130. <model type="virtio"/>
  131. <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
  132. </interface>
  133. <serial type="pty">
  134. <target type="isa-serial" port="0">
  135. <model name="isa-serial"/>
  136. </target>
  137. </serial>
  138. <console type="pty">
  139. <target type="serial" port="0"/>
  140. </console>
  141. <channel type="unix">
  142. <target type="virtio" name="org.qemu.guest_agent.0"/>
  143. <address type="virtio-serial" controller="0" bus="0" port="1"/>
  144. </channel>
  145. <input type="tablet" bus="usb">
  146. <address type="usb" bus="0" port="1"/>
  147. </input>
  148. <input type="mouse" bus="ps2"/>
  149. <input type="keyboard" bus="ps2"/>
  150. <graphics type="vnc" port="-1" autoport="yes">
  151. <listen type="address"/>
  152. </graphics>
  153. <audio id="1" type="none"/>
  154. <video>
  155. <model type="vga" vram="16384" heads="1" primary="yes"/>
  156. <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
  157. </video>
  158. <memballoon model="virtio">
  159. <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
  160. </memballoon>
  161. <rng model="virtio">
  162. <backend model="random">/dev/urandom</backend>
  163. <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
  164. </rng>
  165. </devices>
  166. </domain>

五、虚拟机网络配置

vim /etc/sysconfig/network-scripts/ifcfg-eth0  文件名视实际情况而定

防火墙配置

安装配置SSH,可以远程连接进行管理操作。 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/217404
推荐阅读
相关标签
  

闽ICP备14008679号