Virtualization2.0 简明教程
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.
