Perform Multiple Parallel Live Migrations of Virtual Machines Across Hyper-V Host using New Workflow Feature in PowerShell V3

Perform Multiple Parallel Live Migrations of Virtual Machines Across Hyper-V Host using New Workflow Feature in PowerShell V3
Here’s my part 2 of blog on how you can use PowerShell Workflow in PowerShell v3 to perform Multiple Parallel Live Migrations of Virtual Machines Across Hyper-V Host.This was part 2 of my presentation i took at the PSBUG eventIf you missed my part 1 here’s the link which shows Parallel Provision of Virtual Machines

http://www.vinithmenon.com/2013/06/provision-virtual-machines-in-parallel.html

Here’s a little overview on Live Migration.

  • Live Migrations are widely used in production environment during Patch Tuesday’s when Microsoft release several series of updates for their products.
  • It is widely used for Hyper-V Host patching to move around resources across Hosts while ensuring almost zero downtime.
  • Hyper-V live migration moves running virtual machines from one physical server to another with no impact on virtual machine availability to users. By pre-copying the memory of the migrating virtual machine to the destination server, live migration minimizes the transfer time of the virtual machine.
  • A live migration is deterministic, which means that the administrator, or script, that initiates the live migration determines which computer is used as the destination for the live migration. The guest operating system of the migrating virtual machine is not aware that the migration is happening, so no special configuration for the guest operating system is needed

 

Live migration of virtual machines is a key Hyper-V feature in Windows Server 2008 R2.
Hyper-V in Windows Server 2012 introduces the following live migration improvements:
Faster and simultaneous migration. Live migrations are now able to utilize higher network bandwidths (up to 10 Gigabit) to complete migrations faster. You can also perform multiple simultaneous live migrations to enable you to move many virtual machines in a cluster quickly. These changes allow you to implement high levels of mobility and flexibility in private cloud solutions.
Here’s the PowerShell Workflow Script which does this awesome stuff.
workflow Move-LiveVM

{

param(
[Parameter(Mandatory)]
[string]$SourceHyperVhost,
[Parameter(Mandatory)]
[string]$DestinationHyperVhost,
[Parameter(Mandatory)]
[string]$ClusterName

)


$vminfo = Get-ClusterGroup -cluster $clustername | Where-Object -filterscript  {$_.grouptype -match "VirtualMachine" -and $_.ownernode -match $SourceHyperVhost} 


Foreach -parallel  ($vm in $vminfo)
{

Move-ClusterVirtualMachineRole $vm -Node $DestinationHyperVhost -MigrationType live  -Cluster $clustername

}

}

Also note that i can specify which kind of Migration should be used to move around VM’s, here’s a snap for the same from the new ise which auto-completes with intelligence.

 

Below you can see that i invoked this workflow in my Powershell ISE and it invokes Multiple Live Migrations in parallel.

Move-LiveVM -SourceHyperVhost HyperV1 -DestinationHyperVhost HyperV2 -ClusterName sarcinfracluster


Here’s a view of My VM migration in process in FCM.

Hope these set of posts helped you out in your datacenter automation.

Share this post

Post Comment