日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux虚拟机添加快照,Linux系统下kvm虚拟化(六)创建快照、恢复快照和删除快照...

發布時間:2024/1/8 linux 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux虚拟机添加快照,Linux系统下kvm虚拟化(六)创建快照、恢复快照和删除快照... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

下面開始進行kvm虛擬機快照備份前的操作以及快照管理過程。

1,查看KVM虛擬機磁盤格式以及進行磁盤格式轉換

1.1 查看KVM虛擬機磁盤格式

使用如下方法查看 qemu-img info linux66.img

[root@94ip?vps]#?qemu-img?info?linuxt66.img

image:?linuxt66.img

file?format:?raw

virtual?size:?8.0G?(8589934592?bytes)

disk?size:?8.0G1

由于快照要使用,磁盤格式必須為qcow2,需要進行磁盤格式轉換。

1.2 關閉虛擬機并轉換磁盤

[root@94ip?vps]#?virsh?destroy??linux66

Domain?linux66?destroyed

[root@94ip?vps]#?virsh?list?--all

Id????Name???????????????????????????State

----------------------------------------------------

2?????win2003????????????????????????running

6?????linux65????????????????????????running

-?????linux66????????????????????????shut?off

[root@94ip?vps]#?ll

total?11468860

-rwxr-xr-x?1?qemu?qemu??8589934592?May?11?19:22?linuxt65.img

-rwxr-xr-x?1?root?root??8589934592?May?11?19:21?linuxt66.img

-rwxr-xr-x?1?qemu?qemu?10737418240?May?11?19:23?win2003.img

[root@94ip?vps]#?qemu-img?convert?-f?raw?-O?qcow2?linuxt66.img?linuxt66.qcow2

[root@94ip?vps]#

[root@94ip?vps]#?ll

total?12711880

-rwxr-xr-x?1?qemu?qemu??8589934592?May?11?19:25?linuxt65.img

-rwxr-xr-x?1?root?root??8589934592?May?11?19:21?linuxt66.img

-rw-r--r--?1?root?root??1272971264?May?11?19:24?linuxt66.qcow2

-rwxr-xr-x?1?qemu?qemu?10737418240?May?11?19:25?win2003.img

轉換完成。注意,這里的轉換時針對源文件拷貝一份,并將格式轉成qcow2。

1.3 ?修改配置文件,啟用新格式磁盤。

virsh edit linux 進去搜索img找到以后替換文件格式名:

2,管理快照以及快照恢復

首先我們先查看下該快照命令用到了哪些:

[root@94ip?~]#?virsh??--help?|?grep?snap

iface-begin????????????????????create?a?snapshot?of?current?interfaces?settings,?which?can?be?later?committed?(iface-commit)?or?restored?(iface-rollback)

Snapshot?(help?keyword?'snapshot')

snapshot-create????????????????Create?a?snapshot?from?XML

snapshot-create-as?????????????Create?a?snapshot?from?a?set?of?args

snapshot-current???????????????Get?or?set?the?current?snapshot

snapshot-delete????????????????Delete?a?domain?snapshot

snapshot-dumpxml???????????????Dump?XML?for?a?domain?snapshot

snapshot-edit??????????????????edit?XML?for?a?snapshot

snapshot-info??????????????????snapshot?information

snapshot-list??????????????????List?snapshots?for?a?domain

snapshot-parent????????????????Get?the?name?of?the?parent?of?a?snapshot

snapshot-revert????????????????Revert?a?domain?to?a?snapshot

2.1 創建快照

根據上述命令,我們打算使用snapshot-cteate 來對linux66主機創建快照

[root@94ip?vps]#?virsh??snapshot-create?linux66

Domain?snapshot?1463020507?created

查看快照列表

[root@94ip?vps]#?virsh?snapshot-list?linux66

Name?Creation?Time?State

------------------------------------------------------------

1463020507?2016-05-11?19:35:07?-0700?shutoff

1463020969?2016-05-11?19:42:49?-0700?shutoff

其中快照配置文件放到了/var/lib/libvirt/qemu/snapshot/

查看 最近的快照

virsh snapshot-currentlinux66

2.2 ?恢復快照

恢復快照之前必須先關閉虛擬機,我們可以先關閉以后并查看下快照列表,選中要恢復哪個快照。

[root@94ip?snapshot]#?virsh?list?--all

Id?Name?State

----------------------------------------------------

2?win2003?running

6?linux65?running

-?linux66?shut?off

[root@94ip?snapshot]#?virsh?snapshot-list?linux66

Name?Creation?Time?State

------------------------------------------------------------

1463020507?2016-05-11?19:35:07?-0700?shutoff

1463020969?2016-05-11?19:42:49?-0700?shutoff

比如我們這里恢復 1463020969這個快照。操作如下:

[root@94ip?snapshot]#?virsh??snapshot-revert??linux66??1463020969

[root@94ip?snapshot]#?virsh??snapshot-current??linux66

1463020969

shutoff

1463020507

恢復完成。

2.3快照刪除

[root@94ip?vps]#?virsh??snapshot-list??linux66

Name?????????????????Creation?Time?????????????State

------------------------------------------------------------

1463020507???????????2016-05-11?19:35:07?-0700?shutoff

1463020969???????????2016-05-11?19:42:49?-0700?shutoff

[root@94ip?vps]#?virsh??snapshot-delete??linux66???1463020969

Domain?snapshot?1463020969?deleted

[root@94ip?vps]#?virsh??snapshot-list??linux66

Name?????????????????Creation?Time?????????????State

------------------------------------------------------------

1463020507???????????2016-05-11?19:35:07?-0700?shutoff

總結

以上是生活随笔為你收集整理的Linux虚拟机添加快照,Linux系统下kvm虚拟化(六)创建快照、恢复快照和删除快照...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。