{"id":161039,"date":"2019-10-31T11:00:29","date_gmt":"2019-10-31T03:00:29","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=161039"},"modified":"2019-10-17T10:59:19","modified_gmt":"2019-10-17T02:59:19","slug":"kvm-cloning-snapshots","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/kvm-cloning-snapshots.html","title":{"rendered":"\u4f55\u4e3aKVM\u514b\u9686\u548c\u5feb\u7167"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nKVM\u7684\u514b\u9686\u3001\u5feb\u7167\u90fd\u662f\u8001\u751f\u5e38\u8c08\u7684\u95ee\u9898\uff0c\u8d44\u6599\u4e5f\u975e\u5e38\u591a\uff0c\u8fd9\u91cc\u53ea\u662f\u9488\u5bf9\u4e2a\u4eba\u5b9e\u9a8c\u7684\u8bb0\u5f55\uff0c\u65b9\u4fbf\u4ee5\u540e\u67e5\u9605\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u865a\u62df\u673a\u514b\u9686<\/strong><\/div>\n

\u865a\u62df\u673a\u7684\u514b\u9686\u64cd\u4f5c\u662f\u518d\u9891\u7e41\u4e0d\u8fc7\u4e86\uff0c\u5b89\u88c5\u597d\u7b2c\u4e00\u53f0\u865a\u62df\u673a\u540e\u5c31\u53ef\u4ee5\u8fdb\u884c\u57fa\u7840\u8bbe\u7f6e\uff0c\u5df2\u6b64\u865a\u62df\u673a\u4e3a\u6a21\u677f\uff0c\u4ee5\u540e\u76f4\u63a5\u514b\u9686\uff0c\u800c\u4e0d\u9700\u8981\u91cd\u590d\u8fdb\u884c\u7cfb\u7edf\u5b89\u88c5\u5de5\u4f5c\u3002<\/p>\n

\u514b\u9686\u865a\u62df\u673a\u9996\u5148\u9700\u8981\u5173\u95ed\u6216\u8005\u6302\u8d77\u865a\u62df\u673a<\/p>\n

\r\n[root@kvm7 vps] virsh shutdown vm01\r\n<\/pre>\n

\u514b\u9686vm01\u865a\u62df\u673a\u4e3avm02<\/p>\n

\r\nvirt-clone -o vm01 -n vm02 -f \/home\/vps\/vm02.img\r\n<\/pre>\n

\u514b\u9686\u4f1a\u975e\u5e38\u5360\u7528\u78c1\u76d8IO \uff0c\u5982\u679c\u662f\u5728\u865a\u62df\u673a\u91cc\u9762\u505a\u5b9e\u9a8c\uff0c\u53c8\u662f\u673a\u68b0\u786c\u76d8\u7684\u8bdd\u672c\u5730\u7535\u8111\u90fd\u4f1a\u5f88\u5361\u3002<\/p>\n

\u5982\u679c\u4e4b\u524d\u521b\u5efa\u7684\u865a\u62df\u673avm01 \u662f\u914d\u7f6e\u4e86\u56fa\u5b9aVNC\u7aef\u53e3\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u4fee\u6539\u4e00\u4e0bvm02\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5c06VNC\u7aef\u53e3\u6539\u4e3a\u5176\u4ed6\uff0c\u907f\u514d\u51b2\u7a81\uff0c\u5f53\u7136\u5982\u679c\u662fautoport=\u2019yes\u2019 \u72b6\u6001\u5219\u65e0\u9700\u8c03\u6574\u3002<\/p>\n

\u865a\u62df\u673a\u5feb\u7167<\/strong><\/div>\n

kvm\u5feb\u7167\u6709\u4e24\u79cd\u65b9\u5f0f\u521b\u5efa\uff0c\u5206\u522b\u662f\uff1a<\/p>\n

\r\nqemu-img snapshot \u547d\u4ee4\u8fdb\u884c\u751f\u6210\u5feb\u7167\r\nvirsh snapshot \u76f8\u5173\u547d\u4ee4\u8fdb\u884c\u751f\u6210\u5feb\u7167\r\n<\/pre>\n

\u67e5\u8be2\u4e86\u4e0bqemu-img \u751f\u6210\u5feb\u7167\u9700\u8981\u5173\u673a\uff0c\u800c\u4e14\u5f88\u591a\u7f51\u53cb\u53cd\u5e94\u6570\u636e\u4e22\u5931\uff0c\u76f8\u5bf9\u6765\u8bb2\u5927\u5bb6\u90fd\u63a8\u8350virsh snapshot \u521b\u5efa\u5feb\u7167\u3002<\/p>\n

\u78c1\u76d8\u8f6c\u6362<\/strong><\/span><\/div>\n

\u5982\u679c\u662fraw\u683c\u5f0f\u7684\u78c1\u76d8\u662f\u4e0d\u652f\u6301\u5feb\u7167\u7684\uff0c\u5982\u679c\u662fraw\u78c1\u76d8\u683c\u5f0f\uff0c\u9700\u8981\u8f6c\u6362\u4e3aqcow2<\/p>\n

\r\n[root@kvm7 vps] qemu-img info vm01.img\r\nimage: vm01.img\r\nfile format: raw\r\nvirtual size: 10G (10737418240 bytes)\r\ndisk size: 2.5G\r\n[root@kvm7 vps] qemu-img convert -f raw -O qcow2  vm01.img  vm01.qcow2  #\u5728\u865a\u62df\u673a\u78c1\u76d8\u6587\u4ef6\u76ee\u5f55\u4e0b\u590d\u5236\u5e76\u8f6c\u6362\u4e3aqcow2\u683c\u5f0f\r\n[root@kvm7 vps] qemu-img info vm01.qcow2 \r\nimage: vm01.qcow2\r\nfile format: qcow2\r\nvirtual size: 10G (10737418240 bytes)\r\ndisk size: 2.3G\r\ncluster_size: 65536\r\n<\/pre>\n
\u521b\u5efa\u5feb\u7167<\/strong><\/span><\/div>\n

\u7ed9\u865a\u62df\u673avm01\u521b\u5efa\u5feb\u7167\uff1a<\/p>\n

\r\n[root@localhost vps] virsh snapshot-create vm01\r\n<\/pre>\n

\u67e5\u770b\u5feb\u7167\uff1a<\/p>\n

\r\n[root@kvm7 vps] virsh snapshot-list vm01\r\n \u540d\u79f0               Creation Time             \u72b6\u6001\r\n------------------------------------------------------------\r\n 1481193249           2016-12-08 18:34:09 +0800 running\r\n<\/pre>\n

\u5f53\u524d\u865a\u62df\u673a\u5bf9\u5e94\u7684\u5feb\u7167\u662f\u5b58\u50a8\u5728\/var\/lib\/libvirt\/qemu\/snapshot\/vm01 \u76ee\u5f55\u4e0b\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2axml\u6587\u4ef6\uff0c\u67e5\u770b\u5feb\u7167\u914d\u7f6e\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\uff1a<\/p>\n

\r\n[root@kvm7 vps] virsh snapshot-current  vm01\r\n<\/pre>\n
\u6062\u590d\u5feb\u7167<\/strong><\/span><\/div>\n

\u5728vm01\u4e2d\u751f\u6210\u51e0\u4e2a\u6587\u4ef6\uff0c\u7136\u540e\u6062\u590d\u5feb\u7167\u7b80\u5355\u6d4b\u8bd5\u4e00\u4e0b\uff1a
\n\"\"<\/p>\n

\u6062\u590d\u5feb\u7167\u662f\u9700\u8981\u5173\u95ed\u865a\u62df\u673a\u7684\uff0c\u6240\u4ee5\u5148\u5173\u95edvm01\u4e3b\u673a\uff1a<\/p>\n

\r\n[root@kvm7 vps] virsh shutdown vm01\r\n<\/pre>\n

\u57dfvm01\u88ab\u5173\u95ed<\/p>\n

\u67e5\u770b\u865a\u62df\u673a\u72b6\u6001\uff1a<\/p>\n

\r\n[root@kvm7 vps] virsh domstate vm01\r\n<\/pre>\n

\u5173\u95ed<\/p>\n

\u6267\u884c\u6062\u590d\u5feb\u7167\uff1a\u67e5\u770b\u5230vm01\u5feb\u7167\u65f6\u95f4\u4e3a1481193249<\/p>\n

\r\n[root@kvm7 vps] virsh snapshot-revert vm01 1481193249\r\n<\/pre>\n

\u5bf9\u6bd4\u4e0b\u4e4b\u524d\u521b\u5efa\u7684\u4e09\u4e2a\u6587\u4ef6\uff0c\u5df2\u7ecf\u6ca1\u6709\u4e86\uff0c\u5feb\u7167\u6062\u590d\u6210\u529f\u3002
\n\"\"<\/p>\n

\u67e5\u770b\u5bf9\u5e94\u7684\u78c1\u76d8\u662f\u5426\u5b58\u5728\u5feb\u7167\u4e5f\u5f88\u7b80\u5355\uff0c\u521b\u5efa\u4e86\u5feb\u7167\u7684\u78c1\u76d8\u901a\u8fc7info \u67e5\u770b\u4f1a\u663e\u793a\u51fa\u5feb\u7167\u4fe1\u606f\uff1a<\/p>\n

\r\n[root@kvm7 vps] qemu-img info vm01.img \r\nimage: vm01.img\r\nfile format: qcow2\r\nvirtual size: 8.0G (8589934592 bytes)\r\ndisk size: 2.7G\r\ncluster_size: 65536\r\nSnapshot list:\r\nID        TAG                 VM SIZE                DATE       VM CLOCK\r\n1         1481193249             212M 2016-12-08 18:34:09   00:00:25.775\r\n<\/pre>\n
\u5220\u9664\u5feb\u7167<\/strong><\/span><\/div>\n
\r\n[root@kvm7 vps] virsh snapshot-delete vm01 1481193249\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u865a\u62df\u673a\u7684\u514b\u9686\u64cd\u4f5c\u662f\u518d\u9891\u7e41\u4e0d\u8fc7\u4e86\uff0c\u5b89\u88c5\u597d\u7b2c\u4e00\u53f0\u865a\u62df\u673a\u540e\u5c31\u53ef\u4ee5\u8fdb\u884c\u57fa\u7840\u8bbe\u7f6e\uff0c\u5df2\u6b64\u865a\u62df\u673a\u4e3a\u6a21\u677f\uff0c\u4ee5\u540e\u76f4\u63a5\u514b\u9686\uff0c\u800c\u4e0d\u9700 […]<\/p>\n","protected":false},"author":668,"featured_media":11349,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-161039","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/161039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=161039"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/161039\/revisions"}],"predecessor-version":[{"id":161599,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/161039\/revisions\/161599"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/11349"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=161039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=161039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=161039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}