Migrating Your Virtual Machines to Windows Server 2012 R2 Hyper-V
06/01/2015 Leave a comment
And then comes the time to migrate your old servers with Windows Server 2012 to Windows Server 2012 R2 Hyper-V with all the joys and headaches of upgrading your old servers. In most environments nowadays, the only physical servers are the virtualization hosts, which makes the migration very important. Microsoft made the migration much easier in the new Hyper-V version, where we can simply move virtual machines from a Windows Server 2012 host to a Windows Server 2012 R2, without any downtime and as simple as a normal Live Migration of virtual machines. Actually, that’s how the migration can be done, by simple doing a Shared Nothing Live Migration in your virtual machines to the new host.
There are other options to migrate VMs in offline mode by exporting them. Another interesting feature available in Windows Server 2012 R2 is the option to export a running VM. Given the VM is still running during the exporting process and being changed, this is not an option for migration, but it’s perfect if you want to duplicate your virtual servers or troubleshoot a problem.
In this recipe you will see how to migrate your virtual machines without downtime to a new Windows Server 2012 R2 using Live Migration and the offline migration exporting VMs to the new server.
To migrate your virtual machines using Shared Nothing Live Migration, make sure the source and destination servers are on the same network. You will also improve the migration if you create a dedicated network to be used for migrations only.
To export and import your virtual machines, you will need available storage on the local server or a shared folder on the network.
You will now see how to migrate a virtual machine using Shared Nothing Live Migration from Windows Server 2012 to Windows Server 2012 R2 and how to export and import a virtual machine.
1. To enable Live Migrations on the destination server with Windows Server 2012 R2, open Hyper-V Manager and click on Hyper-V Settings on the right column.
2. In Hyper-V Settings, click on Live Migrations and select the Enable incoming and outgoing live migrations checkbox.
3. Under Simultaneous live migrations, specify the number of concurrent live migrations that will be allowed.
4. In Incoming live migrations, specify a particular network for live migration by selecting Use these IP addresses for live migration or select Use any available network for live migration to use any local network adapter available to move the VMs. The following screenshot shows an example of the existing options described in the previous steps. When finished, click OK.
5. Expand Live Migrations in the left pane and click on Advanced Features.
6. Under Authentication protocol, select Use Credential Security Support Provider (CredSSP) or Use Kerberos.
7. Under Performance options, select between TCP/IP, Compression or SMB and click OK, as shown in the next screenshot.
8. To move your virtual machine using Shared Nothing Live Migration, from the Windows Server 2012 host, open Hyper-V Manager, right click on the VM you want to move and select Move.
9. In the Before You Begin page, click on Next.
10. In the Choose Move Type window, select Move the Virtual Machine, as shown in the following screenshot and click Next.
11. In Specify Destination Computer, type the Windows Server 2012 R2 host that you want to move your VM and click Next.
12. In Choose Move Options, select Move the virtual machine’s data to a single location to move all configuration files and virtual disks to the same location, Move the virtual machine’s data by selecting where to move the items to select the location of each item to be moved or Move only the virtual machine to move the VM only and keep the VHD files on the same location and click Next, as shown in the following screenshot.
13. In Choose a new location for virtual machine, select the destination folder where the VM will be moved and click Next.
14. In the Summary page, verify the selected options and click Finish to start the moving process. Wait until the completion and check the virtual machine on the destination host.
15. The other option to migrate VMs is the Export feature. To export a virtual machine to another server, open the Start screen, and select Hyper-V Manager.
16. Select the virtual machines you want to export, right click on them, and select Export, as you can see in the following screenshot:
17. In the Export Virtual Machine window, enter the path you want to export the virtual machines to and click on Export.
18. Copy the exported virtual machine files to the destination host.
Note: You can also import and export VMs using the PowerShell commands Import-VM and Export-VM respectively. For more information, open PowerShell and type Help Import-VM for import and Help Export-VM for export.
19. Open Hyper-V Manager on the destination host and select Import Virtual Machine from the right pane.
20. In the Before You Begin screen click on Next.
21. In the Locate Folder screen, specify the folder with the virtual machine files you want to import and click Next.
22. In the Select Virtual Machine window, select the virtual machines to be imported and click Next.
23. In the Choose Import Type window, select the type of import, as shown in the next screenshot, and click Next.
24. If the source virtual machine has different virtual switches attached to it or different configuration that the destination host will not support, new windows can be displayed asking you to address the problem. The next screenshot shows an example of a VM with a different virtual switch name. Address all problems or conflicts that the VM may have and click Next.
25. If prompted, specify the folders to store the virtual machine files and disks and click Next.
26. Click on Finish when it is done and you will see the imported virtual machine in the Hyper-V console.
As described during the steps, there are two options to migrate your virtual machines to a new server. The first one, which is using Shared Nothing Live Migration, allows you to move your VM without any downtime, but it requires the source host to be Windows Server 2012. With the second option, you can move VMs from any Hyper-V version, but it’s an offline method.
Starting with the Export/Import option, the process to export the Virtual Machine collects its entire configuration file, snapshots, the Virtual Hard Drive and puts all of them together within a new folder with the virtual machine name in the specified path during the export process. It’s also possible to select more than one virtual machine and export in just one go in case you are migrating from old Hyper-V versions.
Note: Since Windows Server 2012 a VM can be imported without requiring the export process. You can copy all the virtual machine files to a new host and during the importation, you just need to select the VM configuration file (xml) and continue the steps as shown above.
Windows Server 2012 R2 also introduces a new option to export VMs that are running, but this option is not recommended for migration purpose, given the VM is still being updated during the export process, however it’s very handy to copy your VMs into a lab or just for troubleshooting.
During the wizard, you specify the folders where the virtual machine files sit. It doesn’t matter if the virtual machines were exported or not. You can simply copy and paste the VM files and the result will be the same.
After that, the wizard shows a list of virtual machines you want to import. The good news here is that Hyper-V list the VMs per name and not using the Global Unique Identifier (GUID) as previous versions. It makes the process even easier.
The wizard provides three different types of import. The first one Register the virtual machine in-place (use the existing unique ID) assumes that all files of the imported VM are in a single place and just register the VM. It can be used to register VMs in a new host using the same VM path. The second one, Restore the virtual machine (use the existing unique ID) is almost the same as the previous option, but it allows you to specify the VM files path and it copy the files to the new destination path. The last option Copy the virtual machine (create a new unique ID) create new VMs with new IDs and can be very helpful when you just want to use the VM files as a template to create new VMs.
Another problem from previous versions of Hyper-V is when the VM has different configurations in the source host. For example, if the VM has a different virtual switch or a hardware setting that is not present in the destination host the import process would fail. Now the import is clever enough to identify whether the VM has conflicted or different settings. Memory, processor, disk, networks and file paths are checked and in case of problems the wizard will prompt you to changed based on the destination limits and configuration.
When finished, your virtual machine will be ready to be started on the new server, making your migration much simpler.
The first option used in this recipe was Shared Nothing Live Migration that has an easy and intuitive wizard to move your VMs across your host servers. Although the article described how to move a VM from a single host with Windows Server 2012 to a new host with Windows Server 2012 R2, you can still do the same process within a cluster as well.
Different of Storage Migration, by default live migrations are disabled on Hyper-V. To enable it you must specify some options such as authentication protocol, simultaneous live migration and incoming live migration.
The first configuration, authentication protocol, let you choose two options to specify the way Hyper-V will authenticate to start the live migrations. By selecting Credential Security Support Provider (CredSSP) you can live migrate virtual machines only if you are logged on to the source computer to start it so that CredSSP can be used to authenticate the migration. This option doesn’t require any pre-requisites, but you will not be allowed to perform a live migration using other remote management tools like Hyper-V Manager from another server or PowerShell sessions. The migration will be initiated only when you are logged on the source server.
If you also want to start live migrations using these remote management tools you can select to use Kerberos for authentication. When starting a live migration, either locally on the server or remotely, a constrained delegation will be used to authenticate and start the migration. This is the best option due the flexibility to start the migration also from remote tools, but it requires pre-configuration in Active Directory. Kerberos authentication will be demonstrated at the end of the article.
The next option provides a field to specify the number of simultaneous live migrations that Hyper-V will support. In this option the only limit is the hardware and the network connection between the servers.
The Incoming live migrations option allows you to configure which network will be used for live migrations. For better performance and resilience is recommended to use a specific network for live migration, but if you have only one network adapter on the host computer or doesn’t have a particular adapter for live migration you can also use any available network. After enabling live migrations and setting up these three options you are ready to move your VMs.
Under Performance options, there are three new options available. TCP/IP will move the VM memory over a TCP/IP Connection, Compression can compress the VM memory before copying the VM to the new server using TCP/IP connection and SMB copies the VM memory through a SMB connection, which can use Remote Direct memory Access (RDMA) if both servers support it.
The wizard is launched with a simple right click on the VM. Shared Nothing Live Migration and Storage Migration use the same wizard, which improves the user experience and reduce the number of windows and options on Hyper-V. The first window, Choose Move Type, has the Shared Nothing Live Migration option (Move the virtual Machine) and the Storage Migration option (Move the virtual machine’s storage). After selecting to move the VM and specifying the destination server where the VM will be moved, you can select one of the three move options to move VMs to a single location, select different locations per VM item or move only the VM. The option to move only the VM works when you are storing the VM in a shared folder on the network or any other type of shared storage.
When the migration starts, Hyper-V authenticates the connection on the destination host and starts the process by migrating the VM disks. After moving all disk data, it migrates the virtual machine memory.
When finished, your VM will be up and running on the destination host and all the migration process happens with no downtime.
Enabling Live Migration and Migrating VMs using PowerShell
The PowerShell commandlet to move a VM can be considered one of the easiest one on Hyper-V due all process that happens with just one line of command. The whole configuration and migration process described in this article can be automated using PowerShell.
To enable live migrations of virtual machines, type the following command line:
Enable-VMMigration | Set-VMMigrationNetwork Any | Set-VMHost –VirtualMachineMigrationAuthenticationType CredSSP
You can also change the migration network from any to a specific network by adding the IP address or the authentication type by changing CredSSP to Kerberos.
After enabled, to move VMs, type the following commandlet. On this example, a VM called SYD-FS1 will be moved to de server HVHost02 and the storage will be located on D:\Hyper-V. For more information about Move-VM, type Help Move-VM.
Move-VM SYD-FS1 HVHost02 –IncludeStorage –DestinationStoragePath D:\Hyper-V\
Configure Constrained Delegation to Authenticate Live Migrations
Constrained delegation allows live migrations to be started using any remote management tool and might help, providing more flexibility to move your VMs.
To enable it, open Active Directory Users and Computers from one of the Domain Controllers where the host servers sit, right click on the host computer account and click Properties. In the Properties window, click on the Delegation tab, select Trust this computer for delegation to the specified services only and select Use Kerberos, as shown in the next screenshot.
Click Add and then Users or Computers. In the Select Users or Computers box, type the destination host server name and click OK.
In the Add Services dialog box, select cifs and Microsoft Virtual System Migration Service and click OK. The two services will be listed in the service type as shown in the next screenshot as well.
Click Ok to close the computer properties window and repeat the same process on the destination server computer account.
After that you can change the live migration authentication type to use Kerberos.
That’s all guys, hope this help in some way.