有许多可用于管理KVM的解决方案,其中一些是免费的,而另一些则是商业产品您可以在http://www.linux-kvm.org/page/Management_Tools找到此类解决方案的列表选项可以大致分为两类:一类是基于命令行或shell,另一类是基于图形或图形用户界面 oVirt(http://www.ovirt.org/Home)是一种非常流行的开源软件,用于管理KVM实例 RedHat有一个围绕oVirt构建的商业产品,名为RHEVM,或RedHat Enterprise Virtualization Manager(http://www.redhat.com/products/cloud-computing/virtualization/)第三种选择是使用libvirt API编写自己的管理您可以在http://libvirt.org/找到有关libvirt的更多信息,今天小编就来说说关于linux查看kvm虚拟机?下面更多详细答案一起来看看吧!

linux查看kvm虚拟机(Linux基础架构学习-)

linux查看kvm虚拟机

KVM管理解决方案

有许多可用于管理KVM的解决方案,其中一些是免费的,而另一些则是商业产品。您可以在http://www.linux-kvm.org/page/Management_Tools找到此类解决方案的列表。选项可以大致分为两类:一类是基于命令行或shell,另一类是基于图形或图形用户界面。 oVirt(http://www.ovirt.org/Home)是一种非常流行的开源软件,用于管理KVM实例。 RedHat有一个围绕oVirt构建的商业产品,名为RHEVM,或RedHat Enterprise Virtualization Manager(http://www.redhat.com/products/cloud-computing/virtualization/)。第三种选择是使用libvirt API编写自己的管理。您可以在http://libvirt.org/找到有关libvirt的更多信息。

libvirt

Libvirt是一个支持与各种虚拟化平台交互的工具包,KVM就是其中之一。 libvirt的API非常广泛,如果您围绕KVM编写自己的管理,它将非常有用。 libvirt的C库参考可以在http://libvirt.org/html/libvirt-libvirt.html找到。 libvirt有许多语言绑定,例如C#,Java,OCaml,Perl,PHP,Python和Ruby。在下面的示例中,我使用Python绑定来演示如何为KVM编写基本管理应用程序(清单3-8)。您可以在http://libvirt.org/bindings.html上找到有关绑定的更多信息。

清单3-8。示例Libvirt Python代码

import libvirt import sys # Open a read-only connection to the local hypervisor. conn = libvirt.openReadonly(None) if conn == None: print 'Failed to open connection to the hypervisor' sys.exit(1) # Get some information about the hypervisor. hv_info = conn.getInfo() # Print out the architecture, memory, Cores, and speed of the processor. print 'hv arch {0}'.format(hv_info[0]) print 'hv memory {0}'.format(hv_info[1]) print 'cores in hv {0}'.format(hv_info[2]) print 'Mhz speed of hv CPU {0}'.format(hv_info[3])

virsh

virsh包含在KVM中,它是一种管理KVM的快捷方式。 如果您更喜欢简单,可以使用virsh并跳过其他管理解决方案。 virsh使用libvirt。 但是,您必须围绕virsh编写脚本来管理大量的虚拟机管理程序。 清单3-9中显示了使用virsh的一些示例。 您可以在http://linux.die.net/man/1/virsh上阅读有关virsh的更多信息。

清单3-9 virsh例子

# Given a file called hv.txt, which contains a list of KVM hypervisors, loop through the file and get a list of VMs running on each hypervisor. # cat hv.txt hv1.example.com hv2.example.com hv3.example.com # cat hv.sh #!/bin/bash HVLIST=hv.txt USER=fakeuser for hv in `cat ${HVLIST}` do echo ${hv} virsh -c qemu ssh://${USER}@${hv}/system list done # When you run hv.sh, below is a sample output you may get. # ./hv.sh hv1.example.com Id Name State ---------------------------------------------------- 1 vm1.example.com running 3 vm2.example.com running 4 vm3.example.com running hv2.example.com Id Name State ---------------------------------------------------- 1 vm4.example.com running 3 vm5.example.com running 4 vm6.example.com running hv3.example.com Id Name State ---------------------------------------------------- 1 vm7.example.com running 3 vm8.example.com running 4 vm9.example.com running # Get information on architecture, CPU, and memory of hypervisor. # In hv.sh, replace the 'list' command with 'nodeinfo' command [SNIP] for hv in `cat ${HVLIST}` do echo ${hv} virsh -c qemu ssh://${USER}@${hv}/system nodeinfo done # ./hv.sh hv1.example.com CPU model: x86_64 CPU(s): 8 CPU frequency: 3292 MHz CPU socket(s): 1 Core(s) per socket: 4 Thread(s) per core: 2 NUMA cell(s): 1 Memory size: 16301672 KiB Hv2.example.com CPU model: x86_64 CPU(s): 8 CPU frequency: 3292 MHz CPU socket(s): 1 Core(s) per socket: 4 Thread(s) per core: 2 NUMA cell(s): 1 Memory size: 16301672 KiB Hv3.example.com CPU model: x86_64 CPU(s): 8 CPU frequency: 3292 MHz CPU socket(s): 1 Core(s) per socket: 4 Thread(s) per core: 2 NUMA cell(s): 1 Memory size: 16301672 KiB

选择物理服务器

哪种服务器适合虚拟化平台?这是一个成功的虚拟化平台的基本问题。本节探讨了一些选项,例如定制,名称品牌,Open-Compute,机架和刀片服务器。

定制服务器

您可以购买零件并将自己的服务器放在一起。此方法的一个优点是您可以完全控制服务器的每个组件,例如硬盘驱动器,CPU,内存,网络,外形和功率。缺点是您必须花费大量时间确保组件协同工作。此外,您必须维护备件,因为您现在选择的部件将来可能会停产。与名牌服务器相比,您的前期资本支出应该较低。

品牌名称

戴尔,惠普,IBM等品牌名称可以使您的购买决策相对于定制服务器更容易。选择此路由的明显优势是您不必担心获得未经过测试的硬件。此外,供应商在支持合同的整个生命周期内负责硬件支持;因此,您不一定需要备用备件。与定制服务器相比,缺点是成本较高,因为您支付供应商进行集成测试并支付费用。

打开兼容计算的服务器

Open Compute(http://www.opencompute.org/)是一个旨在以低成本创建硬件的项目,其中包含符合特定规格的部件。如果您购买的硬件符合Open Compute服务器的规格,那么您可以确定您获得的硬件设计为低成本运行。

机架和刀片服务器

刀片服务器非常适合虚拟化。这样做的原因是每个刀片都可以是管理程序,它允许给定机箱中的大量VM。

机架式服务器也可用于虚拟化;但是,您丢失了刀片服务器提供的密度,这与您在给定机架中可以拥有的VM数量有关。

Cisco UCS或统一计算系统是不同类型的刀片服务器的示例。 Cisco UCS有一个称为光纤互连的控制器,用于管理机箱中的刀片。大多数刀片服务器没有外部控制器模块。

做出你的选择

无论您选择哪个平台,您选择的一些功能如下:

在选择CPU时,市场上的两个主要参与者是Intel和AMD。我在以下示例中专注于英特尔。您希望在Intel CPU中查找的某些特定于虚拟化的功能是

清单3-10显示了如何使用virsh命令获取有关特定管理程序的信息。

清单3-10。 KVM管理程序信息

# Get version information. # virsh version Compiled against library: libvirt 0.10.2 Using library: libvirt 0.10.2 Using API: QEMU 0.10.2 Running hypervisor: QEMU 0.12.1 #View information about a hypervisor. # virsh sysinfo <sysinfo type='smbios'> <bios> <entry name='vendor'>Dell Inc.</entry> <entry name='version'>2.2.3</entry> <entry name='date'>10/25/2012</entry> <entry name='release'>2.2</entry> </bios> <system> <entry name='manufacturer'>Dell Inc.</entry> <entry name='product'>PowerEdge T110 II</entry> <entry name='version'>Not Specified</entry> <entry name='serial'>XXXXXXX</entry> <entry name='uuid'>4C4C4544-0034-5210-8054-B7C04F435831</entry> <entry name='sku'>Not Specified</entry> <entry name='family'>Not Specified</entry> </system> <processor> <entry name='socket_destination'>CPU1</entry> <entry name='type'>Central Processor</entry> <entry name='family'>Xeon</entry> <entry name='manufacturer'>Intel(R) Corporation</entry> <entry name='signature'>Type 0, Family 6, Model 58, Stepping 9</entry> <entry name='version'>Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz</entry> <entry name='external_clock'>100 MHz</entry> <entry name='max_speed'>4000 MHz</entry> <entry name='status'>Populated, Enabled</entry> <entry name='serial_number'>NotSupport</entry> <entry name='part_number'>FFFF</entry> </processor> <memory_device> <entry name='size'>4096 MB</entry> <entry name='form_factor'>DIMM</entry> <entry name='locator'>DIMM A2</entry> <entry name='bank_locator'>BANK 0</entry> <entry name='type'>DDR3</entry> <entry name='type_detail'>Synchronous Unbuffered (Unregistered)</entry> <entry name='speed'>1600 MHz</entry> <entry name='manufacturer'>80CE000080CE</entry> <entry name='serial_number'>85DF74FD</entry> <entry name='part_number'>M391B5273DH0-YK0</entry> </memory_device> [SNIP] </sysinfo>

,