Centos7搭建KVM虚拟化环境
1. 查看系统版本
[[email protected] ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
2. 首先验证CPU是否支持虚拟化
[[email protected] ~]# cat /proc/cpuinfo | egrep 'vmx|svm'
3. 查看是否加载KVM
[[email protected] ~]# lsmod | grep kvm
kvm_intel 170086 0
kvm 566340 1 kvm_intel
irqbypass 13503 1 kvm
这表明已经加载,如果没有加载则执行以下命令加载KVM
[[email protected] ~]# modprobe kvm
4. 关闭selinux
[[email protected] ~]# setenforce 0
[[email protected] ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
5. 安装KVM相关软件包
[[email protected] ~]# yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python virt- manager libvirt-client virt-install virt-viewer -y
6. 启动libvirt并设置开机自启动
[[email protected] ~]# systemctl start libvirtd
[[email protected] ~]# systemctl enable libvirtd
7. 实施SR-IOV功能,添加intel_iommu=on
[[email protected] ~]# vim /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet intel_iommu=on"
GRUB_DISABLE_RECOVERY="true"
[[email protected] ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
8. 安装虚拟机
新建两个目录:
[[email protected] ~]# mkdir /home/iso
[[email protected] ~]# mkdir /home/images
1) 进入图形化
[[email protected] ~]# virt-manager