Virtualization2.0 简明教程
Virtualization 2.0 - Overview
虚拟化是一种技术,可帮助我们在硬件上安装不同的操作系统。它们完全分離並相互獨立。在維基百科中,你可以找到以下定義:“在計算中,虛擬化是一個廣泛的術語,它指的是計算資源的抽象”。
Virtualization is a technology that helps us to install different Operating Systems on a hardware. They are completely separated and independent from each other. In Wikipedia, you can find the definition as – “In computing, virtualization is a broad term that refers to the abstraction of computer resources.
虚拟化向用户、他们的应用程序或最终用户隐藏计算资源的物理特性。这包括让单个物理资源(例如服务器、操作系统、应用程序或存储设备)表现为多个虚拟资源。它还包括让多个物理资源(例如存储设备或服务器)表现为单个虚拟资源……
Virtualization hides the physical characteristics of computing resources from their users, their applications or end users. This includes making a single physical resource (such as a server, an operating system, an application or a storage device) appear to function as multiple virtual resources. It can also include making multiple physical resources (such as storage devices or servers) appear as a single virtual resource…”
虚拟化通常是 −
Virtualization is often −
-
The creation of many virtual resources from one physical resource.
-
The creation of one virtual resource from one or more physical resource.
Types of Virtualization
如今,虚拟化术语被广泛应用于许多概念,其中一些概念在下文进行描述 −
Today the term virtualization is widely applied to a number of concepts, some of which are described below −
-
Server Virtualization
-
Client & Desktop Virtualization
-
Services and Applications Virtualization
-
Network Virtualization
-
Storage Virtualization
让我们现在详细讨论每一个这些。
Let us now discuss each of these in detail.
Server Virtualization
这是虚拟化你的服务器基础设施,无需再为不同的目的使用任何更多的物理服务器。
It is virtualizing your server infrastructure where you do not have to use any more physical servers for different purposes.

Client & Desktop Virtualization
这类似于服务器虚拟化,但这次是在用户站点,你对其桌面进行虚拟化。我们用瘦客户机改变其桌面,并利用数据中心资源。
This is similar to server virtualization, but this time is on the user’s site where you virtualize their desktops. We change their desktops with thin clients and by utilizing the datacenter resources.

Services and Applications Virtualization
虚拟化技术将应用程序与底层操作系统以及其他应用程序隔离,以提高兼容性和可管理性。例如 – Docker 可用于此目的。
The virtualization technology isolates applications from the underlying operating system and from other applications, in order to increase compatibility and manageability. For example – Docker can be used for that purpose.

Network Virtualization
它是虚拟化基础设施的一部分,专门在你将对服务器进行可视化时使用。它帮助你创建多种交换、Vlan、NAT 等。
It is a part of virtualization infrastructure, which is used especially if you are going to visualize your servers. It helps you in creating multiple switching, Vlans, NAT-ing, etc.
下图显示了 VMware 架构图 −
The following illustration shows the VMware schema −

Storage Virtualization
这在数据中心中广泛使用,在那里你有大量存储空间,它能帮助你为不同的硬件创建、删除、分配存储空间。此分配通过网络连接完成。存储领域的领导者是 SAN。下面给出一个示意图:
This is widely used in datacenters where you have a big storage and it helps you to create, delete, allocated storage to different hardware. This allocation is done through network connection. The leader on storage is SAN. A schematic illustration is given below −

Understanding Different Types of Hypervisors
管理程序是一个拦截操作系统对硬件调用的精简软件层。它还称为 Virtual Machine Monitor (VMM)。它在主机计算机上创建一个虚拟平台,在该平台之上执行和监控多个客户机操作系统。
A hypervisor is a thin software layer that intercepts operating system calls to the hardware. It is also called as the Virtual Machine Monitor (VMM). It creates a virtual platform on the host computer, on top of which multiple guest operating systems are executed and monitored.
管理程序有两种 −
Hypervisors are two types −
-
Native of Bare Metal Hypervisor and
-
Hosted Hypervisor
现在让我们详细讨论这两个。
Let us now discuss both of these in detail.
Native or Bare Metal Hypervisor
本机管理程序是直接运行在主机硬件上,用于控制硬件,并且监测 Guest Operating Systems 的软件系统。访客操作系统在管理程序的另一层运行。这些均具有虚拟机管理程序。
Native hypervisors are software systems that run directly on the host’s hardware to control the hardware and to monitor the Guest Operating Systems. The guest operating system runs on a separate level above the hypervisor. All of them have a Virtual Machine Manager.
该虚拟机架构的实例是 Oracle VM, Microsoft Hyper-V, VMWare ESX 和 Xen 。
Examples of this virtual machine architecture are Oracle VM, Microsoft Hyper-V, VMWare ESX and Xen.

Hosted Hypervisor
托管管理程序被设计为在传统操作系统中运行。换而言之,托管管理程序添加了主机操作系统顶部的独特软件层。同时,访客操作系统成为硬件上的第三层软件。
Hosted hypervisors are designed to run within a traditional operating system. In other words, a hosted hypervisor adds a distinct software layer on top of the host operating system. While, the guest operating system becomes a third software level above the hardware.
众所周知的托管管理程序实例是 Oracle VM VirtualBox 。还有 VMWare Server and Workstation, Microsoft Virtual PC, KVM, QEMU 和 Parallels 。
A well-known example of a hosted hypervisor is Oracle VM VirtualBox. Others include VMWare Server and Workstation, Microsoft Virtual PC, KVM, QEMU and Parallels.

Understanding Local Virtualization and Cloud
虚拟化是使云计算发挥作用的基本技术之一。然而,虚拟化并不是云计算。云计算是不同提供商基于一定成本向你提供的服务。
Virtualization is one of the fundamental technologies that makes cloud-computing work. However, virtualization is not cloud computing. Cloud computing is a service that different providers offer to you based on some costs.
在企业网络中,虚拟化和云计算通常与构建公有或私有云基础设施一起使用。小企业会分别部署每项技术来获取可衡量的益处。通过不同方式,虚拟化和云计算能够帮助你将设备支出保持在最低水平,并且利用现有的设备获得最佳可能的用途。
In enterprise networks, virtualization and cloud computing are often used together to build a public or private cloud infrastructure. In small businesses, each technology will be deployed separately to gain measurable benefits. In different ways, virtualization and cloud computing can help you keep your equipment spending to a minimum and get the best possible use from the equipment you already have.
如前所述,虚拟化软件允许一台物理服务器运行多个独立的计算环境。实际上,这就像为购买的每个物理服务器均获多台服务器。此技术对于云计算来说是至关重要的。云提供商拥有充满服务器的大型数据中心来为其云服务提供支持,但他们无法将一台服务器专用于每个客户。因此,他们将服务器上的数据虚拟分区,让每个客户都可以使用同一软件的独立“虚拟”实例(可以是私有网络、服务器场等)。
As mentioned before, virtualization software allows one physical server to run several individual computing environments. In practice, it is like getting multiple servers for each physical server you buy. This technology is fundamental to cloud computing. Cloud providers have large data centers full of servers to power their cloud offerings, but they are not able to devote a single server to each customer. Thus, they virtually partition the data on the server, enabling each client to work with a separate “virtual” instance (which can be a private network, servers farm, etc.) of the same software.
小企业最有可能通过订阅基于云的服务来采用云计算。云计算的最大提供商是 Microsoft with Azure 和 Amazon 。
Small businesses are most likely to adopt cloud computing by subscribing to a cloud-based service. The largest providers of cloud computing are Microsoft with Azure and Amazon.
Microsoft 提供了以下示意图,你可以了解到如何利用额外基础设施为企业提供帮助而不必花费额外资金。可以拥有内部基本基础设施,而云中可以拥有所有基于虚拟化技术的服务。
The following illustration is provided by Microsoft where you can understand how utilizing extra infrastructure for your business without the need to spend extra money helps. You can have the on-premises base infrastructure, while on cloud you can have all your services, which are based on Virtualized technology.

Virtualization 2.0 - Pros and Cons
在本章中,我们将讨论虚拟化的其中一些最常见的优点和缺点。
In this chapter, we will discuss some of the most common advantages and disadvantages of Virtualization.
Advantages of Virtualization
以下是虚拟化的一些公认的优点,其中进行了详细说明。
Following are some of the most recognized advantages of Virtualization, which are explained in detail.
Using Virtualization for Efficient Hardware Utilization
虚拟化通过减少对物理硬件系统的需求来降低成本。虚拟机使用高效的硬件,它可以减少硬件数量、相关的维护成本并降低电源以及冷却需求。你可以在一秒钟内分配内存、空间和 CPU,这使得你更独立于硬件供应商。
Virtualization decreases costs by reducing the need for physical hardware systems. Virtual machines use efficient hardware, which lowers the quantities of hardware, associated maintenance costs and reduces the power along with cooling the demand. You can allocate memory, space and CPU in just a second, making you more self-independent from hardware vendors.
Using Virtualization to Increase Availability
虚拟化平台提供了物理服务器上没有的许多高级功能,这些功能可以增加正常运行时间和可用性。尽管供应商功能名称可能不同,但它们通常提供实时迁移、存储迁移、容错、高可用性和分布式资源调度等功能。这些技术使虚拟机继续运行或使它们能够从意外中断中恢复。
Virtualization platforms offer a number of advanced features that are not found on physical servers, which increase uptime and availability. Although the vendor feature names may be different, they usually offer capabilities such as live migration, storage migration, fault tolerance, high availability and distributed resource scheduling. These technologies keep virtual machines chugging along or give them the ability to recover from unplanned outages.
虚拟机从一台服务器迁移到另一台服务器的能力也许是虚拟化的其中一项最大的优势,具有深远的用途。随着技术的不断成熟,它能够进行长距离迁移,比如能够将虚拟机从一个数据中心迁移到另一个数据中心,而无论涉及的网络延迟如何。
The ability to move a virtual machine from one server to another is perhaps one of the greatest single benefits of virtualization with far reaching uses. As the technology continues to mature to the point where it can do long-distance migrations, such as being able to move a virtual machine from one data center to another no matter the network latency involved.
Disaster Recovery
当服务器虚拟化时,灾难恢复非常容易进行。借助虚拟机的最新快照,可以快速恢复并开始运行。组织可以更轻松地创建一个价格合理的复制站点。如果数据中心或服务器机房本身发生灾难,则可以随时将这些虚拟机迁移到云提供商的另一处。具备这种灵活性就意味着灾难恢复计划更容易实施,并且有 99% 的成功率。
Disaster recovery is very easy when your servers are virtualized. With up-to-date snapshots of your virtual machines, you can quickly get back up and running. An organization can more easily create an affordable replication site. If a disaster strikes in the data center or server room itself, you can always move those virtual machines elsewhere into a cloud provider. Having that level of flexibility means your disaster recovery plan will be easier to enact and will have a 99% success rate.
Save Energy
将物理服务器迁移到虚拟机,并将它们合并到更少的物理服务器上,意味着降低数据中心每月电力和冷却成本。它减少了碳足迹并有助于净化我们呼吸的空气。消费者希望看到企业减少污染排放并承担责任。
Moving physical servers to virtual machines and consolidating them onto far fewer physical servers’ means lowering monthly power and cooling costs in the data center. It reduces carbon footprint and helps to clean up the air we breathe. Consumers want to see companies reducing their output of pollution and taking responsibility.
Deploying Servers too fast
您可以快速克隆映像、主模板或现有虚拟机,以便在几分钟内启动并运行服务器。您无需填写采购订单、等待运输和收货,然后机架、堆放和布线物理机,才能花更多小时等待操作系统和应用程序完成安装。借助 Veeam 等虚拟备份工具,重新部署映像的速度非常快,终端用户甚至几乎不会注意到存在问题。
You can quickly clone an image, master template or existing virtual machine to get a server up and running within minutes. You do not have to fill out purchase orders, wait for shipping and receiving and then rack, stack, and cable a physical machine only to spend additional hours waiting for the operating system and applications to complete their installations. With virtual backup tools like Veeam, redeploying images will be so fast that your end users will hardly notice there was an issue.
Save Space in your Server Room or Datacenter
想象一个简单的示例:您有两个机架,有 30 台物理服务器和 4 台交换机。通过虚拟化服务器,将帮助您减少物理服务器占用空间的一半。结果可能是在一个机架中放置两台物理服务器,配有一台交换机,每台物理服务器容纳 15 台虚拟化服务器。
Imagine a simple example: you have two racks with 30 physical servers and 4 switches. By virtualizing your servers, it will help you to reduce half the space used by the physical servers. The result can be two physical servers in a rack with one switch, where each physical server holds 15 virtualized servers.
Testing and setting up Lab Environment
在服务器上测试或安装某个东西时,如果它崩溃,不要惊慌,因为没有数据丢失。只需恢复到以前的快照,就可以继续前进,就好像错误根本没有发生一样。您还可以在保持这些测试环境在线的同时,将它们与终端用户隔离。当您完全完成工作时,在实时环境中部署它。
While you are testing or installing something on your servers and it crashes, do not panic, as there is no data loss. Just revert to a previous snapshot and you can move forward as if the mistake did not even happen. You can also isolate these testing environments from end users while still keeping them online. When you have completely done your work, deploy it in live.
Shifting all your Local Infrastructure to Cloud in a day
如果您决定将整个虚拟化基础设施转移到云提供商中,您可以在一天内完成。所有管理程序都可以为您提供导出虚拟服务器的工具。
If you decide to shift your entire virtualized infrastructure into a cloud provider, you can do it in a day. All the hypervisors offer you tools to export your virtual servers.
Possibility to Divide Services
如果您只有一台服务器,而此服务器支持不同的应用程序,那么这可能会增加服务之间相互崩溃的可能性,并增加服务器的故障率。如果您将此服务器虚拟化,您可以将应用程序放置在相互分离的环境中,正如我们之前讨论的那样。
If you have a single server, holding different applications this can increase the possibility of the services to crash with each other and increasing the fail rate of the server. If you virtualize this server, you can put applications in separated environments from each other as we have discussed previously.
Disadvantages of Virtualization
虽然您找不到虚拟化的很多缺点,但我们将讨论几个突出的缺点,如下所示:
Although you cannot find many disadvantages for virtualization, we will discuss a few prominent ones as follows −
Extra Costs
您可能必须投资虚拟化软件,并且可能需要额外的硬件才能使虚拟化成为可能。这取决于您现有的网络。许多企业有足够的能力来适应虚拟化,而无需太多现金。如果您拥有超过 5 年的基础设施,那么您必须考虑一个初始更新预算。
Maybe you have to invest in the virtualization software and possibly additional hardware might be required to make the virtualization possible. This depends on your existing network. Many businesses have sufficient capacity to accommodate the virtualization without requiring much cash. If you have an infrastructure that is more than five years old, you have to consider an initial renewal budget.
Software Licensing
随着越来越多的软件供应商适应虚拟化应用的增加,这一问题变得越来越不严重。然而,重要的是与供应商核实,以了解他们如何看待虚拟化环境中的软件使用。
This is becoming less of a problem as more software vendors adapt to the increased adoption of virtualization. However, it is important to check with your vendors to understand how they view software use in a virtualized environment.
Learn the new Infrastructure
实施和管理虚拟化环境需要具备虚拟化专业知识的 IT 人员。在用户方面,典型的虚拟环境将与非虚拟环境类似地运行。有些应用程序无法很好地适应虚拟化环境。
Implementing and managing a virtualized environment will require IT staff with expertise in virtualization. On the user side, a typical virtual environment will operate similarly to the non-virtual environment. There are some applications that do not adapt well to the virtualized environment.
Virtualization 2.0 - Common Uses
有许多虚拟化用例,但使用最为广泛的是 Server Virtualization 和 Client Desktops Virtualization 。我们已经在前一章讨论了它们的优势以及它们被广泛使用的原因。
There are several types of uses in virtualization, but the most commonly used are Server Virtualization and Client Desktops Virtualization. We have already discussed their advantages in the previous chapter and why are they used widely.
Virtualizing Desktop Computers
客户端虚拟化(也称为 VDI)在集中式服务器内运行整个桌面环境。所有处理均在服务器内部完成。客户端设备通常为瘦客户端,用作连接诸如键盘、鼠标、显示器、音频连接器,甚至通过局域网连接的 USB 端口等 I/O 外围设备的终端节点。
Client virtualization also called as VDI runs the entire desktop environment within a centralized server. All processing is done within the server. Client devices are typically thin clients that serve as an end node to connect I/O peripherals such as keyboard, mouse, a display, audio connectors and even USB ports over the LAN.

如前所述,瘦客户端硬件是一种计算机终端,为键盘、鼠标、显示器、声音外围设备的插口以及 USB 设备的开放端口提供 I/O。
As discussed earlier, a thin client hardware is a computer terminal, which provides I/O for a keyboard, mouse, monitor, jacks for sound peripherals, and open ports for USB devices.
例如 - 打印机、闪存驱动器、网络摄像头、读卡器、智能手机等。一些瘦客户端包含传统串行和/或并行端口,以支持收据打印机、秤、打卡机等老式设备。瘦客户端软件通常包括一个 GUI(图形用户界面)、云接入代理(例如 RDP、ICA、PCoIP)、一个本地网络浏览器、终端仿真(在某些情况下)以及一组基本的本地实用程序。
For example – Printer, Flash Drive, Web Cam, Card Reader, Smartphone, etc. Some thin clients include legacy serial and/or parallel ports to support older devices such as Receipt Printers, Scales, Time Clocks, etc. Thin client software typically consists of a GUI (graphical user interface), Cloud Access Agents (for e.g. RDP, ICA, PCoIP), a local web browser, terminal emulations (in some cases) and a basic set of local utilities.
瘦客户端的主要生产商是 HP、戴尔和 IBM。
The largest producers of thin clients are HP, Dell and IBM.

Running a Specific Program Solution
最著名的桌面虚拟化软件之一是 XenApp & XenDesktop 。在任何设备和任何位置为员工提供 Windows、Linux、网络和 SaaS 应用程序或完整的虚拟桌面。
One of the best software known for Desktop Virtualization is XenApp & XenDesktop. Deliver Windows, Linux, Web and SaaS applications or full virtual desktops to workers on any device and anywhere.
More information can be found on https://www.citrix.com/products/xenapp-xendesktop/
另一个主要提供商是 VMware,其平台称为 VMware Horizon 7 。如要购买并了解其所有功能和规格,请点击以下链接 https://www.vmware.com/products/horizon.html
Another major provider is VMware with its platform called VMware Horizon 7. To purchase and understand all their features and specifications, click on the following link https://www.vmware.com/products/horizon.html
Microsoft 是另一家提供商,它提供了远程桌面服务与 Hyper-V 的组合。如需了解更多相关信息,请点击以下链接 https://technet.microsoft.com/en-us/windowsserver/ee236407.aspx
Microsoft is another provider with a combination of Remote desktop services along with Hyper-V. For any further Information on this, click on the following link https://technet.microsoft.com/en-us/windowsserver/ee236407.aspx
Setting up Test and Development Environments
虚拟化环境最强大的功能之一是可以在短时间内创建不同方法的实验室,特别是在软件开发中,然后将相同的基础设施导入到生产中。
One of the most powerful features of a virtualized environment is the possibility to create labs for different approaches in a minute, especially in software development and then to import the same infrastructure in production.

关于测试环境的,可以将跨平台功能引入您的开发测试环境,并使用您首选的编码语言进行原生构建。它在您今日使用的设备和平台上对应用程序进行测试:从 Linux、Windows 到 iOS 和安卓。
Regarding the test environment, it brings cross-platform functionality to your dev-test environment and uses your preferred coding language to build natively. It tests your applications on the devices and platforms you use today: from Linux, Windows to iOS and Android.
上述提到的所有功能可以通过私有云或公有云实现。这取决于基于要求我们希望使用什么。您应该考虑到管理该云所需的人力资源和您希望支出的预算。
All the features mentioned in the above can be done through private cloud or public cloud. It depends on what we would like to use as per the requirement. You should take into consideration the human resources with which you have to manage this cloud and the budget that you want to spend.
Virtualization 2.0 - Hardware
本章我们将讨论硬件的各种组件,例如 CPU、内存、存储和网络。
In this chapter, we will discuss various components of hardware such as CPU, Memory, Storage and Networking.
Understanding Virtual CPU
当我们安装管理程序时,每一个物理 CPU 都将抽象为虚拟 CPU。它划分出每个核心可用的 CPU 周期,并允许多个 VM 在给定的物理处理器核心上进行“时间共享”。一般来说,管理程序通常为每个 vCPU(每个核心)分配一个工作负载。如果服务器上的工作负载需要更多的 CPU 周期,最好在特定的虚拟 CPU 上部署更少的 VM。
When we install a hypervisor, each physical CPU is abstracted into virtual CPUs. This divides the available CPU cycles for each core and allows multiple VMs to "time share" a given physical processor core. Generally talking, the hypervisor typically assigns one workload per vCPU (per core). If the workloads on a server need more CPU cycles, it is better to deploy fewer VMs on a particular virtual CPU.
让我们考虑以下示例以了解虚拟 CPU 的逻辑。
Let us consider the following example to understand the logic of virtual CPU.
我有一台带有两个处理器的物理服务器(CPU 1 和 CPU 2),每个处理器都有四个物理核心。总共,我们有 2 * 4 = 8 个物理核心。
I have a physical server with two processors (CPU 1 and CPU 2) and each of them has four physical cores. In total, we have 2 * 4 = 8 physical cores.
基于我们的管理程序针对每个物理核心提供的一些计算,我们可以得到 5-10 个 vCPU。
Based on some calculations our hypervisor provided for each physical core, we can get 5-10 vCPUs.
总共,我们将有 [8 个物理核心 * (5 到 10 个 vCPU)] 40-80 个 vCPU,这意味着我们可以向虚拟机分配最多 80 个 vCPU。
In total, we will have [8 physical cores * (5 to 10 vCPUs)] 40-80 vCPUs, which means that we can assign a maximum of 80 vCPUs to virtual machines.

Understanding Virtual Memory
虚拟内存简单来说就是计算机的 RAM。虚拟机的内存资源设置决定了从主机分配多少内存给虚拟机。虚拟硬件内存大小决定了虚拟机中运行的应用程序可用的内存大小。
Virtual Memory in simple words is the RAM of the machine. The memory resource settings for a virtual machine determines how much of the host’s memory is allocated to the virtual machine. The virtual hardware memory size determines how much memory is available to applications that run in the virtual machine.
虚拟机无法从超过其配置虚拟硬件内存大小的内存资源受益。 ESXi hosts 将内存资源使用限制为对虚拟机有用的最大量,以便您可以接受无限制内存资源的默认设置。
A virtual machine cannot benefit from more memory resources than its configured virtual hardware memory size. The ESXi hosts limit the memory resource use to the maximum amount useful for the virtual machine, so that you can accept the default of unlimited memory resources.
您可以添加、更改和配置虚拟机内存资源或选项以提升虚拟机性能。您可以在创建虚拟机时设置大多数内存参数,也可以在 Guest Operating System 安装后进行设置。大多数管理程序要求在更改设置前关闭虚拟机。
You can add, change, and configure virtual machine memory resources or options to enhance virtual machine performance. You can set most of the memory parameters while creating the virtual machine or it can also be done after the Guest Operating System is installed. Most of the hypervisors require to power off the virtual machine before changing the settings.
在以下示意图中,您可以看到总物理内存已在两台虚拟机间分配。
In the following schematic illustration, you can see that the total physical memory is divided between two virtual machines.

Understanding Virtual Storage
存储虚拟化是来自多个网络存储设备的物理存储(数据集群)的合并,使其看起来像是由中心控制台管理的单一存储设备。我们无法向虚拟机分配多于数据集群物理提供的存储。
Storage virtualization is the pooling of physical storage (Data cluster) from multiple network storage devices into what appears to be a single storage device that is managed from a central console. We cannot assign more storage to virtual machines that data cluster offers physically.
您将在文件的末尾看到这些扩展。在用作虚拟机一部分的所有文件中,不同的管理程序喜欢使用不同的文件类型。一些比较常见的是 VDI, VHDX, VMDK 和 HDD 。
You will see these extensions on the end of a file. Of all the files used as part of a virtual machine, different hypervisors like to use different file types. Some of the more common are VDI, VHDX, VMDK and HDD.
在以下示例中,我们有一个总容量为 12 TB 的数据集群,以及四台已分配存储的虚拟机,每台存储容量为 12 TB。总的来说,向它们分配的最大存储容量为 12 TB。
In the following example, we have a data cluster of 12 TB in total and four virtual machines to which we have allocated storage to each of them. In total, the maximum storage allocated to them is 12 TB.

Understanding Virtual Networking
我们将通过一个简单的示例来讨论如何完成虚拟网络。
We will discuss this with a simple example as to how virtual networking done.
我们在同一主机上运行虚拟机 1、2、3 和 4。它们希望在彼此之间发送网络流量。这是通过虚拟网络卡完成的,如以下示意图(vNIC)中所示,该示意图通过由管理程序创建的虚拟交换机(vSwitch)进行虚拟连接。
We have Virtual Machine 1, 2, 3 and 4 running on the same host. They would like to send the network traffic back and forth. This is done by virtual networking cards as shown in the following illustration (vNIC), which connects virtually with a virtual switch (vSwitch) that is created by the hypervisor.
该虚拟交换机与服务器的物理卡(pNIC)进行通信,而该物理卡连接到物理交换机(pSwitch),然后与其余网络设备进行通信。
This virtual switch communicates with a physical card of the server (pNIC), which is connected with a physical switch (pSwitch) and then communicates with the rest of the network equipment.
请参阅以下示意图场景。
Please see the following schematically done up scenario.

Virtualization 2.0 - Microsoft Hyper-V
在本节中,我们将讨论 Microsoft Hyper-V 及其各种模块。
In this chapter, we will discuss Microsoft Hyper-V along with its various modules.
Installing Hyper-V in Windows Server 2012
Microsoft Hyper-V(被称为 Windows Server 虚拟化)是一个本机(裸)虚拟机监视器。它可以在运行 Windows 操作系统(从 Windows 8 开始)的 x86-64 系统上创建虚拟机。Hyper-V 替代了 Windows Virtual PC 作为 Windows NT 客户端版本的硬件虚拟化组件。运行 Hyper-V 的服务器计算机可以配置为向一个或多个网络公开单个虚拟机。
Microsoft Hyper-V, known as Windows Server Virtualization, is a native (bare) hypervisor. It can create virtual machines on x86-64 systems running Windows OS, starting with Windows 8. Hyper-V supersedes Windows Virtual PC as the hardware virtualization component of the client editions of Windows NT. A server computer running Hyper-V can be configured to expose individual virtual machines to one or more networks.
Hyper-V 最初在 Windows Server 2008 和 Windows 7 中发布,自那时起一直免费提供给所有 Windows Server 版本和某些客户端操作系统。
Hyper-V was first released alongside Windows Server 2008 and Windows 7 and has been available without charge for all the Windows Server versions and some client operating systems since that time.
让我们通过以下步骤了解如何在 Windows Server 2012 中安装 Hyper-V 角色。
Let us see how to install a Hyper-V role in a Windows Server 2012 by following the steps given below.
Step 1 − 要安装 Hyper-V 角色,请转至“服务器管理器”→ 管理 → 添加角色和功能。
Step 1 − To Install Hyper-V role go to “Server Manager” → Manage → Add Roles and Features.

Step 2 − 点击“下一步”。
Step 2 − Click on “Next”.

Step 3 − 选择“基于角色或基于功能的安装”选项 → 点击“下一步”。
Step 3 − Select “Role-based or feature-based installation” option → click on “Next”.

Step 4 − 我们将在本地安装 Hyper-V 角色,因此“从服务器池中选择一台服务器”→ 点击“下一步”。
Step 4 − We will locally install the Hyper-V role as such “Select a server from the server pool” → click “Next”.

Step 5 − 从角色列表中,查看“Hyper-V”服务器角色→ 点击弹出窗口中的添加功能 → 点击“下一步”。
Step 5 − From the Roles lists, check the “Hyper-V” Server role → click on Add Features on the popup window → click “Next”.

Step 6 − 点击“下一步”。
Step 6 − Click “Next”.

Step 7 − 选择将参与虚拟化并负责网络交换的服务器的物理网络适配器 → 点击“下一步”。
Step 7 − Choose your server’s physical network adapters that will take part in the virtualization and responsible for network switching → click on “Next”.

Step 8 − 在迁移下,保留默认设置 → 点击“下一步”。
Step 8 − Under Migration, leave the default settings → click on “Next”.

Step 9 − 选择要保存文件的文件 → 点击“下一步”。
Step 9 − Choose the path where you want to save the file → click on “Next”.

Step 10 − 点击“安装”并等待安装栏完成。
Step 10 − Click “Install” and wait for the installation bar to finish.

Installing Hyper-V in a windows 10 workstation
要在 Windows 7、8、10 版本中安装它,您必须检查您的计算机是否支持虚拟化。以下是基本要求:
To install it in Windows 7, 8, 10 versions, you have to check if your computer supports virtualization. Following are the basic requirements −
-
Windows 10 Pro or Enterprise 64-bit Operating System.
-
A 64-bit processor with Second Level Address Translation (SLAT).
-
4GB system RAM at minimum.
-
BIOS-level Hardware Virtualization support.
在我的案例中,我们有一台支持它的笔记本电脑 HP Probook 450 G3 。
In my case, we have a laptop HP Probook 450 G3, which supports it.
在继续安装之前,请按照以下步骤操作。
Before continuing with the installation, follow the steps given below.
Step 1 − 确保在 BIOS 设置中启用了硬件虚拟化支持,如下所示 −
Step 1 − Ensure that hardware virtualization support is turned on in the BIOS settings as shown below −

Step 2 − 在搜索栏中键入 “turn windows features on or off” ,然后单击该功能,如下所示。
Step 2 − Type in the search bar “turn windows features on or off” and click on that feature as shown below.

Step 3 − 选择并启用 Hyper-V。
Step 3 − Select and enable Hyper-V.

Creating a Virtual Machine with Hyper-V
在本节中,你将学习如何创建虚拟机。首先,我们必须打开 Hyper-V 管理器,然后按照以下步骤操作。
In this section, we will learn how to create a virtual machine. To begin with, we have to open the Hyper-V manager and then follow the steps given below.
Step 1 − 转到“服务器管理器”→单击“Hyper-V 管理器”。
Step 1 − Go to “Server Manager” → Click on “Hyper-V Manager”.

Step 2 − 单击左侧面板上的“新建”或“操作”按钮。
Step 2 − Click “New” on the left Panel or on the “Actions” button.

Step 3 − 双击“虚拟机…”
Step 3 − Double-click on “Virtual Machine…”

Step 4 − 会打开一个新表 → 输入新计算机的名称 → 单击“下一步”。
Step 4 − A new table will open → Type Name of your new machine → click “Next”.

Step 5 − 将打开一个新表,你必须在此表中分配内存。请记住,你无法选择超过物理内存的内存。
Step 5 − A new table will be opened where you have to allocate the memory. Keep in mind you cannot choose more memory than you have physically.

Step 6 − 在“连接”下拉框中,选择你的物理网络适配器 → 单击“下一步”。
Step 6 − In the “Connection” drop down box, choose your physical network adaptor → click on “Next”.

Step 7 − 现在是时候创建虚拟硬盘了,如果你已经有一个,请选择第二个选项。
Step 7 − Now it is time to create a Virtual Hard disk, if you already have one, choose the second option.

Step 8 − 选择必须安装的 ISO 映像 → 单击“完成”。
Step 8 − Select the Image of ISO that has to be installed → click on “Finish”.

Step 9 − 单击完成之后,你会收到以下消息,如下面的屏幕截图所示。
Step 9 − After clicking on finish, you would get the following message as shown in the screenshot below.

Step 10 − 要连接到虚拟机,请右击已创建的计算机 → 单击“连接…”
Step 10 − To connect to the Virtual machine, Right Click on the created machine → click on “Connect…”

Step 11 − 之后,ISO 安装将继续。
Step 11 − After that, installation of your ISO will continue.

Setting up Networking with Hyper-V
Hyper-V vSwitch 是一款软件、第 2 层以太网网络流量交换机。它允许管理员将 VM 连接到物理或虚拟网络。它在 Hyper-V 管理器安装中默认可用,包含用于安全和资源跟踪的扩展功能。
The Hyper-V vSwitch is a software, layer-2 Ethernet network-traffic switch. It allows administrators to connect VMs to either physical or virtual networks. It is available by default within the Hyper-V Manager installation and contains extended capabilities for security and resource tracking.
如果你在设置过程之后尝试创建一个 VM,你将无法将其连接到网络。
If you attempt to create a VM right after the set-up process, you will not be able to connect it to a network.
要设置网络环境,你需要在 Hyper-V 管理器的右侧面板中选择 Virtual Switch Manager ,如下面的屏幕截图所示。
To set up a network environment, you will need to select the Virtual Switch Manager in the right hand side panel of Hyper-V Manager as shown in the screenshot below.

虚拟交换机管理器有助于配置 vSwitch 和全局网络设置,它可以让你更改默认的“MAC 地址范围”,如果你有这样做的理由。
The Virtual Switch Manager helps configure the vSwitch and the Global Network Settings, which simply lets you change the default ‘MAC Address Range’, if you see any reason for that.
创建虚拟交换机非常简单,而且有三种类型的 vSwitch,如下所述:
Creation of the virtual switch is easy and there are three vSwitch types available, which are described below −
-
External vSwitch will link a physical NIC of the Hyper-V host with a virtual one and then give your VMs access outside of the host. This means that your physical network and internet (if your physical network is connected to internet).
-
Internal vSwitch should be used for building an independent virtual network, when you need to connect VMs to each other and to a hypervisor as well.
-
Private vSwitch will create a virtual network where all connected VMs will see each other, but not the Hyper-V host. This will completely isolate the VMs in that sandbox.

在这里,我们已经选择了“外部”,然后“创建虚拟交换机”。设置 vSwitch 的表格将被打开,我们将在其中填充字段,如下所示:
Here, we have selected “External” and then “Create Virtual Switch”. The table with the setting of the vSwitch will be open where we will fill the fields as shown below
-
Name − is the name that we will put to identify the vSwitch.
-
Notes − is the description for us, generally, we put friendly descriptions to be understood.
-
Connection Type − is external as explained earlier and selects a physical network card on my server.
在输入所有这些之后,单击“确定”。
Once all this is entered, Click on “OK”.

Allocating Processors & Memory to a VM using Hyper-V
在本节中,我们将看到将 CPU、内存和磁盘资源分配给在服务器上运行的虚拟机这项任务。在 Hyper-V 中分配 CPU 或任何其他类型的资源的关键是记住所有内容都是相对的。
In this section, we will see the task of allocating CPU, Memory and Disk Resources to the virtual machines that are running on a server. The key to allocating CPU or any other type of resource in Hyper-V is to remember that everything is relative.
例如,微软已经发布了一些有关虚拟化 Exchange Server 的指南。列出的其中一件事是,无论是在虚拟机上还是在专用服务器上运行 Exchange,Exchange Server 的整体系统要求都是相同的。
For example, Microsoft has released some guidelines for Virtualizing Exchange Server. One of the things that was listed was that the overall system requirements for Exchange Server are identical whether Exchange is being run on a virtual machine or on a dedicated server.
为了分配上面提到的其中一个功能,我们需要单击右侧面板中的“设置…”选项卡。
To allocate one of the features mentioned above, we need to click on the “Settings…” tab in the right hand side panel.

要为选定的虚拟机分配更多内存,请单击屏幕左侧的“内存”选项卡。你还可以选择“启动 RAM”,在该选项中,你可以为虚拟机分配与你物理拥有的一样多的 RAM → 单击“确定”。
To allocate more memory to the selected virtual machine, click on the “Memory” tab on the left hand side of the screen. You will also have “Startup RAM”, where you can allocate as much ram as you have physically to a VM machine → Click on “Ok”.

要分配更多处理器,请单击面板左侧的“处理器”选项卡。然后,你可以为你的机器输入虚拟处理器的数量。
To allocate more processors, click on the “Processor” tab on the left hand side of the panel. Then you can enter the number of virtual processors for your machine.

如果你需要扩展、压缩虚拟硬盘的容量。在左侧面板中单击“IDE 控制器 0”→ 单击“编辑”。
If you need to expand, compress the capacity of the virtual hard disk. Click on the “IDE controller 0” on the left hand side panel → click on “Edit”.

在完成上述所有更改后,单击“下一步”。
Once all the above changes are done, Click on “Next”.

根据你的需求选择一个选项(它们都有各自的描述),然后单击“下一步”。
Select one of the options based on your need (all of them have their respective descriptions) and then click on “Next”.

单击“完成”并等待该过程完成。
Click on “Finish” and wait for the process to finish.

Using Checkpoints in Hyper-V
Hyper-V 中的检查点被称为快照,可帮助我们在过去需要的状态中还原计算机。
Checkpoints in Hyper-V are called snapshots and they help us to revert the machine in a desired state that we had in the past.
要创建检查点,我们应按照以下步骤操作。
To create a checkpoint we should follow the steps given below.
Step 1 − 选择 VM,单击它。在左侧面板中,单击“检查点”。
Step 1 − Select the VM by clicking on it. On the left hand side panel, click on “Checkpoint”.

Step 2 − 会在主 Hyper-V 管理器控制台中创建以下检查点及其日期和时间。
Step 2 − The following checkpoint will be created with the respective date and time in the main Hyper-V manager console.

VMware Workstation Player
在本章中,我们将了解如何安装 VMware Workstation Player 及其用法。
In this chapter, we will understand how to install the VMware Workstation Player and its usages.
Installing VMware Workstation Player
VMware Workstation Player 是一个“托管虚拟机管理程序”,因此在继续安装之前,必须先安装操作系统。
VMware workstation player is a “hosted hypervisor”, so you have to have a pre-installed OS before continuing to install it.
VMware Workstation Player 是免费版本,可供非商业、个人和家庭使用。他们还鼓励学生和非营利组织受益于此服务。要下载 VMware Workstation Player,可以单击以下链接 https://www.vmware.com/products/player/playerpro-evaluation.html 。要安装 VMware Workstation Player,请按照以下步骤操作。
VMware workstation player is free version and available for non-commercial, personal and home use. They also encourage students and non-profit organizations to benefit from this offering. To download the VMware workstation player, you can click on the following link https://www.vmware.com/products/player/playerpro-evaluation.html. To install the VMware workstation player, follow the steps given below.
Step 1 − 单击“立即下载”,如下面截图所示。
Step 1 − Click on “Download Now” as shown in the screenshot below.

Step 2 − 将看到已下载一个文件 → 双击该文件。
Step 2 − You will see that a file has been downloaded → double click on it.

Step 3 − 将弹出一个表,初始化 VMware 安装 → 单击“下一步”。
Step 3 − A Table will pop-up initializing the installation of VMware → Click “Next”.

Step 4 − 选中方框“我接受许可协议中的条款”→ 单击“下一步”。
Step 4 − Check the box “I accept the terms in the license agreement” → Click on “Next”.

Step 5 − 再次单击“下一步”按钮。
Step 5 − Once again, click on the “Next” button.

Step 6 −保留默认值并单击“下一步”。
Step 6 − Leave the default values and click on “Next”.

Step 7 − 再次单击“下一步”。
Step 7 − Once again, click on “Next”.

Step 8 − 单击“安装”。
Step 8 − Click on “Install”.

Step 9 − 将在桌面上创建一个图标。单击该图标,将弹出一个表格,其中有两种可能性:如果要将其用作非商业版本,只需输入电子邮件地址即可。如果要将其用作商业版本,请选中第二个选项并输入序列密钥。
Step 9 − An icon will be created on the desktop. Click on it and a table will pop–up, where you have two possibilities: If you want to use it as a non-commercial version, just enter your email address. If you want to use it as a commercial version, check the second option and enter your serial key.

Creating a VM with VMware Workstation
要创建虚拟机,我们必须按照以下步骤操作。
To create a virtual machine, we have to follow the steps given below.
Step 1 − 单击“播放器”→ 文件 → 新建虚拟机。
Step 1 − Click on “Player” → File → New Virtual Machine.

Step 1 − 会弹出一个表格,要求查找“引导磁盘”、“引导映像”或以后安装操作系统。
Step 2 − A table will pop-up requesting you to find a “Boot disk”, “Boot Image” or to install OS at a later stage.
我们选择第二个选项并单击“浏览”。然后我们单击要安装的 ISO 镜像。完成所有这些之后,单击“下一步”。
We will choose the second option and click on “Browse”. Then we have to click on the ISO image, which we want to install. Once all this is done, click on “Next”.

Step 3 − 由于我要安装 Windows Server 2012,它会弹出要求输入序列号的表格 → 如果你想激活 Windows 的非商业版本,直接单击“下一步”。
Step 3 − As I am installing windows server 2012, it will pop-up a table requesting to enter the serial key → click directly on “Next”, if you want to activate the noncommercial version for Windows.

Step 4 − 完成上述步骤后,将会打开一个对话框。单击“是”。
Step 4 − After the above step is complete, a dialogue box opens. Click “Yes”.

Step 5 − 单击“下一步”。
Step 5 − Click “Next”.

Step 6 − 在“最大磁盘大小”框中,输入虚拟硬盘的值,在本例中为 60GB。然后单击“下一步”。
Step 6 − In the “Maximum size disk” box, enter the value of your virtual Hard disk, which in our case is 60GB. Then click on “Next”.

Step 7 − 单击“完成”。
Step 7 − Click on “Finish”.

Setting up Networking with VMware Workstation
要在 VMware Workstation 中设置虚拟机的网络模式,我们必须单击“编辑虚拟机设置”。
To set up the networking modes of a virtual machine in a VMware Workstation, we have to click on the “Edit virtual machine settings”.

将打开一张表格,其中列出了网络设置,在该表格的左侧面板中,单击“网络适配器”。
A table will be opened with the settings of networking and on the left hand side panel of this table click on “Network Adaptor”.

在此表格的左侧,你可以看到以下屏幕截图中所示的网络模式。
On the left of this table, you can see the networking modes as shown in the following screnshots.

如果要限制虚拟机的带宽使用情况,请单击“高级”并设置传入和传出带宽。
If we want to limit the bandwidth usage of a virtual machine, click on “Advance” and set the incoming and outgoing bandwidths.

Allocating Processors & Memory to a VM using VMware Workstation
要在 VMware Workstation 中分配内存给虚拟机,我们必须单击“编辑虚拟机设置”。将打开一张表格,我们必须单击“内存”。
To allocate memory to a virtual machine in a VMware Workstation, we have to click on “Edit virtual machine settings”. A table will be opened and we will have to click on “Memory”.
在左侧面板中,我们必须手动输入内存量或通过像以下屏幕截图中所示的那样上下移动箭头来输入。
On the left hand side panel, we have to enter the amount of memory manually or by moving the arrow up and down as shown in the following screenshot.

如果你单击“处理器”,在左侧面板,我们必须输入 vCPU 数量,如下面的屏幕截图所示。
If you click on “Processors”. On the left hand side panel, we have to enter the amount of vCPU as shown in the screenshot below.

Note − 如果你设置的 vCPU 比主机支持的多,它将无法开启 VM。
Note − If you put more vCPU-s than what the host supports, it will fail to power on the VM.

Duplicating a VM Using VMware Workstation
要创建 VM 机器副本,我们必须使用 VMware Workstation 商业版。
To create duplicates of VM machines, we have to use the VMware Workstation Commercial Version.
让我们按照以下步骤看看如何在实际操作中进行。
Let us see how to do it in practice by following the steps given below.
Step 1 − 打开 VMware 管理控制台并右键单击要复制的 VM。单击“管理”。
Step 1 − Open the VMware managing console and right click on a VM that you want to duplicate. Click on “Manage”.

Step 2 − 单击“克隆……”,然后将打开一个向导。
Step 2 − Click on “Clone…” and a wizard will be open.

Step 3 − 单击“下一步”。
Step 3 − Click on “Next”.

Step 4 −点击“创建完整克隆”并点击“下一步”。
Step 4 − Click on “Create a Full Clone” and “Next”.

Step 5 −为要创建的克隆起个名字,然后点击“完成”。
Step 5 − Put a name for the clone that will be created and “Finish”.

以下屏幕截图介绍了克隆流程。
The following screenshots describe the process of cloning.

克隆流程完成后,将打开以下窗口。
Once the cloning process is complete, the following window will open.

Virtualization 2.0 - VirtualBox
在本章中,我们将了解什么是 VirtualBox,并详细讨论其拥有的各个组件。
In this chapter, we will understand what a VirtualBox is and discuss in detail the various components it has.
Installing VirtualBox
首先,我们将下载 VirtualBox 并安装它。我们应该按照以下步骤进行安装。
To start with, we will download VirtualBox and install it. We should follow the steps given below for the installation.
Step 1 - 要下载 VirtualBox,请点击以下链接 https://www.virtualbox.org/wiki/Downloads 现在,根据你的操作系统,选择要安装哪个版本。在我们的例子中,它将是第一个(Windows 主机)。
Step 1 − To download VirtualBox, click on the following link https://www.virtualbox.org/wiki/Downloads Now, depending on your OS, select which version to install. In our case, it will be the first one (Windows host).

Step 2 - 选择选项后,单击“下一步”。
Step 2 − Once the option is selected, click on “Next”.

Step 3 - 你可以选择询问在哪里安装应用程序。我们可以保留默认设置,然后单击“下一步”。
Step 3 − You have the option asking where to install the application. We can leave it as default and click on “Next”.

Step 4 - 选择选项后,如图所示,单击下一步。
Step 4 − Once the options are selected as shown in the following screenshot, click on Next.

Step 5 - 将出现一个对话框,询问是否继续安装。单击“是”。
Step 5 − A dialog box will come up asking whether to proceed with the installation. Click “Yes”.

Step 6 - 在下一步中,单击“安装”。
Step 6 − In the next step, click on “Install”.

Step 7 - 选中启动 VirtualBox 复选框,然后单击“完成”。
Step 7 − Tick the start VirtualBox check box and click on “Finish”.

Step 8 - VirtualBox 应用程序现在将打开,如图所示。现在,我们可以准备安装虚拟机了。
Step 8 − VirtualBox application will now open as shown in the following screenshot. Now, we are ready to install the virtual machines.

Creating a VM with VirtualBox
要使用 Oracle VirtualBox 创建虚拟机,我们应按照以下步骤进行操作。
To create a virtual machine with Oracle VirtualBox, we should follow the steps given below.
Step 1 - 首先,单击桌面上的“Oracle VM VirtualBox”图标,如下面的屏幕截图所示。
Step 1 − To begin with, click on the “Oracle VM VirtualBox” icon on the desktop as shown in the screenshot below.

Step 2 - 下一步是单击屏幕左上角的“新建”按钮。
Step 2 − The next step is to click on “New” button, which is in the top left hand side of the screen.

Step 3 - 将弹出一个表,要求你提供虚拟机的参数。这些参数将是 -
Step 3 − A table will pop-up requesting you the parameters for the virtual machine. These will be −
-
Name − We have to put a friendly name for this Virtual Machine.
-
Type − Enter the OS that is going to be installed on it.
-
Version − Enter the specific version for that OS, which we have selected earlier.
填写完所有上述参数后,单击“下一步”。
Once all the above parameters are filled, click on “Next”.

Step 4 - 选择你需要在此虚拟机中分配的内存大小 → 单击“下一步”。
Step 4 − Select the amount of memory that you need to allocate in this VM → Click on “Next”.

Step 5 - 勾选 HDD 的三个选项之一,然后单击“创建”。
Step 5 − Check one of the three options for the HDD and click on “Create”.

Step 6 - 为你的虚拟 HDD 选择一个文件扩展名(建议使用大多数管理程序使用的通用文件扩展名,如 VHD)→ 单击“下一步”。
Step 6 − Select a file extension for your virtual HDD (It is recommended to use a common file extension that most of the hypervisors use like VHD) → click on “Next”.

Step 7 - 选择是将虚拟 HDD 设置为动态的还是固定的。这取决于你的需求 → 单击“下一步”。
Step 7 − Choose whether you want the Virtual HDD as dynamic or fixed. This is based on your needs → Click on “Next”.

Step 8 − 为虚拟硬盘文件命名,并为虚拟机选择磁盘大小 → 单击“创建”。
Step 8 − Put a name for your virtual HDD file and select the disk size for your VM → Click on “Create”.

通过选择“专家模式”,所有上述步骤均可一次性完成。
All the above steps can be done in one shot by selecting the “Expert mode”.

创建的虚拟机将显示在下方的截图中。
The virtual machine created will be as shown in the screenshot below.

Setting up Networking with VirtualBox
在 VirtualBox 中有两种网络模式,分别是 −
There are two types of networking modes in VirtualBox, which are −
-
Nat Networks and
-
Host-only Networks.
这两个将在下方详细说明。
Both of these are explained in detail below.
Nat Networks
要设置 Nat 网络,我们应按照以下步骤进行操作。
For setting up Nat Networks, we should follow the steps given below.
Step 1 − 转到 Oracle VM VirtualBox Manager → 单击“首选项…”
Step 1 − Go to Oracle VM VirtualBox Manager → Click on “Preferences…”

Step 2 − 单击“网络”,然后在左面板中单击“NAT 网络”选项卡。
Step 2 − Click on “Network” and then on the left panel click on the “NAT Networks” tab.

Step 3 − 单击“+”按钮,该按钮在下方截图中高亮显示。
Step 3 − Click on the “+” button, which is highlighted in the screenshot below.

Step 4 − 在这里,我们必须输入“网络名称”和将被 NAT 的此网络的 IP 范围,以便访问互联网和其他网络。
Step 4 − Here, we have to put the “Network Name” and the IP range for this network that will be NAT-ed, in order to have access to internet and to other networks.

Host-only Networks
要设置仅主机网络,我们应按照以下步骤进行操作。
For setting up Host-only Networks, we should follow the steps given below.
Step 1 − 如果单击“仅主机网络”选项卡,则可以创建与其他网络隔离的网络。但是,虚拟机主机彼此通信并与管理程序计算机通信。单击“+”号。
Step 1 − If you click on the “Host-only Networks” tab, you can create networks that are isolated from the other networks. However, VM hosts communicate with each other and the Hypervisor machine. Click on the “+” sign.

Step 2 − 主机接口将继续创建,如下图所示。
Step 2 − The host interface will continue to be created as shown in the screenshot below.

Step 3 − 如果单击按钮,则可以编辑设置。
Step 3 − If you click on button, you can edit the settings.

Step 4 − 如果希望主机使用“DHCP IP”,请单击“DHCP 服务器”选项卡,并选中“启用服务器”复选框 → 单击“确定”。
Step 4 − If you want your host machines to take “DHCP IP”, click on the “DHCP Server” tab and check the box “Enable Server” → Click “OK”.

Step 5 − 在“适配器”选项卡中,输入管理程序的 IP。
Step 5 − In the “Adapter” tab, put the IP of the hypervisor.

在完成所有这些网络模式设置准备后。现在是时候为我们的虚拟机分配网络了。
After all these preparations for setting up the network modes is complete. It is now time to assign a network to our VMs.
要做到这一点,请单击面板左侧的虚拟机,然后右键单击“网络”选项,一张表格将会打开。
To do this, Click on the VMs on the left side of the panel, then right click on the “Network” option and a table will be open.

每台计算机最多可以有四个以太网适配器。下图突出显示了四个部分,它们在下面进行了说明。
You can have up to four Ethernet adaptors per machine. The following image has four sections highlighted, which are explained below.
-
Check the box “Enable Network Adapter” to enable the vNIC on the VM and attach it to one network.
-
You can have many networks created, so we have to select one of them in the “Name” dropdown box.
-
In the adapter type dropdown-box, we have to select a physical NIC that the hypervisor has.
-
Promiscuous Mode: Here, we can select “Deny”, if we do not want the VMs to communicate with each other.
完成以上所有参数后。单击“确定”。
Once all the above parameters are completed. Click on “OK”.

Allocating Processors & Memory to a VM
要使用 VirtualBox 为虚拟机分配处理器和内存,我们应执行以下步骤。
To allocate processors and memory to a virtual machine using VirtualBox, we should follow the steps given below.
Step 1 − 要分配处理器和内存,您必须在选择 VM 后单击“设置”。
Step 1 − To allocate a processor and memory, you have to click on “Settings” after you have selected the VM.

Step 2 − 单击左侧标签中的“系统”,然后单击“主板”标签。如下图所示,左右移动箭头以分配内存。
Step 2 − Click on “System” on the left side tab, then click on the “Motherboard” tab. Move the arrow left or right to allocate the memory as shown in the screenshot below.

Step 3 − 要分配处理器,请单击“处理器”选项卡。如下图所示,左右移动箭头以分配处理器数量。
Step 3 − To allocate processors, click on the “Processor” tab. Move the arrow left or right to allocate the number of processors as shown in the screenshot below.

Step 4 − 完成所有这些更改后 → 单击“确定”。
Step 4 − After all those changes are done → click on “OK”.

Duplicating a VM Using VirtualBox
要使用 VirtualBox 复制虚拟机,我们应执行以下步骤。
To duplicate a virtual machine using VirtualBox, we should follow the steps given below.
Step 1 − 要复制我们之前创建的 VM,请右键单击 VM,然后选择“克隆”。一个向导将打开。
Step 1 − To duplicate a VM that we created before, right click on the VM and select “Clone”. A wizard will open.

Step 2 − 填写克隆计算机的名称,然后单击“下一步”。
Step 2 − Write the name of the cloning machine and click on “Next”.

Step 3 − 选择其中一个选项,然后单击“克隆”。
Step 3 − Select one of the options and Click on “Clone”.

Step 4 − 新创建的 VM 将如下图所示。
Step 4 − The newly created VM will be as shown in the following screenshot.

Deleting a VM on VirtualBox
要删除 VirtualBox 上的虚拟机,我们应执行以下步骤。
To delete a virtual machine on VirtualBox, we should follow the steps given below.
Step 1 − 首先,我们要右键单击要删除的 VM,然后单击“删除”。
Step 1 − To start with, we have to right click on the VM that we want to delete and then click on “Remove”.

Step 2 − 要彻底删除虚拟机,请选择“删除所有文件”。
Step 2 − To delete a virtual machine completely, select “Delete all files”.

Virtualization 2.0 - Openstack
在本章中,我们将讨论 Openstack 及其在虚拟化中的作用。
In this chapter, we will discuss regarding Openstack and its role in Virtualization.
Understanding Openstack
OpenStack 是一款软件,用于构建和管理公有云和私有云的云计算平台。OpenStack 拥有一个最大的社区。它由 OpenStack Foundation 管理,这是一个非营利性组织,它负责监督开发和社区建设。它的官方网页是 – https://www.openstack.org/ 。
OpenStack is a software for building and managing cloud-computing platforms for public and private clouds. Openstack has one of the biggest communities. It is managed by the OpenStack Foundation, a non-profit organization that oversees both development and community building. Its official webpage is – https://www.openstack.org/.
OpenStack 用于部署虚拟机和其他用于管理云环境的不同任务的实例。OpenStack 被认为是 - 基础设施即服务 (IaaS)。基于 Openstack,请查看以下原理图,它说明了它是如何进行管理的。
OpenStack is used to deploy virtual machines and other instances that handle different tasks for managing a cloud environment. OpenStack is considered as – Infrastructure as a Service (IaaS). Based on Openstack, please see the following schematic illustration, which describes how it is managed.
Source - https://www.openstack.org/
Source − https://www.openstack.org/

Openstack 平台由 Web UI 仪表板进行管理。它包含九个核心关键组件。
Openstack platform is managed by a web UI dashboard. It comprises of nine Core key components.

以下是对这些核心概念的详细描述:
These key concepts are described in detail as follows −
-
Nova is a computing engine. It is used for deploying and managing large numbers of virtual machines.
-
Swift is a storage system for objects and files.
-
Cinder is a block storage component. It accesses specific locations on a disk drive.
-
Neutron provides the networking capability.
-
Horizon is the dashboard of Openstack. It is the only graphical interface (WEB UI).
-
Keystone provides identity services. It is essentially a central list of all the users.
-
Glance provides image services to OpenStack. In this case, "images" refers to images (or virtual copies) of hard disks.
-
Ceilometer provides telemetry services, which allow the cloud to provide billing services to individual users of the cloud.
-
Heat allows developers to store the requirements of a cloud application in a file that defines what resources are necessary for that application.
下图解释了 Openstack 的发布版本。
The release versions of Openstack are explained in the following illustration.

Installing Openstack
由于 Openstack 是一个开源平台,因此可以通过不同的软件发行版来安装和部署它。它们各自为云操作系统增加了自己的价值。
As Openstack is an open source platform, there are many ways to install and deploy it through different software distributions. Each one of them adds their own value to the cloud operating system.
对于想使用 Openstack 的新系统管理员,可以获得预先安装的 Openstack 平台 ISO 映像。它们可以从以下链接下载 https://docs.openstack.org/image-guide/obtain-images.html
For a new system administrator, who wants to play with Openstack will get pre-installed ISO images of the Openstack platform. They can be downloaded from the following link https://docs.openstack.org/image-guide/obtain-images.html

要手动安装,主要发行版包括:
To install them manually, the main distributors are −
我们必须了解 Openstack 适用于企业环境,并且要安装它,我们应该具备下列硬件要求。
We must understand that Openstack is for enterprise environment and to install it we should have the following hardware requirements.
Installation Requirements
Openstack 的安装要求如下:
The installation requirements for Openstack are as follows −
-
A minimum of 5 machines with the following roles − 1 machine for the MAAS server. 1 machine for the Autopilot. 3 or more machines for the cloud − At least one must have 2 NICs. At least 3 must have 2 disks.
-
A dedicated switch to create a private cloud LAN.
-
Internet access through a router on that LAN.
对于此实验室,我们有一个虚拟机,我们将安装 Devstack 。它设计用于安装在单个笔记本电脑、个人电脑或虚拟机上。它包括用于开发评估的原始上游代码。它受以下支持:
For this laboratory, we have a virtual machine and we will install Devstack. It is designed for installation on a single laptop, PC or VM. It includes the raw upstream code for development evaluation. It is supported on −
-
Ubuntu 14.04/16.04
-
Fedora 23/24
-
CentOS/RHEL 7
-
Debian and
-
OpenSUSE
The link for this version is – https://docs.openstack.org/devstack/latest/#install-linux
Installing Openstack on Ubuntu 14.04
要在 Ubuntu 14.04 上安装 Openstack,我们应遵循以下给定的步骤。
For installing Openstack on Ubuntu 14.04, we should follow the steps given below.
Step 1 — 从以下链接下载安装脚本 - https://git.openstack.org/cgit/openstack-dev/devstack
Step 1 − Download the installation script from the following link - https://git.openstack.org/cgit/openstack-dev/devstack
使用此命令 – git clone [role="bare"]https://git.openstack.org/openstack-dev/devstack
Use this command – git clone [role="bare"]https://git.openstack.org/openstack-dev/devstack


Step 2 — 通过键入以下命令浏览 Devstack 文件夹 – $ cddevstack 。
Step 2 − Browse the folder Devstack by keying in the following command – $ cddevstack.

Step 3 — 使用以下命令执行文件 stack.sh ,安装过程将继续,如下所示:
Step 3 − Execute the file stack.sh with the following command ./stack.sh and installation process will continue as shown below −

Step 4 — 输入您的密码。
Step 4 − Enter your password.

Step 5 — 现在完成安装过程大约需要 15-20 分钟,它将在期间下载并安装所有库。
Step 5 − Now it will take about 15-20 minutes to finish the installation process, while it downloads and installs all the libraries.

Step 6 — 在安装结束时,我们将看到主机的 IP、用于管理它的 URL、用户名和用于管理它的密码。
Step 6 − At the end of the installation, we will see the IP of the host, URL for managing it, username and password to administrate it.

Step 7 — 要登录,您必须在浏览器中输入:主机 IP、用户名和我们在安装期间输入的密码。
Step 7 − To sign in, you have to type in the browser: Host IP, username and password that we entered during the installation.

Step 8 — 在主仪表盘中,您将看到“实例”概述。
Step 8 − In the main dashboard, you will see “Instances” overview.

Step 9 — 要创建新实例或简单地说创建虚拟机,请单击“实例”。
Step 9 − To create new instances or in simple words to create Virtual machines click on “Instances”.

Step 10 — 单击“启动实例”。
Step 10 − Click on “Launch Instances”.

Step 11 — 填写所有字段,如下所示。
Step 11 − Fill in all the fields as shown below.

Step 12 − 我们将看到创建的实例,如下图所示。
Step 12 − We will see the instance created as shown in the following screenshot.

Preparing the Infrastructure
至少在服务器级别,虚拟化已经使用了很长时间。此后,该概念已扩展到用户、应用程序、网络、安全、存储,当然也扩展到了桌面虚拟化 (VDI)。因此,要在所有这些概念中实施,我们必须事先准备一个基础设施,该基础设施分为一些关键组件。
Virtualization, at least at the server level, has been in use for some time. Since, the concept has expanded to the User, Application, Network, Security, Storage, and of course to Desktop Virtualization (VDI) as well. Therefore, to roll out in all these concepts, we have to prepare an infrastructure before, which is divided in some key components.
第一个是 Hypervisor ,我们在前面的章节中已经讨论过。这项工作需要的一些重要规格包括:处理器、内存和网络模式等。
The First one is Hypervisor and we have discussed it in the earlier chapters. Some important specifications needed for this job are – Processors, Memory and Networking Modes, etc.
Networking - LAN and WAN Optimization
VDI 可能非常占用资源 —— 这包括通过线缆传输的流量。拥有一台好的 core-switching infrastructure 将通过允许管理员创建与流量动向相关的特定规则和策略来帮助减轻这个痛苦。
VDI can be very resource intensive – this includes traffic over the wire. Having a good core-switching infrastructure will help alleviate this pain by allowing the administrators to create certain rules and policies revolving around traffic flow.
为特定于 VDI 的流量设置 QoS metrics 可以帮助消除拥塞,并确保正确的流量拥有适当的优先级。至于离开数据中心的流量,了解用户的位置并根据某些标准优化他们的体验非常重要。
Setting up QoS metrics for VDI-specific traffic can help remove congestion and ensure that the right traffic has the proper amount of priority. As for the traffic that is leaving the data center, knowing where the user is located and optimizing their experience based on certain criteria, becomes very important.
另一个重要方面是存储。大型组织将拥有大量存储控制器。同时,一些较小的组织只会使用一个存储控制器。无论可用的存储控制器数量多少,都需要根据 VDI 为其正确调整大小。
Another significant aspect is storage. Large organizations will have numerous storage controllers. At the same time, some smaller organizations will be using only one. Regardless of the amount of storage controllers available, they need to be sized properly for VDI.
为了防止启动和处理风暴,组织必须查看其映像的 IOPS 要求。为了减轻处理痛苦,管理员可以查看 Flash Technologies ( NetApp, Fusion-IO, XtremIO ) 或 SSD Technologies ( Violin, Nimbus ),以帮助卸载这种类型的负载。此外,Atlantis ILIO 等中介平台运行在虚拟机之上,该虚拟机利用大量 RAM 作为关键存储存储库。
To prevent boot and processing storms, organizations must look at IOPS requirements for their images. To alleviate processing pains, administrators can look at Flash Technologies (NetApp, Fusion-IO, XtremIO) or SSD Technologies (Violin, Nimbus) to help offload that kind of workload. Furthermore, intermediary platforms like Atlantis ILIO run on top of a virtual machine that utilizes massive amounts of RAM as the key storage repository.
Understanding Different File Systems
文件系统根据其功能而有所不同。以下是其中一些最常见的文件系统 -
File systems are varied depending on their functions. Some of the most common ones are listed below −
-
Virtual Machine File System- VMFS
-
Network File System- NFS
-
New Technology File System- NTFS
-
Raw Device Mapping- RDM
让我们详细讨论其中的每一个。
Let us discuss each of these in detail.
Virtual Machine File System
VMFS 是 VMware 专有的文件系统。它是一个群集文件系统,可以同时装载到多台服务器上。这有助于每个主机同时连接到任何文件系统,这是 VMware 首选的专有系统所预期的。大多数 VMware 管理程序都可以在其他文件系统上运行,但默认选择和首选选择是 VMFS。
VMFS is a file system proprietary to VMware. It is a clustered file system and it can be mounted on multiple servers simultaneously. This helps every host to connect to the any file system at the same time, which is expected from a proprietary system preferred by VMware. Most of the VMware hypervisors will work with other file systems, but the default choice and the preferred choice is VMFS.
Network File System
NFS 是一个最初由 Sun 开发的系统,但现在是一个开放标准系统。通常在 UNIX 和 Linux 世界中使用。它是一个分布式文件系统。它可以装载到一台服务器上,并且网络将用于向多台计算机共享信息。
NFS is a system that was originally developed by Sun, but is now an Open Standard system. Used commonly in the UNIX and Linux world. It is a distributed file system. It can be mounted on one server and the network will be used to share information to multiple machines.
Choosing Between Different Types of Storage
所有的存储设备都被分成三类,分别是 -
All the storage devices are divided into three categories, which are −
-
Direct-Attached Storage
-
Network-Attached Storage
-
Storage-Area Network
Let us understand each of these in detail.
Direct-Attached Storage
DAS 是你的本地硬盘驱动器。每台计算机都可以有一个或多个本地硬盘驱动器。它主要用于小型虚拟化系统。此解决方案适用于少量来宾计算机。它是存储最便宜和最简单的方法。你还可以使用此方法连接外部硬盘驱动器,将任何来宾计算机加载到该外部硬盘驱动器,这是一个快速简单的启动方法。
DAS is your local hard drive. We can have one or more local hard drives in every machine. It is mostly used for small-virtualized systems. This solution is appropriate for a small amount of guest machines. It is the cheapest and the easiest method of storage. You can connect an external hard drive too with this method, load any guest machines onto that external hard drive, and that is just a quick and easy way to get rolling.
例如 - 一台在上面有本地硬盘的服务器。该类型的管理程序可以容纳不超过 10-20 台虚拟机。示例设备可以是带有八个本地硬盘的 HP 服务器,如下面的插图所示。
For example – A server that has local hard discs on it. That type of hypervisor can hold not more that 10-20 VM machines. A sample device can be a HP Server with eight local hard discs as shown in the following illustration.

Network-attached Storage
NAS 是“在网络上与他人共享其自己存储并且以最简单的形式充当文件服务器的任何服务器”。网络附属存储通过网络共享文件。使用的一些最重要的协议是 SMB, NFS, CIFS, 和 TCP/IP 。当你在 Windows 系统的文件服务器上访问文件时,它就是 NAS
NAS is "Any server that shares its own storage with others on the network and acts as a file server in the simplest form". Network Attached Storage shares files over the network. Some of the most significant protocols used are SMB, NFS, CIFS, and TCP/IP. When you access files on a file server on your windows system, it is NAS
NAS 将使用以太网连接来通过网络共享文件。NAS 设备将有一个 IP 地址,然后可以通过该 IP 地址通过网络访问。NAS 的最大提供商是 QNAP 和 Lenovo 。
NAS will be using an Ethernet connection for sharing files over the network. The NAS device will have an IP address and then will be accessible over the network through that IP address. Biggest providers of NAS are QNAP and Lenovo.

下图显示了 NAS 的工作原理。
The following illustration shows how NAS works.

Storage-area Network
SAN 允许多台服务器共享存储池;使其对服务器看起来像是本地存储或直接附加存储。专用网络标准 Fibre Channel 已被开发出来,以便允许块在服务器和存储之间高速移动。它使用专用交换机和基于光纤的布线系统,将其与遍历繁忙企业网络的日常流量分开。而成熟的 SCSI 协议使服务器的主机总线适配器和磁盘系统之间的通信成为可能。
SANs allow multiple servers to share a pool of storage; making it appear to the server as if it were local or directly attached storage. A dedicated networking standard, Fibre Channel, has been developed to allow blocks to be moved between servers and storage at high speed. It uses dedicated switches and a fiber-based cabling system, which separates it from the day-to-day traffic traversing the busy enterprise network. While the well-established SCSI protocol enables communication between the servers’ host bus adaptors and the disk system.

下图显示了 SAN 交换机如何运行。
The following illustration shows how a SAN switch operates.

Virtualization 2.0 - Troubleshooting
在本章中,我们将讨论网络通信和低性能故障排除。
In this chapter, we will discuss troubleshooting for network communication and for slow performance.
Troubleshooting Network Communication
在虚拟环境中,为了对网络连接进行故障排除,我们应按以下步骤查找解决方案:
In a virtual environment, to troubleshoot a network connectivity, we should follow some steps in order to find a resolution.
Network Communication Indications
以下是我们的某些症状:
Some of the symptoms that we have are as follows −
-
You cannot connect to the Internet.
-
There is no network connectivity to or from a single virtual machine.
-
Virtual machines fail to connect to the network.
-
Cannot get an IP.
-
A TCP/IP connection fails to and from a single virtual machine.
Network Communication Errors
您也可以收到以下错误:
You can get the following errors as well −
-
Destination Host Unreachable
-
Network error
-
Connection Refused
-
Network cable is unplugged
-
Ping request could not find host
-
Please check the name and try again
-
Unable to resolve target system name, etc.
Network Communication Resolutions
上述症状和错误的解决方案如下:
The resolutions for the above symptoms and errors are as follows −
-
Make sure that the Port Group Name is associated with the virtual machine’s network adapter, which exists in the switch or in the Virtual Distributed Switch. Also, ensure that it is spelt correctly.
-
Make sure that there are enough storage capacities in your virtual machine sometimes it affects the connectivity.
-
Verify that the virtual network adapter is present and connected.
-
Verify that the networking within the virtual machine’s guest operating system is correct.
-
Verify that the TCP/IP stack is functioning correctly.
-
If this virtual machine was converted from a physical system, verify that there are no hidden network adapters present. Because it can have hidden static routes.
-
Verify that the vSwitch has enough ports for the virtual machine.
-
Verify that the virtual machine is configured with two vNICs to eliminate a NIC or a physical configuration issue.
-
Confirm that your virtual machine’s firewall is not blocking the Internet access.
-
Confirm that your virtual machine’s anti-virus program is not blocking the Internet access.
-
Ensure that the network adapter is enabled.
-
Shut down the virtual machine and then restart your Host Machine.
-
Removing and re-adding virtual network card adaptor.
Troubleshooting Slow Performance
检查 CPU 负载是否过高。您可以单击“CPU”。这表明虚拟机正消耗多少 CPU。如果负载过高,您可以考虑添加更多 vCPU。在确保物理主机中的可用内核多于将在 VM 中配置的内核后,请执行此操作。我们还应考虑 VM 中的应用程序是否真正能够利用多个 vCPU。
Check if your CPU load is high. You can click on “CPU”. This will show you the amount of CPU the VM is consuming. If it is very high, you may consider adding some more vCPUs. This should be done after ensuring that the physical host has more cores available than what you are going to configure inside the VM. We should also consider whether the applications inside the VM are actually able to utilize multiple vCPUs or not.
Check the Memory
内存也可能是影响 VM 性能的严重限制因素。如果您配置的内存不足,VM 通常会响应,开始将内存页面换出到磁盘。如果虚拟机使用超过三分之二的内存,则应分配更多内存。
Memory could be a serious limit on VM performance as well. If you do not configure enough memory, the VM will usually respond by starting to swap its memory pages to disk .If your virtual machine is using more than 2/3rd of the memory and then we should allocate more.
See Disk Alignment
对于任何早于 Windows 7、早于 Windows 2008 Server 或旧版基于 Linux 的系统,磁盘可能未对齐。未对齐可能会导致严重的性能损失,尤其当底层存储没有太多 IOPS 可用时。
For any pre-Windows 7, pre-Windows 2008 Server or older Linux based systems, your disks may be misaligned. Misalignment may cause quite a performance hit, especially when your storage underneath does not have many IOPS to spare.
必须根据应用程序的需求将虚拟磁盘格式化为特定格式或块大小。例如:Microsoft SQL 2005 服务器的数据库通常放在块大小为 64KB 的 NTFS 上。
It is important to format the virtual disks to a specific format or block size according to the application needs. For example – The database of a Microsoft SQL 2005 server is generally put on an NTFS that has a block size of 64KB.
如果虚拟机在某个时间点出现了性能问题,您需要检查病毒扫描程序。不仅要针对受影响的虚拟机检查,还要针对其他虚拟机检查。
If the virtual machine has a performance issue at some point in time, you need to check the virus scanner. Not only on the impacted virtual machine, but also on the other virtual machines as well.
如果您执行了 P2V(虚拟机,即您将物理机转换为 VM),并且在之后没有“清理”,则可能有很多未使用的驱动程序,甚至应用程序。
If you do a P2V – a virtual machine (meaning you convert a physical machine to a VM) and you do not “clean up” afterwards, there may be a lot of unused drivers and even applications.
Backing Up, Restoring and Migrating VM
在本章中,我们将讨论如何备份、还原和迁移虚拟机。
In this chapter, we will discuss how to back up, restore and migrate a virtual machine.
Duplicating a VM
复制或克隆机器是指制作其精确副本。大多数管理程序支持此功能。通过复制机器,我们可以复制每个详细信息,包括机器名称以及附加到机器的不同网络地址。
To duplicate or clone a machine means making an exact copy of it. Most of the hypervisors support this feature. By duplicating a machine, we copy down every detail, including the name of the machine and the different network addresses attached to the machine.
复制机器并使其投入使用并不总是最好的选择,因为网络中的重复名称或 IP 可能存在问题。我们通常出于备份目的进行复制。
Duplicating a machine and putting it in to function is not always the best option because a duplicate name or IP in network can be a problem. We make duplication generally for backup purposes.
大多数管理程序在机器关闭时可以克隆。如果管理程序接受在机器启动时克隆,则建议将其关闭,因为该进程可能会使机器崩溃。在实践中,我们已经讨论了“VMware Workstation 中的克隆方式”,请参阅前面的章节。
Most hypervisors can clone while the machine is turned off. If the hypervisor accepts to clone while it is on, it is recommend to turn it off, because the process can crash the machine. In practice, we have discussed “How cloning is done in VMware Workstation”, please refer to the previous chapters.
Backing Up and Recovering a VM
有三种备份虚拟机的方法。
There are three methods for backing up virtual machines.
Method 1
最常见的一种方法是在访客虚拟机上安装传统的备份软件。如果我们的虚拟机上使用 Windows 操作系统,那么我们可以使用位于“控制面板”中的“备份和还原”来备份机器。
The most common one is to install traditional backup software on the guest VM. If Windows OS is used on our VM, we can use “Backup and restore” to back up the machine, which is found in the “Control Panel”.

对于 Linux 操作系统,我们可以根据需要使用许多开源工具,例如“Bacula”、“rsync”等。
For Linux OS, we can use many open source tools depending on our needs, like “Bacula”, “rsync”, etc.
Method 2
另一种策略或方法是复制定义虚拟机的所有文件。因此,我们必须找到并复制定义我们的虚拟机的所有各个文件到备用位置。其中一些文件将会很大。
Another strategy or method is to copy all of the files that define a VM. Therefore, we will have to go out and find all of the individual files that define our virtual machine and copy them to an alternate location. Some of these files are going to be large.
示例:在这里,我们使用 VirtualBox 创建了多个虚拟机,如下面的插图所示。它们的名称是——“AC2”、“Kali2016.1”、“test”、“Windows 2012”。
Example: Here, we have created several VM machines with VirtualBox as shown in the following illustration. Their names are – “AC2”, “Kali2016.1”, “test”, “Windows 2012”.

要找到我们必须复制或备份的文件,我们必须右键单击虚拟机。转到“存储”,然后将鼠标悬停在虚拟硬盘驱动器上,它将显示找到 VDI 文件的完整路径。
To find the files that we have to copy or to backup, we have to right click on the VM machine. Go to “Storage” then move your mouse over the virtual HDD and it will show the full path where the VDI files are found.


我们将所有这些文件保存到另一个位置。
We will save all these files to another location.
Method 3
备份和还原虚拟机的第三个选项是使用第三方软件。其中最好的软件之一是 VEEAM ,可在以下 URL 中找到—— https://www.veeam.com/
The third option to backup and restore VM machines is to use third party software. One of the best is VEEAM, which can be found on the following URL - https://www.veeam.com/

Converting a Physical Server into a Virtual Server
在本节中,我们将了解如何将物理机转换为虚拟机。这在很多文献中通常称为 P2V 。
In this section, we will see how to convert a physical machine into a virtual machine. This is often called as P2V in many literatures.
VMware 推出了一个名为 vCenter Converter 的产品,它可以将物理机专门转换为 VMware 虚拟机。可以从以下位置下载该软件—— https://www.vmware.com/products/converter.html
VMware puts out a product that is called vCenter Converter, which will convert from a physical machine specifically into a VMware virtual machine. The software can be downloaded from - https://www.vmware.com/products/converter.html

Microsoft 有一个名为 Disk2vhd 的产品,它可以将物理硬盘驱动器转换为 VHD 格式的虚拟硬盘驱动器。可以从以下链接下载—— https://technet.microsoft.com/en-us/sysinternals/ee656415.aspx
Microsoft has a product called Disk2vhd, which will convert a physical hard drive into a VHD formatted virtual hard drive. It can be downloaded from the following link – https://technet.microsoft.com/en-us/sysinternals/ee656415.aspx
我们只需要在物理服务器上安装该软件,然后单击“创建”,如下面的屏幕截图所示。它将创建一个 VHDX 文件,该文件可以导入超管理器。
We just have to install the software on the physical server and click “Create” as shown in the screenshot below. A VHDX file will be created which could be imported in a Hypervisor.

这两款产品都可以转换机器,且在服务器正在运行时它们是免费的。所有超管理程序供应商都有一些 P2V 工具,而且它们通常是免费的。从供应商的角度来看,他们非常希望您将您的物理机转换为针对其超管理程序优化的虚拟机。
Both of these products will convert machines, while the server is running and is free. All the vendors of hypervisors have some P2V tool and they are typically free. From the vendor’s point of view, they would very much like you to convert your physical machines into virtual machines that are optimized for their hypervisor.
Converting a Virtual Server into a Physical Server
将虚拟服务器转换为物理服务器通常称为 V2P,它肯定不如 P2V 转换常见。然而,有时在基于开发的环境中需要这样做。确实会发生需要在虚拟服务器中测试产品而不是在物理服务器中测试产品或者克隆生产机器并将其移动到测试中的情况。
To convert a virtual server to a physical server also commonly called as V2P is certainly less common than a P2V conversion. However sometimes, it is needed in development-based environments. It does happen where a product needs to be tested in the virtual server than to a physical server, or to clone a production machine and move it to test.
超管理程序供应商不提供这样的工具。但是,您必须向硬件供应商提出请求,询问他们是否可以提供此类工具。
Hypervisor vendors do not offer such a tool. However, you have to request the hardware vendor, if they could offer such tools.