KVM 是基于虚拟化扩展(Intel VT 或者 AMD-V)的 X86 硬件的开源的 Linux 原生的全虚拟化解决方案。KVM 中,虚拟机被实现为常规的 Linux 进程,由标准 Linux 调度程序进行调度;虚机的每个虚拟 CPU 被实现为一个常规的 Linux 进程。这使得 KVM 能够使用 Linux 内核的已有功能。
环境:Red Hat Enterprise Linux Server release 7.3
1. 首先要配置好yum源,检查当前CPU是否支持KVM虚拟化。
Red Hat或者CentOS[root@localhost Desktop]# cat /proc/cpuinfo | egrep '(vmx|svm)' #如果输出结果中包含vmx,则表示采用Intel虚拟化技术;如果包含svm,则表示采用AMD虚拟化技术;如果没有任何输出,表示当前的CPU不支持KVM虚拟化技术。还可以用grep -E 'svm|vmx' /proc/cpuinfo和egrep --color -i "svm|vmx" /proc/cpuinfo来检查。 Ubuntu系统中查看 apt-get install cpu-checker kvm-ok 以下结果说明支持VT INFO: /dev/kvm exists KVM acceleration can be used 以下结果说明不支持VT INFO: Your CPU does not support KVM extensions KVM acceleration can NOT be used
2. 安装虚拟化软件包
[root@localhost Desktop]# yum install -y qemu-kvm qemu-img #Ubuntu用apt-get install -y virt-manager来安装 [root@localhost Desktop]# lsmod | grep kvm #验证KVM模块是否成功加载 kvm_intel 170181 0 kvm 554609 1 kvm_intel irqbypass 13503 1 kvm #如果输出以上结果,则表示KVM模块已经成功加载。 [root@localhost Desktop]# virsh -c qemu:///system list #验证libvirtd服务是否正常启动 Id Name State #如果已经成功启动,则会输出以上结果;如果出现错误,则表示libvirtd服务没有成功启动。
3. 安装虚拟机
[root@localhost Desktop]# virt-manager
![c51bd749-531a-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/c51bd749-531a-eb11-8da9-e4434bdf6706.png)
![c81bd749-531a-eb11-8da9-e4434bdf6706.png](http://p02.5ceimg.com/content/c81bd749-531a-eb11-8da9-e4434bdf6706.png)
![ca1bd749-531a-eb11-8da9-e4434bdf6706.png](http://p04.5ceimg.com/content/ca1bd749-531a-eb11-8da9-e4434bdf6706.png)
![cd1bd749-531a-eb11-8da9-e4434bdf6706.png](http://p02.5ceimg.com/content/cd1bd749-531a-eb11-8da9-e4434bdf6706.png)
#如果默认的storage不能用,那么就选择创建自定义的storage![d01bd749-531a-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/d01bd749-531a-eb11-8da9-e4434bdf6706.png)
配置好相关参数,准备装系统:
正在安装:
安装完成,准备重启:
安装成功!
在宿主上查看虚拟机
[root@localhost ~]# virsh list --all Id Name State ---------------------------------------------------- - rhel7.3 shut off [root@localhost ~]# virsh start rhel7.3 Domain rhel7.3 started [root@localhost ~]# virsh list --all Id Name State ---------------------------------------------------- 6 rhel7.3 running [root@localhost ~]# virsh destroy rhel7.3 Domain rhel7.3 destroyed [root@localhost ~]# virsh list --all Id Name State ---------------------------------------------------- - rhel7.3 shut off
让您学习到的每一节课都有所收获
《Linux就该这么学》是一本由资深运维专家刘遄老师及国内多名红帽架构师(RHCA)基于最新RHEL7系统共同编写的高质量Linux技术自学教程,极其适合用于Linux技术入门教程或讲课辅助教材。荣获双11、双12购物狂欢节IT品类书籍销量冠军,2017年、2018年国内读者增速最快的技术书籍,您可以在京东、当当、亚马逊及天猫搜索书名后购买,亦可加刘遄老师微信交流学习(手指按住下图3秒钟即可自动扫描)~
刘遄老师QQ:5604215
☀ Linux技术交流群:560843(新群,火热加群中……)
☀ 官方站点:www.linuxprobe.com
☀ 书籍在线学习(电脑在线阅读效果更佳):
http://www.linuxprobe.com/chapter-00.html
《Linux就该这么学》是一本基于最新Linux系统编写,面向零基础读者的技术书籍。从Linux基础知识讲起,然后渐进式地提高内容难度,详细讲解Linux系统中各种服务的工作原理和配置方式,以匹配真实生产环境对运维人员的要求,突显内容的实用性。想要学习Linux系统的读者可以点击按钮了解这本书,同时这本书也适合专业的运维人员阅读,作为一本非常有参考价值的工具书!