Create a two node HyperV Cluster

After trying the two node no share “Cluster” I decided to move to a more traditional cluster. Why ? First because I am curious and second because a cluster offer failover ! Basically what we need more is a shared storage, I mean a SAS, Fibre Channel or ISCSI Volumes.
Microsoft Best Practice : Each host that you want to cluster must have access to the storage array.

  • The Multipath I/O (MPIO) feature must be added on each host that will access the Fibre Channel or iSCSI storage array. You can add the MPIO feature through Server Manager. If the MPIO feature is already enabled before you add a host to VMM management, VMM will automatically enable MPIO for supported storage arrays by using the Microsoft provided Device Specific Module (DSM). If you already installed vendor-specific DSMs for supported storage arrays, and then add the host to VMM management, the vendor-specific MPIO settings will be used to communicate with those arrays.If you add a host to VMM management before you add the MPIO feature, you must add the MPIO feature, and then manually configure MPIO to add the discovered device hardware IDs. Or, you can install vendor-specific DSMs.
  • If you are using a Fibre Channel storage array network (SAN), each host must have a host bus adapter (HBA) installed, and zoning must be correctly configured. For more information, see your storage array vendor’s documentation.
  • If you are using an iSCSI SAN, make sure that iSCSI portals have been added and that the iSCSI initiator is logged into the array. Additionally, make sure that the Microsoft iSCSI Initiator Service on each host is started and set to Automatic. For more information about how to create an iSCSI session on a host when storage is managed through VMM

Source : http://technet.microsoft.com/en-us/library/gg610630.aspx

For my test lab i’ll use ISCSI storage. Unfortunatly I don’t have physical NAS or SAN so I’ll use the new ISCSI Server on Win 2012. To do so I’ll create a new server named Infra02 with a normal config (1Cpu, 1GB Ram, join domain). On my previous post I had two volume 750GB mounted on each HyperV server, I just mooved it to the new server INFRA02.

 

Storage pools : Before doing anything let’s just explain the new Storage Pool service provided in Win2012. Usually, on a server with several disks you can build a RAID unit using the physical RAID card.. But if the server doen’t provide RAID card, if you have a JBOD device connected to it, if you want to put together NAS storages (strange thing but why not), if you have different disk type and volumes or all this things then you can use the Storage Pool service proposed by Microsoft. The storage pool allow us to put together several storage unit in a logical pool. Then you can use this pool to create Virtual Disk.

So you can combine your 3 DAS storage on a server maybe with your old JBODs and a NAS array to create one or two Pool and then create several Virtual Disk that will be presented as Iscsi Volumes such as :

In my case the two 750GB volume represent two physical Direct Attached Storage (DAS). And so the INFRA02 server will allow us to build a real ISCSI storage device for the HyperV Cluster.

Ok I can create Iscsi virtual disk directly on physical disk but i repeat we are in a test environment.

First of all we need to add the Iscsi server features on INFRA02 :

add-WindowsFeature FS-iSCSITarget-Server

To build the cluster we’ll need :

  • 1 Volume for the cluster (witness disk)
  • Shared Storage for Virtual machines

So, to begin and in order to be able to run our own scripts we need to se the execution policy.

Set-executionPolicy Unrestricted
Then we need to create a Storage pool, add our disk to it and create the Virtual disks.
To do so, create a script that containing the following code (createStorage.ps1) and put it under c:scripts:

$disks = Get-PhysicalDisk –CanPool $true $storagesub = Get-StorageSubsystem New-StoragePool -FriendlyName StoragePool01 -StorageSubsystemFriendlyName $storagesub.FriendlyName -PhysicalDisks $disks $newSpace = New-VirtualDisk –StoragePoolFriendlyName StoragePool01 –FriendlyName Storage01 -Size (1500GB) -ResiliencySettingName Simple -ProvisioningType Fixed

You’ll then have one new “StoragePool01” a new disk named “Storage01”

  • In the Server manager disk view bring the disk online
  • Inittialize it
  • Create a partition using the full disk space
  • Use x: letter
  • (Script coming. One day … or not)
Then we are going to create the Iscsi target and assign the three disks to it :

New-IscsiServerTarget -TargetName FileCluster -InitiatorID IPAddress:10.0.0.10, IPAddress:10.0.0.11

#Witness Disk

New-IscsiVirtualDisk -DevicePath X:iScsiVirtualDiskswitness.VHD -Size 5GB Add-iSCSIVirtualDiskTargetMapping -TargetName FileCluster -DevicePath X:iScsiVirtualDiskswitness.VHD

#Storage disks

1..2 | % {New-IscsiVirtualDisk -DevicePath X:iScsiVirtualDisksLUN0$_.VHD -Size 700GB Add-iSCSIVirtualDiskTargetMapping -TargetName FileCluster -DevicePath X:iScsiVirtualDisksLUN0$_.VHD }

In the Iscsi target I also allow 10.0.0.10 and 10.0.0.11 to connect to the iScsi Server

Create another named script  “Connectiscsi.ps1” with:

Set-Service MSiSCSI -StartupType automatic

Start-Service MSiSCSI

New-iSCSITargetPortal -TargetPortalAddress 10.0.0.2

Get-iSCSITarget | Connect-iSCSITarget

Get-iSCSISession | Register-iSCSISession

Execute the script remotely on both servers with :

1::2 | % {Invoke-Command -ComputerName Hyperv0$_ -FilePath “C:scriptConnectiscsi.ps1” }

So far our Storage is on the network and our two HyperV hosts can access it !

Now we can configure the cluster.
On our management server (INFRA01 for me) run the following command to install the Clustering Remote Server Administration Tool:

add-WindowsFeature RSAT-Clustering

Run the following command to install failover clustering feature on each HyperV server :

1..2 | % {Invoke-Command -ComputerName Hyperv0$_ -scriptblock {add-windowsFeature Failover-Clustering} }

From one Hyperv host open the Server manager disk view and :

  • Bring the disk online
  • Inittialize it
  • Create a partition using the full disk space
  • Do not assign letter
  • (Script coming. One day … or not)

Add a new network adapter to each HyperV server and configure it to be : Hyperv01 : 10.0.1.1 /24 Hyperv02 : 10.0.1.2 /24 This network directly link the two hyperv server and will be use to simulate a redunduncy network.

Here we go ! We now have two hosts linked by two networks and each host is connected to 3 iScsi Volumes (1 for witness and 2 for storage). We now have all pre-requisite to build the cluster.

To check if everything is ok you can (should) run a cluster validation test

If you don’t have error and manage warnings then you can create your cluster :

New-Cluster -Name Cluster01 -Node hyperv01,hyperv02 –StaticAddress 10.0.1.3, 10.0.0.3 -noStorage

Then we’ll need to add all available storage to the cluster :

Get-ClusterAvailableStorage Cluster01 | add-ClusterDisk

Configure Cluster Quorum :

Set-ClusterQuorum -NodeAndDiskMajority “Cluster Disk 2” -Cluster Cluster01

Add the two other disk to be Cluster Shared Volumes

Add-ClusterSharedVolume “Cluster Disk1″,”Cluster Disk 3” -Cluster Cluster01

This two shared volumes are now under both hyperv server :

C:ClusterStorage

We can therefore re-configure HyperV to use C:ClusterStorageVolume1 to be the default storage location :

1..2 | % {Invoke-Command -ComputerName Hyperv0$_ -scriptblock {set-VMHost –VirtualHardDiskPath C:ClusterStorageVolume1VHD –VirtualMachinePath C:ClusterStorageVolume1VM} }

To test the failover cluster :

Create a test VirtualMachine :

New-VM VM01 -Memory 1GB -ComputerName Hyperv01

Add-ClusterVirtualMachineRole -VirtualMachine -VM01 -name VM01 -Cluster Cluster01

Start-vm VM01 -ComputerName Hyperv01

Cut the network on Hyperv01 and see if the VM shut down and reboot on Hyperv02 !

In my next post I’ll come with more VM creation options and powershell code.

Enjoy

Leave a Reply

Your email address will not be published. Required fields are marked *