You dont have javascript enabled! Please enable it!

Simultaneous Shared-Nothing Live Migration with PowerShell

3 Min. Read

In this article, we will show you how to use simultaneous shared-nothing live migration with PowerShell.

Live migration is a Hyper-V feature in Windows Server. It allows you to transparently move running Virtual Machines from one Hyper-V host to another without perceived downtime. The primary benefit of live migration is flexibility; running Virtual Machines is not tied to a single host machine. This allows actions like draining a specific host of Virtual Machines before decommissioning or upgrading it. When paired with Windows Failover Clustering, live migration allows the creation of highly available and fault-tolerant systems.

Introduction

As you know Microsoft introduced Shared-Nothing Live Migration back in Windows Server 2012 Hyper-V.

For those who are new to this feature, shared-nothing live migration allows an administrator to move a running Virtual Machine from Host A to Host B, and optionally it’s storage with just an Ethernet cable without the need to have any shared storage, this is awesome!!!

The requirements for enabling Shared-Nothing Live Migration are fairly simple:

1) You need a minimum of two Server 2012 R2 installations or later with the Hyper-V role enabled or free Microsoft Hyper-V Server.

2) Each server must have access to its own location to store VMs. This location can be local or SAN-attached storage or a Server Message Block (SMB) 3.0 share.

3) Servers must have the same type or family of processors (Intel or AMD) if you’re using the VM’s Processor Compatibility feature.

4) Servers must be part of the same Active Directory domain.

5) Servers must be connected by at least a 1Gbps connection (a separate private network for live migration traffic is recommended but not necessary), over which the two servers can communicate.

6) Each Hyper-V server should have the same virtual switches defined with the same name, to avoid errors and manual steps when performing the migration, by leveraging the usage of Ethernet Resource Pool you can live migrate without worry about different virtual switch names.

7) VMs that are being migrated must not use pass-through disks.

Let’s assume you meet the above requirements, the next step is to enable the Hyper-V hosts for incoming and outgoing live migrations and you are good, but don’t forget the authentication stuff (CredSSP or Kerberos) since we will not cover these here as they are beyond the scope of this post.

More information about Shared-Nothing Live Migration can be found here.

If we need to move a VM from host A to host B, how can we accomplish this??? fairly simple using the Hyper-V Manager console.

Right-click and move…

SN-LM01

Shared Nothing Live Migration with PowerShell

The PowerShell cmdlet to move a VM can be considered one of the easiest options on Hyper-V because the entire process is just one line of command:

Move-VM –Name VM01 –IncludeStorage –DestinationHost HVSRV02 –DestinationStoragePath D:\Hyper-V\

Let’s assume you need to evacuate all Virtual Machines from one host to another as early as possible.

Unfortunately, there is no such way to do this using the UI, you need to select one VM at a time and then move it to the second node.

Live Migrate Multiple Virtual Machines Simultaneously

PowerShell is the answer…

<#
Author: Charbel Nemnom
Website: https://charbelnemnom.com
Date created: 23-December-2013
Last modified: 30-May-2015
Version: 1.2
#>

Read-host "`nPress [enter] to Start"

Workflow Invoke-ParallelLiveMigration

{

Param (

[Parameter(Mandatory=$true)] [string] $SourceHostName,

[Parameter(Mandatory=$true)] [string] $DestinationHostName,

[Parameter(Mandatory=$true)] [string] $DestinationStoragePath

)

$VMNames = Get-VM -ComputerName $SourceHostName | Select VMName

ForEach -Parallel ($VirtualMachine in $VMNames)

{

Move-VM -Name $VirtualMachine.VMName  –ComputerName $SourceHostName –IncludeStorage –DestinationHost $DestinationHostName –DestinationStoragePath $DestinationStoragePath

}

}

Invoke-ParallelLiveMigration

Read-Host "`nPress enter to Exit"

SN-LM02

SN-LM03

One important note to mention: when you enable Hyper-V hosts for incoming and outgoing live migrations, the default simultaneous migrations are set to 2 by default, you need to maximize that number to meet your requirements, and there is no one stopping you from configuring 100 simultaneous live migrations.

When you have only one, two, or even four 1Gbps NICs available, but you might stick to 2 or 4 migrations per available 1Gbps, why limit yourself if you have one or multiple 10Gbps, 40Gbps, or even 56Gbps, sure enough, bigger pipes are better than smaller ones but your CEO/CIO will be happy paying more $$$.

Learn more

Make sure to check my recent Windows Server Hyper-V Cookbook for in-depth details about Hyper-V!

Until then, enjoy your day!

Cheers,
/Charbel

Related Posts

Previous

Windows Server 2012 R2 Server Virtualization Technical Overview White Paper

Cannot copy files into VM with Allow Enhanced Session Mode in Hyper-V 2012 R2

Next

Let me know what you think, or ask a question...

error: Alert: The content of this website is copyrighted from being plagiarized! You can copy from the 'Code Blocks' in 'Black' by selecting the Code. Thank You!