Virtualization2.0 简明教程

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”.

backup

对于 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”.

ac2

要找到我们必须复制或备份的文件,我们必须右键单击虚拟机。转到“存储”,然后将鼠标悬停在虚拟硬盘驱动器上,它将显示找到 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.

go to storage
logs

我们将所有这些文件保存到另一个位置。

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/

veeam

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

p2v

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.

disk2vhd

这两款产品都可以转换机器,且在服务器正在运行时它们是免费的。所有超管理程序供应商都有一些 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.