18 September 2013

Building Hyper-V clusters Step by Step - Part I - The most basic

This series of articles will go through various way on how to build a Hyper-V clusters.  This can mean a lot of things but the generally idea is to have two or more Hyper-V host servers that can host high availability virtual machines.

Design Goals

  • Two node Hyper-V cluster
  • Using only SMB 3.0 as shared storage
  • Using only single NIC per server
  • Using DHCP
  • No SCVMM

Cluster nodes: HV01 and HV02
Management and Fileshare Server HV03

All machines need to be joined to the same domain.

Build process
All build steps can and should be performed from the management server. Personally I like to run everything from the PowerShell ISE

All the PowerShell commands are formatted in courier

Step 1 Install required roles on the servers

The nodes needs:

  • Hyper-V
  • Failover Clustering
  • Hyper-V Management Tools
  • Failover Clustering Management Tools

Invoke-Command -computername HV01, HV02 {Install-WindowsFeature RSAT-Hyper-V-Tools, RSAT-Clustering, Failover-Clustering, hyper-v -Restart}

The role installation will reboot the server and may take a few minutes.

The Management Server needs

  • Hyper-V Management Tools
  • Failover Clustering Management Tools

Install-WindowsFeature RSAT-Hyper-V-Tools, RSAT-Clustering

Step 2 Create virtual switches
The nodes need to have identical configurations, including the virtual switches.  This build is very simple from a network perspective.  Each node has a single network adapter.  We will need to create the virtual switch and allow access to the management OS

Start a PSSession to each node and follow these steps

Enter-PSSession HV01

Identify the adapter name you want to use (in this case Ethernet 3)

New-VMSwitch -Name "External" -NetAdapterName "Ethernet 3" -AllowManagementOS:$true 

Step 3 Create the cluster
Since we need the cluster Active Directory object to provisions the SMB shares we need to perform this step first.

This will create a cluster called HVC01 and will use DHCP to assign a cluster VIP

New-Cluster -Name HVC01 -Node HV01, HV02 

If this fails you can run a validation check to see if any errors show up

Test-Cluster -Node  HV01, HV02 

Step 4 Create the SMB 3.0 Fileshares
In this build the Management Server will also be the SMB 3.0 file share host.  For a cluster we will create two shares.  The one will be for the Cluster Quorum Witness, the other for storing virtual machines. The shares are identical and as such you can use the same commands, just change the path.

The commands below create the folder, then shares the folder granting full access to Everyone, lastly it sets the NTFS permissions to also allow full control to the nodes and the cluster machine accounts.

$Folder = "D:\VMFOLDER"
$ShareName = "VMFOLDER"
$MachineAccounts = "domain\hv01$","domain\hv02$","domain\hvc01"

New-Item -Path $folder -ItemType directory
New-SmbShare -Name $ShareName -Path $Folder -FullAccess Everyone

$MachineAccounts | ForEach-Object {
$Acl = Get-Acl $Folder
$Ar = New-Object  system.security.accesscontrol.filesystemaccessrule($_,"FullControl","ContainerInherit,ObjectInherit","none","Allow")
Set-Acl $Folder $Acl

At this point you should have a cluster that is up and running.  

Step 5 Configure the Quorum
In SMB only cluster you can make use of a file share to act as the Quorum.

Set-ClusterQuorum –Cluster HVC01 –NodeAndFileShareMajority \\hv03\VMWitness 

Step 6 Adding Virtual Machines
Since you now have a cluster the process of adding or creating a virtual machine is a little different.  Instead of using the Hyper-V management console you will be using the Failover Cluster Manager 

  • Connect to cluster
  • Select Roles
  • Right Click - Virtual machine - New Virtual Machine
  • Select any of the nodes
  • In the Specify Name and location Screen - specify the Fileshare created earlier
  • Complete the wizard as normal.
  • There will be a cluster validation notice that the object was created correctly

You can now start the virtual machine and fail it over between the hosts by selecting Move - Live Migration - Select Node

This is a very simple build and all of the build steps are performed in PowerShell, as such this build doc will work for Windows Server with GUI, Windows Server Core and Hyper-V server.

Check out Part II 

No comments:

Post a Comment