Welcome 微信登录

首页 / 操作系统 / Linux / KVM脚本批量添加删除虚拟机

[背景]最近事情特别多,前段时间搞搞openstack,发现过与复杂,就想把KVM先好好学学,再过来搞它.因为工作关系,又用twisted开发了一个c/s的监控程序,但因还没有写完,所以暂时没有发出来.如果不是强逼自己,我想我这个工具,也可能需要再等几日才能发布吧.扯远了,先不说这些,就说我这款工具能干嘛吧.简单的说就像openstack的镜像功能一般,不过,人家是提供Web Gui,点两下就OK了,我这需要修改下配置文件vm.ini,不过它那个点两下,不一定OK噢,反正我试过,没那么灵光.我的配置文件很简单,就是告诉我是添加还是删除虚拟机,如果添加则需要告诉模板镜像文件在哪?模板xml文件在哪.当然这些都是要定义好的.也就是提前将镜像文件做好嘛.openstack的glance也是需要的嘛.[过程](1)安装模板系统略(2)将模板img文件和xml文件分别copy到/template/img,/template/xml下,当然,你也可以更改,不过,程序也需要做修改.(3)修改vm.ini文件参考模板xml文件more /template/xml/Template_CentOS55x64_LAMP.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit Template_Centos55x64_LAMP
or other application using the libvirt API.
-->
<domain type="kvm">
<name>Template_Centos55x64_LAMP</name>
<uuid>e7bbc1b0-e9b1-a0f2-bd1e-dd9f3fd48823</uuid>
<memory unit="KiB">524288</memory>
<currentMemory unit="KiB">524288</currentMemory>
<vcpu placement="static">2</vcpu>
<os>
<type arch="x86_64" machine="rhel6.3.0">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="raw"/>
<source file="/var/lib/libvirt/images/Template_Centos55x64_LAMP.img"/>
<target dev="hda" bus="ide"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
<interface type="bridge">
<mac address="52:54:00:88:d0:51"/>
<source bridge="br0"/>
<model type="virtio"/>
</interface>
<serial type="pty">
<target port="0"/>
</serial>
<console type="pty">
<target type="serial" port="0"/>
</console>
<input type="mouse" bus="ps2"/>
<graphics type="vnc" port="-1" autoport="yes"/>
<video>
<model type="cirrus" vram="9216" heads="1"/>
</video>
</devices>
</domain>
  • 1
  • 2
  • 下一页
Ubuntu下最强大的进程监视器htop使用Linux下Panabit安装配置笔记相关资讯      KVM 
  • 怎样在 Ubuntu 和 Debian 中通过命  (02月29日)
  • RHCSA 系列(十五): 虚拟化基础  (10/07/2015 15:25:43)
  • 在Ubuntu上安装KVM并搭建虚拟环境  (10/04/2015 06:28:17)
  • KVM嵌套虚拟化配置  (11/20/2015 20:16:53)
  • Ubuntu下使用KVM+Qemu 搭建虚拟机  (10/04/2015 06:48:51)
  • 如何在Linux发行版上安装和配置KVM  (10/04/2015 06:21:48)
本文评论 查看全部评论 (0)
表情: 姓名: 字数