当前位置: 首页 > news >正文

网站超市系统 源码h5案例

网站超市系统 源码,h5案例,用手机做网站视频,网站公司的未来文章目录 libvirt 简介节点、Hypervisor和域libvirt 安装和配置libvirt的XML配置文件libvirt APIMain libvirt APIsError handlingSpecial specific APIs 建立到Hypervisor的连接libvirt API使用编译libvirt工具virshvirt-clonevirt-dfvirt-imagevirt-installvirt-topvirt-what… 文章目录 libvirt 简介节点、Hypervisor和域libvirt 安装和配置libvirt的XML配置文件libvirt APIMain libvirt APIsError handlingSpecial specific APIs 建立到Hypervisor的连接libvirt API使用编译libvirt工具virshvirt-clonevirt-dfvirt-imagevirt-installvirt-topvirt-whatvirt-p2vvirt-v2vvirt-managervirt-viewerqt-virt-managerqt-remote-viewerguestfishlibguestfs 总结参考 本文对libvirt概念和原理做简单介绍作为对libvirt使用入门。 libvirt 简介 libvirt是为了更方便地管理平台虚拟化技术而设计的开放源代码的应用程序接口、守护进程和管理工具它不仅提供了对虚拟化客户机的管理也提供了对虚拟化网络和存储的管理。 libvirt支持多种虚拟化方案既支持包括KVM、QEMU、Xen、VMware、VirtualBox、Hyper-V等在内的平台虚拟化方案也支持OpenVZ、LXC等Linux容器虚拟化系统还支持用户态LinuxUML的虚拟化。 libvirt本身提供了一套较为稳定的C语言应用程序接口目前在其他一些流行的编程语言中也提供了对libvirt的绑定在Python、Perl、Java、Ruby、PHP、OCaml等高级编程语言中已经有libvirt的程序库可以直接使用。libvirt还提供了为基于AMQP高级消息队列协议的消息系统如Apache Qpid提供QMF代理这可以让云计算管理系统中宿主机与客户机、客户机与客户机之间的消息通信变得更易于实现。libvirt还为安全地远程管理虚拟客户机提供了加密和认证等安全措施。 libvirt对多种不同的Hypervisor的支持是通过一种基于驱动程序的架构来实现的。libvirt对不同的Hypervisor提供了不同的驱动对Xen有Xen的驱动对QEMU/KVM有QEMU驱动对VMware有VMware驱动。在libvirt源代码中可以很容易找到qemu_driver.c、xen_driver.c、xenapi_driver.c、VMware_driver.c、vbox_driver.c这样的驱动程序源代码文件。 ibvirt作为中间适配层可以让底层Hypervisor对上层用户空间的管理工具是完全透明的因为libvirt屏蔽了底层各种Hypervisor的细节为上层管理工具提供了一个统一的、较稳定的接口API。通过libvirt一些用户空间管理工具可以管理各种不同的Hypervisor和上面运行的客户机 节点、Hypervisor和域 在libvirt中涉及几个重要的概念解释如下 节点Node是一个物理机器上面可能运行着多个虚拟客户机。Hypervisor和Domain都运行在节点上。Hypervisor也称虚拟机监控器VMM如KVM、Xen、VMware、Hyper-V等是虚拟化中的一个底层软件层它可以虚拟化一个节点让其运行多个虚拟客户机不同客户机可能有不同的配置和操作系统。域Domain是在Hypervisor上运行的一个客户机操作系统实例。域也被称为实例instance如在亚马逊的AWS云计算服务中客户机就被称为实例、客户机操作系统guest OS、虚拟机virtual machine它们都是指同一个概念。 节点、Hypervisor和域的关系: libvirt 安装和配置 libvirt的XML配置文件 在使用libvirt对虚拟化系统进行管理时很多地方都是以XML文件作为配置文件的包括客户机域的配置、宿主机网络接口配置、网络过滤、各个客户机的磁盘存储配置、磁盘加密、宿主机和客户机的CPU特性等等。本节只针对客户机的XML进行较详细介绍因为客户机的配置是最基本的和最重要的了解了它之后就可以使用libvirt管理客户机了。 关于各种配置的XML可以直接参考libvirt官方文档XML Format libvirt API ibvirt的核心价值和主要目标就是提供一套管理虚拟机的、稳定的、高效的应用程序接口API。libvirt API本身是用C语言实现的本节以其提供的最核心的C语言接口的API为例进行简单的介绍。 从libvirt官方文档看主要API分成以下几类 Main libvirt APIs libvirt-common common macros and enums for the libvirt and libvirt-admin library libvirt-domain-checkpoint APIs for management of domain checkpoints libvirt-domain-snapshot APIs for management of domain snapshots libvirt-domain APIs for management of domains libvirt-event APIs for management of events libvirt-host APIs for management of hosts libvirt-interface APIs for management of interfaces libvirt-network APIs for management of networks libvirt-nodedev APIs for management of nodedevs libvirt-nwfilter APIs for management of nwfilters libvirt-secret APIs for management of secrets libvirt-storage APIs for management of storage pools and volumes libvirt-stream APIs for management of streams Error handling virterror error handling interfaces for the libvirtlibrary Special specific APIs admin interface APIs for management of the libvirt daemons qemu driver qemu-driver specific APIs lxc driver lxc-driver specific APIs 建立到Hypervisor的连接 对于一个libvirt连接可以使用简单的客户端-服务器端C/S的架构模式来解释一个服务器端运行着Hypervisor一个客户端去连接服务器端的Hypervisor然后进行相应的虚拟化管理。当然如果通过libvirt API实现本地的管理则客户端和服务器端都在同一个节点上并不依赖于网络连接。一般来说如基于QEMU/KVM的虚拟化方案不管是基于libvirt API的本地管理还是远程管理在服务器端的节点上除了需要运行相应的Hypervisor以外还需要让libvirtd这个守护进程处于运行中的状态以便让客户端连接到libvirtd从而进行管理操作。 由于支持多种Hypervisorlibvirt需要通过唯一的标识来指定如何才能准确地连接到本地或远程的Hypervisor。为了达到这个目的libvirt使用了在互联网应用中广泛使用的URIUniform Resource Identifier统一资源标识符来标识到某个Hypervisor的连接。libvirt中连接的标识符URI其本地URI和远程URI有一些区别下面分别介绍一下它们的使用方式。 本地URI 在libvirt的客户端使用本地的URI连接本系统范围内的Hypervisor本地URI的一般格式如下 driver[transport]:///[path][?extraparameters]其中driver是连接Hypervisor的驱动名称如qemu、xen、xbox、lxc等transport是选择该连接所使用的传输方式可以为空也可以是“unix”这样的值path是连接到服务器端上的某个路径?extraparameters是可以额外添加的一些参数如Unix domain sockect的路径。 远程URI 除了本地管理libvirt还提供了非常方便的远程的虚拟化管理功能。libvirt可以使用远程URI来建立到网络上的Hypervisor的连接。远程URI和本地URI是类似的只是会增加用户名、主机名或IP地址和连接端口来连接到远程的节点。远程URI的一般格式如下 driver[transport]://[user][host][:port]/[path][?extraparameters]其中transport表示传输方式其取值可以是ssh、tcp、libssh2等user表示连接远程主机使用的用户名host表示远程主机的主机名或IP地址port表示连接远程主机的端口。其余参数的意义与本地URI中介绍的完全一样。 在远程URI连接中也存在使用system实例和session实例两种方式这二者的区别和用途与本地URI中介绍的内容是完全一样的。 更加详细的内容说明可以参考官方文档Connection URIs libvirt API使用 如下一个简单的C程序就是通过调用libvirt的API来查询一些关于某个域的信息。该示例程序比较简单易懂它仅仅是使用libvirt API的一个演示程序这里不做过多的介绍。不过这里有三点需要注意 需要在示例代码的开头引入libvirt/libvirt.h这个头文件由于只是实现查询信息的功能所以可以使用virConnectOpenReadOnly来建立只读连接这里使用了空值NULL作为URI是让libvirt自动根据默认规则去建立到Hypervisor的连接。这里由于本地已经运行了libvirtd守护进程并启动了两个QEMU/KVM客户机所以它默认会建立到QEMU/KVM的连接。 /*** Get domain information via libvirt C API.* Tested with libvirt-devel-2.0.0 on a RHEL 7.3 host system.*/ #include libvirt/libvirt.h #include stdio.hint getDomainInfo(int id) {virConnectPtr conn NULL; /* the hypervisor connection */virDomainPtr dom NULL; /* the domain being checked */virDomainInfo info; /* the information being fetched *//* NULL means connect to local QEMU/KVM hypervisor */conn virConnectOpenReadOnly(NULL);if (conn NULL) {fprintf(stderr, Failed to connect to hypervisor\n);return 1;}/* Find the domain by its ID */dom virDomainLookupByID(conn, id);if (dom NULL) {fprintf(stderr, Failed to find Domain %d\n, id);virConnectClose(conn);return 1;}/* Get virDomainInfo structure of the domain */if (virDomainGetInfo(dom, info) 0) {fprintf(stderr, Failed to get information for Domain %d\n, id);virDomainFree(dom);virConnectClose(conn);return 1;}/* Print some info of the domain */printf(Domain ID: %d\n, id);printf( vCPUs: %d\n, info.nrVirtCpu);printf( maxMem: %d KB\n, info.maxMem);printf( memory: %d KB\n, info.memory);if (dom ! NULL)virDomainFree(dom);if (conn ! NULL)virConnectClose(conn);return 0; } int main(int argc, char **argv) {int dom_id 1;printf(-----Get domain info by ID via libvirt C API -----\n);getDomainInfo(dom_id);return 0; }编译 gcc libvirt-demo.c -o libvirt-demo -lvirt运行 $ sudo ./libvirt-demo -----Get domain info by ID via libvirt C API ----- Domain ID: 1vCPUs: 2maxMem: 4194304 KBmemory: 4194304 KB编译libvirt libvirt 源码地址https://gitlab.com/libvirt/libvirt.git 编译过程参考源码中的docs/compiling.rst文档即可编译完之后在构建目录下有对应的库、管理工具、deamon程序和测试程序。 工具 许多工具都在使用libvirt提供的功能下面介绍几个常见的工具更多的介绍参考官方文档Applications using libvirt。 virsh libvirt项目的源代码中就包含了virsh这个虚拟化管理工具的代码。virsh 是用于管理虚拟化环境中的客户机和Hypervisor的命令行工具与virt-manager等工具类似它也是通过调用libvirt API来实现虚拟化的管理的是完全在命令行文本模式下运行的用户态工具。 virsh是用C语言编写的一个使用libvirt API的虚拟化管理工具。virsh程序的源代码在libvirt项目源代码的tools目录下实现virsh工具最核心的一个源代码文件是virsh.c。 通过virsh我们可以在命令行管理虚拟化环境如何使用virsh可以通过查看virsh帮助文档或者查看其他资料。 virt-clone Allows the disk image(s) and configuration for an existing virtual machine to be cloned to form a new virtual machine. It automates copying of data across to new disk images, and updates the UUID, MAC address, and name in the configuration. virt-df Examine the utilization of each filesystem in a virtual machine from the comfort of the host machine. This tool peeks into the guest disks and determines how much space is used. It can cope with common Linux filesystems and LVM volumes. virt-image Provides a way to deploy virtual appliances. It defines a simplified portable XML format describing the pre-requisites of a virtual machine. At time of deployment this is translated into the domain XML format for execution under any libvirt hypervisor meeting the pre-requisites. virt-install Provides a way to provision new virtual machines from a OS distribution install tree. It supports provisioning from local CD images, and the network over NFS, HTTP and FTP. virt-top Watch the CPU, memory, network and disk utilization of all virtual machines running on a host. virt-what virt-what is a shell script for detecting if the program is running in a virtual machine. It prints out a list of facts about the virtual machine, derived from heuristics. virt-p2v Convert a physical machine to run on KVM. It is a LiveCD which is booted on the machine to be converted. It collects a little information from the user, then copies the disks over to a remote machine and defines the XML for a domain to run the guest. (Note this tool is included with libguestfs) virt-v2v virt-v2v converts guests from a foreign hypervisor to run on KVM, managed by libvirt. It can convert guests from VMware or Xen to run on OpenStack, oVirt (RHEV-M), or local libvirt. It will enable VirtIO drivers in the converted guest if possible. (Note this tool is included with libguestfs) For RHEL customers of Red Hat, conversion of Windows guests is also possible. This conversion requires some Microsoft signed pieces, that Red Hat can provide. virt-manager A general purpose desktop management tool, able to manage virtual machines across both local and remotely accessed hypervisors. It is targeted at home and small office usage up to managing 10-20 hosts and their VMs. virt-viewer A lightweight tool for accessing the graphical console associated with a virtual machine. It can securely connect to remote consoles supporting the VNC protocol. Also provides an optional mozilla browser plugin. qt-virt-manager The Qt GUI for create and control VMs and another virtual entities (aka networks, storages, interfaces, secrets, network filters). Contains integrated LXC/SPICE/VNC viewer for accessing the graphical or text console associated with a virtual machine or container. qt-remote-viewer The Qt VNC/SPICE viewer for access to remote desktops or VMs. guestfish Guestfish is an interactive shell and command-line tool for examining and modifying virtual machine filesystems. It uses libvirt to find guests and their associated disks. libguestfs A library and set of tools for accessing and modifying virtual machine disk images. It can be linked with C and C management programs, and has bindings for Perl, Python, Ruby, Java, OCaml, PHP, Haskell, and C#. Using its FUSE module, you can also mount guest filesystems on the host, and there is a subproject to allow merging changes into the Windows Registry in Windows guests. 总结 libvirt是一套用于管理硬件虚拟化的开源API、守护进程与管理工具是目前使用最广泛的虚拟化管理工具可以协助我们从0到1构建一个基础的虚拟化管理平台。 参考 libvirt libvirt-git KVM实战原理、进阶与性能调优 虚拟化技术之kvm管理工具virsh常用基础命令一 虚拟化技术之kvm管理工具virsh常用基础命令二
http://www.hkea.cn/news/14454755/

相关文章:

  • 亿网中国网站管理系统岷县网站建设
  • 网站推广和网络推广网站合作建设合同
  • 做微整去那个网站找好的医院wordpress 定时计划失败
  • 建设网站和ipv4和ipv6什么关系即墨公司做网站
  • 怎么做网站的步骤游戏开发可以自学吗
  • 建个网站用多少钱工业设计公司属于什么行业
  • 网站推广推广网站的线下推广怎么做的
  • 服务器出租网站做个电商平台需要哪些步骤
  • 如何做盗版视频网站怎么自己制作网站
  • 查询公司的网站备案信息215做网站
  • 前端网站开发教程电商网站建设功能需求
  • 青鸟网站开发实例seo人才招聘
  • 为什么找不到做网站的软件内蒙古互联网公司哪里最多
  • 做网站违反广告法手机网站建设哪家有
  • 合肥地区网站制作网站开发与设计总结
  • 区块链网站开发费用wordpress采集自动伪原创
  • 赤峰市哪里做网站陕西一建2022停考
  • 吉林电商网站建设公司电话nginx wordpress 403
  • 广告建设网站中国商务服务网
  • 企业网站酷站外贸仿牌网站建设
  • 优秀作文大全网站百度首页 百度
  • 昆明怎样优化网站云虚拟主机怎么做2个网站
  • 常州网站建设公司如何成都高薪seo
  • 江西企业网站建设公司广西自治区集约化网站建设要求
  • 各大网站的域名是什么原因做网站建设涉及哪些算法
  • 郑州好的网站建设公司wordpress后台系统
  • 某鲜花网站的数据库建设十个必备的视频制作app
  • 建设 网站石青淘宝推广工具
  • 网站开发软件 连接SQL数据库写网页用什么语言
  • 商务网站建设简答题及答案网站关键词库如何做