• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

Kvm虚拟机snapshot快照管理【显哥出品,必为精品】

Kvm lixian 4年前 (2020-07-30) 21952次浏览 14个评论 扫描二维码

1.创建快照

#开机状态下创建快照
[root@kvm /opt]# virsh  snapshot-create  web01

#查看主机快照列表
[root@kvm /opt]# virsh snapshot-list web01
 Name                 Creation Time             State
------------------------------------------------------------
 1596093787           2020-07-30 15:23:07 +0800 running
​
#名称以秒级创建
[root@kvm01 /opt]# date +%s
1596114378

#快照存放的位置
[root@kvm /opt]# tree  /var/lib/libvirt/qemu/snapshot/
/var/lib/libvirt/qemu/snapshot/
└── web01
    └── 1596093787.xml

1 directory, 1 file

#查看快照信息
[root@kvm /opt]# virsh snapshot-info  web01  --snapshotname  1596093787
Name:           1596093787
Domain:         web01
Current:        yes
State:          running
Location:       internal
Parent:         -
Children:       0
Descendants:    0
Metadata:       yes
​

#关机状态下创建快照(占用资源比开机更少)
[root@kvm /opt]# virsh  snapshot-create  web01
Domain snapshot 1596114702 created

[root@kvm /opt]# virsh  snapshot-list web01 
 Name                 Creation Time             State
------------------------------------------------------------
 1596093787           2020-07-30 15:23:07 +0800 running
 1596114702           2020-07-30 21:11:42 +0800 shutoff
​
[root@kvm /opt]# virsh snapshot-info  web01  --snapshotname  1596114702
Name:           1596114702
Domain:         web01
Current:        yes
State:          shutoff
Location:       internal
Parent:         1596093787
Children:       0
Descendants:    0
Metadata:       yes

2.恶意破坏虚拟机(运维有风险,操作需谨慎)

[root@kvm /opt]# virsh start web01 
Domain web01 started
[root@kvm /opt]# virsh console web01 
Connected to domain web01
Escape character is ^]

CentOS Linux 7 (Core)
Kernel 3.10.0-957.el7.x86_64 on an x86_64

kvm login: root
Password: 
Last login: Thu Jul 30 04:57:19 from 10.0.0.1
[root@kvm ~]# 
[root@kvm ~]# ls /
bin   data  etc   lib	 media	opt   root  sbin  sys  usr
boot  dev   home  lib64  mnt	proc  run   srv   tmp  var
[root@kvm ~]# rm -rf /*
[root@kvm ~]# ls
-bash: /bin/ls: No such file or directory

3.恢复快照

#查看虚拟机快照列表
[root@kvm /opt]# virsh  snapshot-list web01 
 Name                 Creation Time             State
------------------------------------------------------------
 1596093787           2020-07-30 15:23:07 +0800 running
 1596114702           2020-07-30 21:11:42 +0800 shutoff
​
#恢复快照
[root@kvm /opt]# virsh snapshot-revert web01 1596114702

4.测试

[root@kvm /opt]# virsh start web01 
Domain web01 started

[root@kvm /opt]# virsh console web01
Connected to domain web01
Escape character is ^]

CentOS Linux 7 (Core)
Kernel 3.10.0-957.el7.x86_64 on an x86_64

kvm login: root
Password: 
Last login: Thu Jul 30 04:57:19 from 10.0.0.1
[root@kvm ~]# ls
anaconda-ks.cfg
[root@kvm ~]# ls /
bin   data  etc   lib	 media	opt   root  sbin  sys  usr
boot  dev   home  lib64  mnt	proc  run   srv   tmp  var

5.删除快照

[root@kvm /opt]# virsh  snapshot-list web01 
 Name                 Creation Time             State
------------------------------------------------------------
 1596093787           2020-07-30 15:23:07 +0800 running
 1596114702           2020-07-30 21:11:42 +0800 shutoff

[root@kvm /opt]# virsh  snapshot-delete web01 1596093787
Domain snapshot 1596093787 deleted

[root@kvm /opt]# virsh snapshot-list web01 
 Name                 Creation Time             State
------------------------------------------------------------
 1596114702           2020-07-30 21:11:42 +0800 shutoff

[root@kvm /opt]# ll /var/lib/libvirt/qemu/snapshot/web01/
total 8
-rw------- 1 root root 4855 Jul 30 21:24 1596114702.xml

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:Kvm虚拟机snapshot快照管理【显哥出品,必为精品】
喜欢 (0)

您必须 登录 才能发表评论!

(14)个小伙伴在吐槽
  1. eve otele gelen tek escort burada vip escort tıkla ulaş ona
  2. kaliteli yerli escort bulmak için tıklaman yeterli olacaktır sadece
  3. en iyisinde güzel rus escort bayan
  4. merkezde ucuz escort bulmak için sadece tıklayın
  5. arabada ucuz veren escort burada tıkla ve ulaş ona
  6. arabada görüşen escort için tıkla
  7. ucuz vip ulaşabilceğin escort bayan
  8. otele gelen ucuz escort bayan ile tıklayın
  9. en iyi escort seçmek için hızlıca ulaşın
  10. birbirinden benzersiz bayanlar için tıkla
    zonguldak escort2023-05-18 04:51
  11. sizde zonguldak escort sayfamızı ziyaret ederek zonguldak escort cagirabilirsiniz.
  12. merhaba sitemizi ziyaret edebilir ve kuşadası escort hizmetinden faydalanabilirsiniz.
  13. sms onay hizmetine sitemizden göz atabilirsiniz.
    sms onay2023-05-11 01:24
  14. I have read your article carefully and I agree with you very much. This has provided a great help for my thesis writing, and I will seriously improve it. However, I don't know much about a certain place. Can you help me?
    gateio2023-03-10 21:10