KVM virtual machine Basic management and common commands

Source: Internet
Author: User

Basic management of KVM

1. View the KVM virtual machine configuration file

#Kvm虚拟机默认配置文件位置 [[email protected] qemu]# pwd/etc/libvirt/Qemu[[email protected] qemu]# lltotal A-RW-------1Root root3863Nov6  -: -CentOS6.5. XML-RW-------1Root root3771Nov7 xx: $Centos6u7.xml-RW-------1Root root3628Nov7  Geneva:Genevacentos.xmldrwx------3Root root +Nov7 xx: $Networks

2 Start and close

 #显示正在运行的虚拟机[[email protected]~]# virsh list Id Name state---------------------------------------------------- #显示所有虚拟机[[email protected]~]# Virsh List--All Id the Name state---------------------------------------------------- -CentOS shut off-CentOS6.5shut off-Centos6u7 shut off#启动名字为CentOS6.5 virtual machines [email protected]~]# Virsh start CentOS6.5 #关闭名字为CentOS6.5 virtual machines [email protected]~]# Virsh shutdown CentOS6.5 #强制关闭名字为Centos6.5 virtual machines [email protected]~]# Virsh destroy CentOS6.5 #移除名字为CentOS6.5 virtual machines [email protected]~]# Virsh undefine CentOS6.5 #设置CentOS6.5 Virtual machine boot up [[email protected]~]# Virsh autostart CentOS6.5 #默认情况下virsh工具不能对linux虚拟机进行关机操作 #linux操作系统需要开启与启动acpid服务. This service must be configured on the installation of a KVM Linux virtual machine . # yum-y install acpid#/etc/init.d/acpid start

3 Starting a virtual machine from a configuration file

[Email protected] ~]# Virsh CREATE/ETC/LIBVIRT/QEMU/CENTOS6. 5. xml

4 Other (hang, resume) Virsh commands

#挂起服务器 [Email protected] qemu]# Virsh suspend CentOS6. 5  #恢复服务器[[email protected] qemu]# Virsh resume CentOS6. 5

5 Renaming a virtual machine

1, stop the virtual machine [[email protected] qemu]# Virsh shutdown centos6u51, export the virtual machine's configuration file [[email protected] qemu]# pwd/etc/libvirt/Qemu[[email protected] Qemu-img]# Virsh dumpxml centos6u5 > test-Centos6u5.xml2change configuration file [[email protected] qemu]# sed-I.'s/centos6u5/test-centos6u5/g'test-centos6u5.xml# Note You can not change the image name3Remove the original virtual machine [[email protected] qemu]# Virsh undefine centos6u54load new virtual machine [[email protected] qemu]# Virsh define test-Centos6u5.xml5start virtual machine [[email protected] qemu]# virsh start test-centos6u5

6 Virtual Machine Snapshot creation

1Convert disk image File format to Qcow2[[email protected]~]# Virsh shutdown test-Centos6u5[[email protected] Qemu-img]# qemu-img convert-f Raw Centos6u5.raw-O qcow2 CentOS6u5.raw.qcow2 snapshots must be in the QCOW2 format. I'll start with a new virtual machine to Qcow22create snapshot [[email protected] QEMU-img]# Virsh snapshot-Create Centos6u53view snapshot [[email protected] QEMU-img]# Virsh snapshot-list Centos6u5 Name Creation time State------------------------------------------------------------1479043349            .- One- -  ,: A: in-0500shutoff4restore snapshot [[email protected] QEMU-img]# Virsh Snapshot-revert Centos6u514790433495delete snapshot [[email protected] QEMU-img]# Virsh Snapshot-delete Centos6u51479043349

KVM virtual machine Basic management and common commands

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.