This article is Part 4 in a series of articles of the "Top 31 Favorite Features in Windows Server 2012" with my fellow IT Pro Technical Evangelists. Be sure to follow them on Twitter and check out their blogs this month for the other parts of this series:
Woohoo! Applause! ... Wait! You say that Windows Server 2008 R2 also had Live Migration? Well, hmm ... you're absolutely correct! BUT, in Windows Server 2012, Live Migration of Virtual Machines has been dramatically enhanced to support several new capabilities. Two of my most favorite new Live Migration capabilities are:
First, a few quick definitions ...
In fact, the Hyper-V "hosts" in this scenario can be Windows Server 2012 or the FREE Hyper-V Server 2012! Yes, that's right - we can now Live Migrate running VM's to/from:
As you think about the full lifecycle of VMs in your environment - from development to pilot to production - you'll begin to appreciate the flexibility this can provide in terms of being able to easily move VMs between appropriate hardware platforms for each stage of the lifecycle with no-fuss or reconfiguration.
To enable Shared Nothing Live Migration, use Hyper-V Manager to set the following properties in the Hyper-V Settings of each host:
If you selected "Kerberos" as your authentication protocol above, you'll also need to setup constrained delegation in Active Directory for each Hyper-V host. To do this, launch the Active Directory Users & Computers tool and modify the following properties in the computer object of each Hyper-V host:
Easy! Once you've configured Live Migration for each Hyper-V host, you can quickly Live Migrate selected Virtual Machines by using Hyper-V Manager.
Right-o ... back to the topic of this article! When we configured Live Migration above, we saw that we could specify the maximum number of simultaneous Live Migrations to/from each Hyper-V host. This comes in really useful if you have busy Hyper-V hosts with many running VMs and you find that you need to quickly evacuate all VMs from one host to perform hardware maintenance or upgrades. However, as a GUI management tool, Hyper-V Manager can be used to only Live Migrate one VM at-a-time between hosts interactively. If we want to Live Migrate multiple VM's simultaneously, we can use ... drum roll, please ... PowerShell 3.0!
NOTE: If you're looking for a full Enterprise GUI management solution that can build Private Clouds, Live Migrate multiple VM's concurrently, and a whole lot more, be sure to check out System Center 2012. However, PowerShell 3.0 is included with Windows Server 2012 and, as such, provides a scripted solution for no additional cost!
In Windows Server 2012, PowerShell 3.0 provides over 2,400 cmdlets to script and automate nearly every aspect of the underlying OS. When it comes to Hyper-V automation, PowerShell is no stranger - there's 163 PowerShell Cmdlets for Hyper-V alone! :-) To perform a batch Live Migration of multiple VMs, we'll leverage three PowerShell Cmdlets to quickly get the job done:
The resulting single line of PowerShell 3.0 code looks like this:
Get-VM -ComputerName SOURCE_HOST | Out-GridView -Title "Select one or more VMs to Live Migrate" -PassThru | Move-VM -DestinationHost DEST_HOST -DestinationStoragePath DRIVE:\FOLDER
Using the Out-Grid Cmdlet, we are presented with a list of VM's from which to select, and when we click the OK button, the Move-VM Cmdlet performs the Live Migrations in sequence.
As cool as the above single line of PowerShell 3.0 code is, it falls just a little short of what we ultimately wanted to accomplish ... each Live Migration operation occurs above, but they occur in sequence one-after-the-other, instead of simultaneously like we really wanted. To run the Live Migrations simultaneously, we can use another new feature in PowerShell 3.0 - Workflows with Parallel execution!
OK - I know, I know ... this sounds like a Developer topic, but it really is EASY in PowerShell 3.0. All we need to do is create a custom workflow that runs a ForEach loop with the -Parallel parameter. Here's the PowerShell 3.0 code that we need to create the workflow:
ForEach -Parallel ($VM in $VMList)
Move-VM -ComputerName $SourceHost -Name $VM -DestinationHost $DestHost -DestinationStoragePath $DestPath
Once this code is run, the custom workflow will be created and "Invoke-ParallelLiveMigrate" can be called like any other PowerShell Cmdlet. This workflow accepts four mandatory parameters for VMList, SourceHost, DestHost and DestPath. To use this custom workflow to perform true simultaneous Live Migrations, we just need to grab the list of selected VMs into an object variable and then run our new custom workflow. Here's an example of the code:
$VMList = Get-VM -ComputerName SOURCE_HOST | Out-GridView -Title "Select one or more VMs to Live Migrate" -PassThru
Invoke-ParallelLiveMigrate -VMList $VMList.Name -SourceHost SOURCE_HOST -DestHost DEST_HOST -DestPath DRIVE:\FOLDER
And ... that's it! See? I told you it was EASY with PowerShell 3.0 and Windows Server 2012! ;-)
Here's some great resources that you may wish to leverage to continue your learning:
Be sure to check back daily for our next round of Favorite Features in Windows Server 2012!
Be sure to check out these additional resources:
Keith Mayer is a Senior Technical Architect at Microsoft, focused on helping ISV partners leverage the Azure cloud platform. Keith has over 20 years of experience as a technical leader of complex IT projects, in diverse roles, such as Network Engineer, IT Manager, Technical Instructor and Consultant. He has consulted and trained thousands of customers and partners worldwide on design of enterprise technology solutions.
Keith is currently certified on several Microsoft technologies, including Azure, Private Cloud, System Center, Hyper-V, Windows, Windows Server, SharePoint, SQL Server and Exchange. He also holds other industry certifications from VMware, IBM, Cisco, Citrix, HP, CheckPoint, CompTIA and Interwoven.
You can contact Keith online at http://aka.ms/AskKeith.