本文介绍如何设置未群集的主机,以便在它们之间执行实时迁移。 如果在安装 Hyper-V 时未设置实时迁移,或者想要更改设置,请使用这些说明。 若要设置群集主机,请使用用于故障转移群集的工具。
设置实时迁移的要求
若要为实时迁移设置非群集主机,需要:
有权执行各种步骤的用户帐户。 源计算机和目标计算机上的本地“Hyper-V 管理员”组或“管理员”组中的成员身份满足此要求,除非你要配置约束委派。 配置受约束委派需要“域管理员”组中的成员身份。
源和目标服务器上安装的 Windows Server 2016 或Windows Server 2012 R2 中的 Hyper-V 角色。 如果虚拟机至少为版本 5,则可以在运行 Windows Server 2016 和 Windows Server 2012 R2 的主机之间执行实时迁移。
有关版本升级说明,请参阅在 Windows 10 或 Windows Server 2016 上升级 Hyper-V 中的虚拟机版本。 有关安装说明,请参阅在 Windows Server 上安装 Hyper-V 角色。源和目标计算机或者属于相同的 Active Directory 域,或者属于互相信任的域。
Hyper-V 管理工具已安装在运行 Windows Server 2016 或 Windows 10 的计算机上,除非是这些工具安装在源服务器或目标服务器上,并且你将从服务器运行这些工具。
考虑有关身份验证和网络的选项
请考虑如何设置以下内容:
Authentication: Which protocol will be used to authenticate live migration traffic between the source and destination servers? 选择确定在开始实时迁移之前是否需要登录到源服务器:
Kerberos 允许你避免登录到服务器,但需要设置约束委派。 有关说明,请参阅下文。
CredSSP 允许你避免配置约束委派,但需要登录到源服务器。 可以通过本地控制台会话、远程桌面会话或远程 Windows PowerShell 会话执行此操作。
对于可能不明显的情况,CredSPP 需要登录。 例如,如果你登录 TestServer01,将虚拟机迁移至 TestServer02,然后打算将虚拟机再迁至 TestServer01,那么你需要先登录 TestServer02,然后再尝试将虚拟机迁回至 TestServer01。 如果不这样做,身份验证尝试将失败,发生错误,并显示以下消息:
“虚拟机迁移操作失败,迁移出错位置:源计算机。 Failed to establish a connection with host computer name: No credentials are available in the security package 0x8009030E."
Performance: Does it make sense to configure performance options? 这些选项可以减少网络和 CPU 使用率,并加快实时迁移速度。 考虑你的要求和基础结构,并测试不同的配置以帮助你做出决定。 步骤 2 结束时介绍了这些选项。
Network preference: Will you allow live migration traffic through any available network, or isolate the traffic to specific networks? 我们建议将迁移流量隔离到受信任的专用网络上,这是最佳安全做法,因为实时迁移流在网络上发送时未进行加密设置。 可通过物理上隔离的网络或通过另一个受信任的网络技术(如 VLAN)来实现网络隔离。
升级到 Windows Server 2025
从 Windows Server 2025 开始,在非域控制器的所有已加入域的服务器上默认启用 Credential Guard。 因此,升级到 Windows Server 2025 后,可能无法在 Hyper-V 中使用基于 CredSSP 的实时迁移。 基于 CredSSP 的委派是 Windows Server 2022 及更早版本的实时迁移的默认值。 请改用 Kerberos 约束委派,如下一节所述。 有关详细信息,请参阅升级到 Windows Server 2025 时,Hyper-V 的实时迁移中断。
步骤 1:配置约束委派(可选)
如果你已决定使用 Kerberos 对实时迁移流量进行身份验证,请使用作为域管理员组成员的帐户配置受约束委派。
使用“用户和计算机”管理单元配置约束委派
打开“Active Directory 用户和计算机”管理单元。 (From Server Manager, select the server if it's not selected, click Tools>>Active Directory Users and Computers).
在“Active Directory 用户和计算机”导航窗格中,选择域,然后双击“计算机”文件夹。
From the Computers folder, right-click the computer account of the source server and then click Properties.
From Properties, click the Delegation tab.
在“委派”选项卡上,选择“仅信任此计算机委派指定的服务”,然后选择“使用任何身份验证协议”。
Click Add.
From Add Services, click Users or Computers.
在“选择用户或计算机”对话框,键入目标服务器的名称。 Click Check Names to verify it, and then click OK.
From Add Services, in the list of available services, do the following and then click OK:
To move virtual machine storage, select cifs. 如果要同时迁移存储器与虚拟机,而且仅迁移虚拟机的存储器,则需要执行此步骤。 如果将该服务器配置为使用 Hyper-V 的 SMB 存储器,则应首先选中该选项。
要迁移虚拟机,选择“Microsoft 虚拟系统迁移服务”。
On the Delegation tab of the Properties dialog box, verify that the services you selected in the previous step are listed as the services to which the destination computer can present delegated credentials. Click OK.
From the Computers folder, select the computer account of the destination server and repeat the process. 在“选择用户或计算机”对话框,确保指定源服务器的名称。
配置更改在发生以下两种情况后生效:
- 更改已复制到运行 Hyper-V 的服务器所登录的域控制器。
- 域控制器颁发新的 Kerberos 票证。
步骤 2:设置进行实时迁移的源计算机和目标计算机的步骤
此步骤包括选择关于身份验证和网络的选项。 作为最佳安全做法,我们建议你选择特定网络来运行实时迁移流量,在上所述。 此步骤还演示如何选择性能选项。
使用 Hyper-V 管理器为实时迁移设置源计算机和目标计算机
打开 Hyper-V 管理器。 (From Server Manager, click Tools>>Hyper-V Manager.)
在导航窗格中,选择其中一个服务器。 (If it isn't listed, right-click Hyper-V Manager, click Connect to Server, type the server name, and click OK. Repeat to add more servers.)
In the Action pane, click Hyper-V Settings>>Live Migrations.
In the Live Migrations pane, check Enable incoming and outgoing live migrations.
如果你不打算使用默认值 2,在“同步实时迁移”下面,请指定不同数字。
在“内向实时迁移”下面,如果打算使用特定网络连接来运行实时迁移流量,则单击“添加”,键入 IP 地址信息。 另外,单击“使用任何可用网络进行实时迁移”。 Click OK.
To choose Kerberos and performance options, expand Live Migrations and then select Advanced Features.
- If you have configured constrained delegation, under Authentication protocol, select Kerberos.
- Under Performance options, review the details and choose a different option if it's appropriate for your environment.
Click OK.
在“Hyper-V 管理器”中,选择其他服务器,然后重复步骤。
使用 Windows PowerShell 设置实时迁移的源计算机和目标计算机
Three cmdlets are available for configuring live migration on non-clustered hosts: Enable-VMMigration, Set-VMMigrationNetwork, and Set-VMHost. 此示例使用全部三个,并执行以下操作:
- 在本地主机上配置实时迁移
- 仅允许特定网络上的传入迁移流量
- 选择 Kerberos 作为身份验证协议
每一行代表一个单独的命令。
PS C:\> Enable-VMMigration
PS C:\> Set-VMMigrationNetwork 192.168.10.1
PS C:\> Set-VMHost -VirtualMachineMigrationAuthenticationType Kerberos
Set-VMHost 还允许你选择性能选项(以及许多其他主机设置)。 例如,若要选择 SMB,但将身份验证协议设置为默认的 CredSSP,请键入:
PS C:\> Set-VMHost -VirtualMachineMigrationPerformanceOption SMB
下表介绍了性能选项的工作方式。
Option | Description |
---|---|
TCP/IP | 通过 TCP/IP 连接虚拟机的内存复制到目标服务器。 |
Compression | 在通过 TCP/IP 连接将虚拟机的内存内容复制到目标服务器之前,先对虚拟机的内存内容进行压缩。 Note: This is the default setting. |
SMB | 虚拟机的内存将通过 SMB 3.0 连接复制到目标服务器。 - 当源服务器与目标服务器上的网络适配器启用了远程直接内存访问 (RDMA) 功能时,将使用 SMB 直通。 有关详细信息,请参阅通过 SMB 直通优化文件服务器的性能。 |
Next steps
设置主机后,即可执行实时迁移。 有关说明,请参阅在不使用故障转移群集的情况下使用实时迁移来移动虚拟机。