kvm--Simple article

Source: Internet
Author: User

KVM Installation Readiness:

Linux operating system, Centos6.6 is used here.

The simplest is to install the desktop environment tick virtualization

To install a KVM dependency package on an existing system:

Yum-y groupinstall "Desktop" #安装gnome桌面

Yum-y Install qemu-kvm.x86_64 #安装KVM模块

Yum-y Install qemu-kvm-tools.x86_64 #KVM调试工具

Yum-y install Python-virtinst.noarch #python组件 to record the XML file when the VM was created

Yum-y Install qemu-img.x86_64 #qemu组件, create disks and start virtual machines

Yum-y Install bridge-utils.x86_64 #网络支持工具

Yum-y Install Libvirt #虚拟机管理工具

Yum-y Install Virt-manager #图形界面管理工具

Yum-y Install Libguestfs-tools #安装管理工具


See if the operating system supports virtualization

Intel looks at the following ways:

Cat/proc/cpuinfo |grep VMX

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/94/wKioL1XnqCXAL7pRAAJNN3_5eeA527.jpg "title=" 2015-09-01_140521.png "alt=" Wkiol1xnqcxal7praajnn3_5eea527.jpg "/>

Here's how AMD looks:

Cat/proc/cpuinfo |grep SVM


See if the KVM module is installed

Lsmod |grep KVM


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/94/wKioL1Xnp_7zuWXqAAA-BbbovD8422.jpg "title=" 2015-09-01_141026.png "alt=" Wkiol1xnp_7zuwxqaaa-bbbovd8422.jpg "/>



Simple configuration of KVM:

To configure the virtual network card:

Vim-o/etc/sysconfig/network-scripts/ifcfg-{eth0,br0}

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/98/wKiom1XnsXLD_5shAAGd-8vCqA0663.jpg "title=" 2015-09-03_103245.png "alt=" Wkiom1xnsxld_5shaagd-8vcqa0663.jpg "/>

Restart the service:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/98/wKiom1XnseaCkWaDAAIsoTQ1yNw498.jpg "title=" 2015-09-03_103500.png "alt=" Wkiom1xnseackwadaaisotq1ynw498.jpg "/>

To see if the configuration was successful:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/94/wKioL1XntGjgiC69AAN438fbA74836.jpg "title=" 2015-09-03_103630.png "alt=" Wkiol1xntgjgic69aan438fba74836.jpg "/>



Managing KVM Virtual Machines:

Manage graphical interfaces:

Virt-manager bring up graphical interface management:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/98/wKiom1XnuiCDo-lkAAEgk_WYI8M879.jpg "title=" 2015-09-03_111004.png "alt=" Wkiom1xnuicdo-lkaaegk_wyi8m879.jpg "/>

To create a storage pool:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/94/wKioL1XnvL7S__aQAADnnDTIIyk267.jpg "title=" 2015-09-03_111205.png "alt=" Wkiol1xnvl7s__aqaadnndtiiyk267.jpg "/>

To create a mirrored storage pool:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/95/wKioL1XnvUKDgjElAADqnMq0Pic681.jpg "title=" 2015-09-03_111419.png "alt=" Wkiol1xnvukdgjelaadqnmq0pic681.jpg "/>

Mirrored mount Directory:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/98/wKiom1Xnu1yC8e6KAAD0a6-GSm0726.jpg "title=" 2015-09-03_111507.png "alt=" Wkiom1xnu1yc8e6kaad0a6-gsm0726.jpg "/>

To create a storage volume:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/95/wKioL1Xnvc2xldW6AAFA3GBRBjM718.jpg "title=" 2015-09-03_111624.png "alt=" Wkiol1xnvc2xldw6aafa3gbrbjm718.jpg "/>

The steps to create a virtual machine are as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/98/wKiom1XnvDnTQarCAAEer_41-_o308.jpg "title=" 2015-09-03_111855.png "alt=" Wkiom1xnvdntqarcaaeer_41-_o308.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/98/wKiom1XnvwOiYkzjAAEYcOjmY0w876.jpg "title=" 2015-09-03_113051.png "alt=" Wkiom1xnvwoiykzjaaeycojmy0w876.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1XnwUeTdlugAADCb73GW7k209.jpg "title=" 2015-09-03_113129.png "alt=" Wkiol1xnwuetdlugaadcb73gw7k209.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/98/wKiom1Xnv0WxC0AtAAD6P0HwdbY764.jpg "title=" 2015-09-03_113204.png "alt=" Wkiom1xnv0wxc0ataad6p0hwdby764.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/95/wKioL1XnwZnT5kRDAAFE_hahhSQ085.jpg "title=" 2015-09-03_113254.png "alt=" Wkiol1xnwznt5krdaafe_hahhsq085.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/95/wKioL1XnwfLg2isEAADG530MlnU732.jpg "title=" 2015-09-03_113422.png "alt=" Wkiol1xnwflg2iseaadg530mlnu732.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/98/wKiom1Xnv_CTNUm3AAN8nuhLeoQ242.jpg "title=" 2015-09-03_113454.png "alt=" Wkiom1xnv_ctnum3aan8nuhleoq242.jpg "/>

To manage the command line:

Help

Virsh-h

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/99/wKiom1XnzXaDSIrEAAHUoyRoAvA051.jpg "title=" 2015-09-03_123223.png "alt=" Wkiom1xnzxadsireaahuoyroava051.jpg "/>

To view the KVM configuration file storage directory:

ls/etc/libvirt/qemu/

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1Xn0GOBFUtyAAAzvhsPXNI158.jpg "title=" 2015-09-03_123429.png "alt=" Wkiol1xn0gobfutyaaazvhspxni158.jpg "/>

To view the status of a virtual machine:

Virsh List--all

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1Xn0OuBpXn2AABQI7x9tOQ746.jpg "title=" 2015-09-03_123729.png "alt=" Wkiol1xn0oubpxn2aabqi7x9toq746.jpg "/>

Confirm that the switch service is running:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1Xn0bqjZXaiAAA3SJCOzLY377.jpg "title=" 2015-09-03_124108.png "alt=" Wkiol1xn0bqjzxaiaaa3sjcozly377.jpg "/>

Virtual Machine shutdown:

Virsh shutdown CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/95/wKioL1Xn0pHz36J4AAB0i076WAk075.jpg "title=" 2015-09-03_124516.png "alt=" Wkiol1xn0phz36j4aab0i076wak075.jpg "/>

Virtual Machine Boot:

Virsh start CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/99/wKiom1Xn0KHxqkYbAABvhkfXFDQ416.jpg "title=" 2015-09-03_124607.png "alt=" Wkiom1xn0khxqkybaabvhkfxfdq416.jpg "/>

Forced power off of virtual machines:

Virsh Destroy CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/95/wKioL1Xn0wGC7hrbAABw1xabjMI578.jpg "title=" 2015-09-03_124709.png "alt=" Wkiol1xn0wgc7hrbaabw1xabjmi578.jpg "/>

To start a virtual machine from a configuration file:

Virsh Create/etc/libvirt/qemu/centos

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/95/wKioL1Xn09aQHHb7AACNnzxB3vg867.jpg "title=" 2015-09-03_125039.png "alt=" Wkiol1xn09aqhhb7aacnnzxb3vg867.jpg "/>

To suspend a virtual machine:

Virsh suspend CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/99/wKiom1Xn0nezdXzpAABzUFHPwKE191.jpg "title=" 2015-09-03_125357.png "alt=" Wkiom1xn0nezdxzpaabzufhpwke191.jpg "/>

To view the status of a virtual machine:

Virsh List--all

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1Xn1TSjhiyfAABJCM5QSpE663.jpg "title=" 2015-09-03_125631.png "alt=" Wkiol1xn1tsjhiyfaabjcm5qspe663.jpg "/>

To restore a virtual machine:

Virsh Resume CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/99/wKiom1Xn0vPClBWYAABxDygwXu4146.jpg "title=" 2015-09-03_125601.png "alt=" Wkiom1xn0vpclbwyaabxdygwxu4146.jpg "/>

Configure the virtual machine to accompany the host startup:

Virsh autostart CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/95/wKioL1Xn1hOx_A7bAAAyBIB8tEM613.jpg "title=" 2015-09-03_130013.png "alt=" Wkiol1xn1hox_a7baaaybib8tem613.jpg "/>

To export a configuration file for a virtual machine:

Virsh dumpxml CentOS >/etc/libvirt/qemu/centos1.xml

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/95/wKioL1Xn1teCdCwFAABtdCTOfdA904.jpg "title=" 2015-09-03_130330.png "alt=" Wkiol1xn1tecdcwfaabtdctofda904.jpg "/>

Removal of virtual machines:

Virsh shutdown CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/99/wKiom1Xn1XLhqrpNAAAhZaNebTY491.jpg "title=" 2015-09-03_130639.png "alt=" Wkiom1xn1xlhqrpnaaahzanebty491.jpg "/>

Virsh undefine CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1Xn1-HxGFTpAABmfTCMiyc031.jpg "title=" 2015-09-03_130803.png "alt=" Wkiol1xn1-hxgftpaabmftcmiyc031.jpg "/>

To restore a virtual machine from a backup:

Cd/etc/libvirt/qemu

MV Centos1.xml Centos.xml

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1Xn2M3BO9SOAAB1iAZ3rCg697.jpg "title=" 2015-09-03_131153.png "alt=" Wkiol1xn2m3bo9soaab1iaz3rcg697.jpg "/>

To redefine a virtual machine:

Virsh define CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/99/wKiom1Xn1vuDS0ZNAAA01gtYIuw050.jpg "title=" 2015-09-03_131314.png "alt=" Wkiom1xn1vuds0znaaa01gtyiuw050.jpg "/>

To modify the configuration information for a virtual machine:

Vim/etc/libvirt/qemu/centos.xml

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/95/wKioL1Xn2beBeKQNAAJRPzWKT6E545.jpg "title=" 2015-09-03_131545.png "alt=" Wkiol1xn2bebekqnaajrpzwkt6e545.jpg "/>

Virsh Edit CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/99/wKiom1Xn18egrPKAAAH0T4QEUno678.jpg "title=" 2015-09-03_131636.png "alt=" Wkiom1xn18egrpkaaah0t4qeuno678.jpg "/>

KVM File Management:

To view the current disk format:

Qemu-img info/var/lib/libvirt/images/centos.img

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/99/wKiom1Xn2eqBdeHqAAB-2X0YR9I767.jpg "title=" 2015-09-03_132313.png "alt=" Wkiom1xn2eqbdehqaab-2x0yr9i767.jpg "/>

Turn off the virtual machine and convert the disk format.

Virsh shutdown CentOS

Qemu-img convert-f Raw-o Qcow2/var/lib/libvirt/imagers/centos.img/var/lib/libvirt/imagers/centos.qcow2

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/99/wKiom1Xn3NLyyNpLAAB2rPiY12Q452.jpg "title=" 2015-09-03_133809.png "alt=" Wkiom1xn3nlyynplaab2rpiy12q452.jpg "/>

To edit a configuration file:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/95/wKioL1Xn3s7RIfcEAAHUgPdBcfw478.jpg "title=" 2015-09-03_133613.png "alt=" Wkiol1xn3s7rifceaahugpdbcfw478.jpg "/>

Using the cat command:

Virt-cat-a/var/lib/libvirt/imagers/centos.qcow2/etc/sysconfig/network

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/99/wKiom1Xn3tmwAVqeAABrrz4wczE306.jpg "title=" 2015-09-03_134648.png "alt=" Wkiom1xn3tmwavqeaabrrz4wcze306.jpg "/>

Using the VIM command

Virt-edit-a/var/lib/libvirt/imagers/centos.qcow2/etc/resolv.conf

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/96/wKioL1Xn4gDzShpiAACfRAOt-Sk356.jpg "title=" 2015-09-03_135109.png "alt=" Wkiol1xn4gdzshpiaacfraot-sk356.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/96/wKioL1Xn4lHALGk-AACaTm_dw_0799.jpg "title=" 2015-09-03_135228.png "alt=" Wkiol1xn4lhalgk-aacatm_dw_0799.jpg "/>

To view disk information for a virtual machine:

Virt-df-h CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/96/wKioL1Xn4rCwKB3iAACXQa1FBro160.jpg "title=" 2015-09-03_135357.png "alt=" Wkiol1xn4rcwkb3iaacxqa1fbro160.jpg "/>

Cloning of virtual machines:

To view the status of a virtual machine:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/99/wKiom1Xn4QPwsjuMAABVEkv03Sc725.jpg "title=" 2015-09-03_135552.png "alt=" Wkiom1xn4qpwsjumaabvekv03sc725.jpg "/>

Cloning:

Virt-clone-o centos-n centos2-f/var/lib/libvirt/imagers/centos.qcow2

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/96/wKioL1Xn5Q6x_EyAAABnvLye8xI001.jpg "title=" 2015-09-03_140406.png "alt=" Wkiol1xn5q6x_eyaaabnvlye8xi001.jpg "/>

To view the status of a virtual machine:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/99/wKiom1Xn4yPigRQZAABi0kqFACk187.jpg "title=" 2015-09-03_140506.png "alt=" Wkiom1xn4ypigrqzaabi0kqfack187.jpg "/>

To start the test:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/96/wKioL1Xn5XqR1_UOAAAu83o68IM409.jpg "title=" 2015-09-03_140559.png "alt=" Wkiol1xn5xqr1_uoaaau83o68im409.jpg "/>


Snapshots of virtual machines:

To create a snapshot:

Virsh snapshot-create CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/96/wKioL1Xn5pfBFvBSAABNGgkim1g317.jpg "title=" 2015-09-03_141039.png "alt=" Wkiol1xn5pfbfvbsaabnggkim1g317.jpg "/>

To view virtual machine snapshot version information:

Virsh snapshot-current CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/99/wKiom1Xn5RjTUqqKAADrjjsuAPY862.jpg "title=" 2015-09-03_141327.png "alt=" Wkiom1xn5rjtuqqkaadrjjsuapy862.jpg "/>

To view snapshot information:

Virsh snapshot-list CentOS

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/96/wKioL1Xn58qyDxWPAABy2HSbsFA892.jpg "title=" 2015-09-03_141549.png "alt=" Wkiol1xn58qydxwpaaby2hsbsfa892.jpg "/>

Revert to Snapshot:

Virsh Snapshot-revert CentOS 1441287546

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/96/wKioL1Xn6HKTrs_8AAA5LjqTexs918.jpg "title=" 2015-09-03_141838.png "alt=" Wkiol1xn6hktrs_8aaa5ljqtexs918.jpg "/>

To delete a snapshot:

Virsh Snapshot-delete CentOS 1441287546

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/96/wKioL1Xn6PewRMnUAACWBifXmNo438.jpg "title=" 2015-09-03_142051.png "alt=" Wkiol1xn6pewrmnuaacwbifxmno438.jpg "/>


This is the general practice.

If there is an error, please let me know, thank you.

This article is from the "XXX" blog, please be sure to keep this source http://moumou.blog.51cto.com/9995443/1691101

kvm--Simple article

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.