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