KVM 虚拟机创建快照

注意要使用KVM的快照功能,虚拟机的硬盘一定要是qcow2格式,否则无法使用快照功能。

列出虚拟机

[root@kvm ~]#virsh list
 Id    Name                           State
----------------------------------------------------
 44    win7-1                         running
 51    win7-3                         running
 53    win7-4                         running
 54    win7-2                         running
 60    win7                           running
 97    xp-1                           running
 98    xp-4                           running
 99    xp-3                           running
 100   xp-2                           running
 103   centos7-1                      running

创建快照

[root@kvm ~]#virsh  snapshot-create-as  centos7-1 centos7_init

这里创建一个centos7-1的快照,快照名为centos7_init

列出快照

[root@kvm ~]# virsh  snapshot-list centos7-1
 Name                 Creation Time             State
------------------------------------------------------------
 centos7_init         2016-03-22 18:57:50 +0800 running

可以查看到centos7-1的快照

查看快照信息

[root@kvm ~]# virsh snapshot-info centos7-1 --snapshotname centos7_init
Name:           centos7_init
Domain:         centos7-1
Current:        yes
State:          running
Location:       internal
Parent:         -
Children:       0
Descendants:    0
Metadata:       yes


安装HTTP服务并启动

#yum install httpd -y
#systemctl start httpd.service 
# lsof -i:80
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   3308   root    4u  IPv6  28945      0t0  TCP *:http (LISTEN)
httpd   3316 apache    4u  IPv6  28945      0t0  TCP *:http (LISTEN)
httpd   3317 apache    4u  IPv6  28945      0t0  TCP *:http (LISTEN)
httpd   3318 apache    4u  IPv6  28945      0t0  TCP *:http (LISTEN)
httpd   3319 apache    4u  IPv6  28945      0t0  TCP *:http (LISTEN)
httpd   3321 apache    4u  IPv6  28945      0t0  TCP *:http (LISTEN)


恢复快照

[root@kvm ~]# virsh snapshot-revert centos7-1 centos7_init

这个时候我们再尝试启动httpd服务,发现并未安装,证明快照恢复成功

systemctl start httpd.service
Failed to start httpd.service: Unit httpd.service failed to load: No such file or directory.



你可能感兴趣的:(kvm,快照)