Virtual machine management and virtual machine snapshots _ Yun-dimensional learning

Source: Internet
Author: User
### #虚拟机管理 #

Virt-manager # #开启图形管理工具

Virt-viewer Vmname # #显示虚拟机, Vmname represents the virtual machine name
Virsh List # #列出正在运行的vm

Virsh List--all # #列出所有vm

Virsh Start Vmname # #运行指定vm
Virsh Shutdown Vmname # #正常关闭指定vm

Virsh Destroy Vmname # #强行结束指定vm

Virsh Create Vmname.xml # #临时恢复指定vm, Vmname represents front-end management files


Virsh Define Vmname.xml # #永久恢复vm


Virsh undefine vmname # #删除vm的前端管理, storage is not deleted




# # # # #虚拟机快照 ########

The command for the snapshot is: qemu-img create-f qcow2-b vm2.qcow2 node1.qcow2

Write simple scripts to implement snapshots

This script not only has the snapshot function, but is directly made to reset the virtual machine, which is equivalent to deleting the snapshot before and building a snapshot again


!/bin/bash
Virsh Destroy $ &>/dev/null # #关闭旧的虚拟机

Virsh undefine $ &>/dev/null # #删除旧的快照
Qemu-img create-f qcow2-b/var/lib/libvirt/images/$1.qcow2/var/lib/libvirt/images/$2.qcow2 &>/dev/null
Virt-install \ # #创建新的快照
--name $ \ # #设置名字
--ram 1000 \ # #设置内存大小
--DISK/VAR/LIB/LIBVIRT/IMAGES/$2.QCOW2 \ # #保存文件路径
--import &>/dev/null & # #不显示所有信息

Write this file name kz.sh and give execution permission, execute the effect as shown





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.