KVM虚拟化平台
简介
KVM是KernelVirtual Machine的简写,目前Linux发行版必须在64位的系统环境才能运行KVM.
同时硬件需要支持VT技术。KVM的前身是QEMU,2008年被Red Hat公司收购并获得一项hypervisor
技术,不过Red Hat的KVM被认为将成为未来Linux hypervisor的主流。准确来说,KVM仅仅是Linux
内核的一个模块。管理和创建完整的KVM虚拟机,需要更多的辅助工具。本章将介绍部署虚拟化环
境.创建虚拟机实例,以及虚拟机的基本管理。
1、安装KVM所需软件
[root@centos01 ~]# yum -y install qemu-kvm-tools virt-install virt-manager libvirt
2、关机修改虚拟机配置
3、改为图形化界面登录
[root@centos01 ~]# init 5
4、移动光盘,创建虚拟机
创建后完成即可
5、KVM的管理使用
1、查看
[root@centos01 ~]# virsh list --all
2、关机
[root@centos01 ~]# virsh shutdown centos7.0
强制关机 [root@centos01 ~]# virsh destory centos7.0
3、加载配置文件
[root@centos01 ~]# virsh create /etc/libvirt/qemu/centos7.0.xml
4、挂起和恢复虚拟机 设置虚拟机随宿主机一起启动
[root@centos01 ~]# virsh suspend centos7.0
[root@centos01 ~]# virsh resume centos7.0
[root@centos01 ~]# virsh autostart centos7.0
5、备份虚拟机和删除虚拟机
[root@centos01 ~]# virsh dumpxml centos7.0 > ./centos7.0.xml
[root@centos01 ~]# virsh undefine centos7.0
[root@centos01 ~]# mv ./centos7.0.xml /etc/libvirt/qemu/
[root@centos01 ~]# virsh define /etc/libvirt/qemu/centos7.0.xml
6、克隆虚拟机和创建快照
[root@centos01 ~]# virt-clone -o centos7.0 -n centos7.01 -f /var/lib/libvirt/images/centos7.01.qcow2
[root@centos01 ~]# virsh snapshot-create centos7.0
[root@centos01 ~]# virsh snapshot-list centos7.0
[root@centos01 ~]# virsh snapshot-revert centos7.0 1604742497
删除快照
[root@centos01 ~]# virsh snapshot-delete centos7.0 1604742497