11、virsh

1、介绍

xxx

2、virsh快速创建实例

kvm.xml配置文件内容:

<domain type='kvm'>
        <name>install</name>
        <memory>10048576</memory>
        <currentMemory>10048576</currentMemory>
        <vcpu>12</vcpu>
        <os>
          <type arch='x86_64' machine='pc'>hvm</type>
          <boot dev='hd'/>
       </os>
       <features>
         <acpi/>
         <apic/>
         <pae/>
       </features>
       <clock offset='localtime'/>
       <on_poweroff>destroy</on_poweroff>
       <on_reboot>restart</on_reboot>
       <on_crash>destroy</on_crash>
       <devices>
         <emulator>/usr/libexec/qemu-kvm</emulator>
         <disk type='file' device='disk'>
          <driver name='qemu' type='qcow2'/>
           <source file='/mnt/CentOS-7.3-x86_64.qcow2'/>
           <target dev='hda' bus='virtio'/>
         </disk>
        <interface type='bridge'>
          <virtualport type='openvswitch'/>
          <source bridge='br-ex'/>
        </interface>
        <input type='mouse' bus='ps2'/>
         <graphics type='vnc' port='12306' autoport='no' listen = '0.0.0.0' keymap='en-us'/>
       </devices>
     </domain>

配置步骤:

#准备纯净的镜像文件和配置文件
#mv CentOS-7.3-x86_64.qcow2 sjq/
#mv kvm.xml sjq/
#进入文件夹
#cd sjq/
#编辑修改配置文件
#vim kvm.xml
#定义配置 
#virsh define kvm.xml 
#取消定义
#virsh undefine Cirros
#vim kvm.xml
#定义配置
#virsh define kvm.xml 
#启动虚拟机
#virsh start hyhive-install
#列出当前虚拟机
#virsh list --all


#删除虚拟机
#强制关闭虚拟机
# virsh destroy hyhive-install
Domain hyhive-install destroyed
#删除虚拟机
# virsh undefine hyhive-install
Domain hyhive-install has been undefined
#删除虚拟机镜像(真正删除) #查看删除结果 # virsh list
--all

 

posted @ 2017-07-24 14:16  浮萍之家  阅读(159)  评论(0编辑  收藏  举报