ubuntu 虚拟机群配置管理工具
在ubuntu下,如果想要统一的管理几台甚至几十台虚拟机可以用基于shell的virsh命令,以及基于图形界面的virt-manager, 他们都是利用libvirt提供的管理虚拟机的API进行了封装,具体的相关使用文档都可以从 http://libvirt.org找到。
你可以方便在ubuntu上用apt-get来安装这两个工具,而不用担心依赖。
#apt-get install libvirt0 libvirt-bin libvirt-dev virt-manager
http://www.2cto.com/os/201203/123128.html 该链接基本讲明白了如何用virsh工具方便简单的配置虚拟机启动参数,启动,关闭,挂起,唤醒虚拟机,并如何实现动态迁移。
每个虚拟机的启动都有自己的配置文件,用xml定义,下面是我的机器上的关于kvm,及uml虚拟机的配置脚本:
KVM xml (test1.xml):
<domain type="kvm">
#change the vm id #all following configuration can be find with http://libvirt.org/formatdomain.html
<name>test1</name>
#change the vm name
<uuid>769aa9f5-dd35-4359-9d1a-b150de0df9bc</uuid>
#the unique uuid number,you can use uuidgen to produce one
<memory>524288</memory>
#kB 512*1024kB
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<type arch="x86_64">hvm</type>
<boot dev="network" />
</os>
<acpi />
<apic />
<pae />
</features>
<clock offset="utc" />
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<emulator>/usr/bin/kvm</emulator>
<driver name="qemu" type="qcow2" cache="none" />
<source file="/home/ljj/vmstuffs/ubuntu160.img" />
#the img file location
<target dev="vda" bus="virtio" />
</disk>
<source bridge="virbr0" />
<target dev="vnet0" />
<model type="virtio" />
</interface>
<source path="/dev/pts/4" />
<target port="0" />
</serial>
<source path="/dev/pts/4" />
<target port="0" />
</console>
<input type="mouse" bus="ps2" />
<graphics type="vnc" port="5900" autoport="yes" keymap="en-us" />
#configure the vnc monitor port
</devices>
</domain>
UML xml (uml1.xml) :
<name>uml1</name>
<uuid>ac4430e3-47bc-4d83-b2a8-04e268b9e254</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<type>uml</type>
<kernel>/root/libvirt+openvz+UML/uml/linux-2.6.24-rc7</kernel> //uml kernel location
</os>
</domain>
posted on 2012-04-19 16:53 lin_victor 阅读(427) 评论(0) 编辑 收藏 举报