Monthly Archives: October 2013

Building a Hyper-V Cluster – Creating Virtual Machines – Part 5/5

Creating and Managing VMs

In this video we will create highly available VMs.  First we create the virtual machines in the GUI then in PowerShell.

When creating a VM, ensure that you always check the box to store the virtual machine in a different location.  If you don’t do this, then the VM’s configuration file and VHD files will be put in the Hyper-V default location.  This is bad because it will be hard to tell what VHDs are associated configuration files.  If you check the store virtual machine in a different location check box all of the VM’s components will be stored in a single folder.  This will make your management life much easier!  Also, if the VM will be part of the cluster, be sure to create and manage the VM in failover cluster manager rather than Hyper-V manager.

Store the virtual machine in a different location

PowerShell PowerShell Code

#Create a new VM
New-VM -Name JasonVM -Path c:\ClusterStorage\CSV1

#Add the VM to the cluster so it becomes highly available
Add-ClusterVirtualMachineRole -VMName JasonVM

#Start the VM and live migrate it to another cluster node
Start-ClusterGroup -Name JasonVM
Move-ClusterVirtualMachineRole -Name JasonVM

#Create and remove VM Snapshot/Checkpoints
Checkpoint-VM -Name JasonVM
Get-VM -Name JasonVM| Get-VMSnapshot
Get-VM -Name JasonVM| Get-VMSnapshot| Remove-VMSnapshot

#Shut down the VM
Stop-VM -Name JasonVM

#List the Hyper-V and Failover Clustering commands
Get-Command -Module hyper-v, failoverclusters

Resources

MSDN: Virtual Machine Live Migration Overview
TechNet:Windows PowerShell: Create Hyper-V virtual machines

Check out the other post in this series!

Building a Hyper-V Cluster – Building The Hyper-V Cluster – Part 4/5

In this video we validate our cluster node configuration and then create the cluster. Once the cluster is formed, we update the names of various cluster components to match their function. Finally we set up a CSV on the cluster.

In Server 2012R2 the cluster validation well help to ensure that the nodes in the cluster are configured identically and correctly. By passing the cluster validation and using hardware certified for 2012R2, we are ensuring our cluster will be in a supported configuration.

When we form the cluster we only need two items, the name and IP of the cluster. The name we specify will be used to create a computer account in active directory. If the using running the new-cluster command does not have rights to create computer accounts in AD the account may be prestaged. If this is done, the account should be disabled and the user should have full permission on the account.

PowerShell Command

Test-Cluster -node 2k12r2-node1,2k12r2-node2
New-Cluster -Name HVC1 -node 2k12r2-node1,2k12r2-node2 -staticAddress 192.168.0.100

#Update Cluster Network Names to Match Function
(Get-ClusterNetwork| ?{$_.Address -eq "192.168.1.0"}).name = "Managment"
(Get-ClusterNetwork| ?{$_.Address -eq "10.0.1.0"}).name = "iSCSI"
(Get-ClusterNetwork| ?{$_.Address -eq "10.0.2.0"}).name = "Cluster1"
(Get-ClusterNetwork| ?{$_.Address -eq "10.0.3.0"}).name = "Cluster2"

#Update Cluster Disk Names to Match Function
(Get-ClusterGroup -Name "Cluster group"| Get-ClusterResource |?{$_.ResourceType -eq "Physical Disk"}).name = "Witness"
(Get-ClusterGroup "available storage"| Get-ClusterResource).name = "CSV1"

#Configure the CSV
Get-ClusterResource -Name "CSV1"| Add-ClusterSharedVolume
Rename-Item -name C:\ClusterStorage\Volume1 -NewName C:\ClusterStorage\CSV1

Cluster Network Roles

In our example we did not need to change anything other than the cluster network’s name. This is because the excellent work the Windows Failover Clustering team has done on the cluster creation wizard. Automatically each cluster network will be configured with the correct cluster role and metric. These setting can be used to fine tune cluster network behavior, but in most cases are best left in default configuration.
We can use Get-ClusterNetwork to inspect the values for role and metric:
PS C:\> Get-ClusterNetwork -Cluster HVC0 | Format-Table Name, role, Metric, AutoMetric -AutoSize
Name Role Metric AutoMetric
—- —- —— ———-
Cluster1 1 30384 True
Cluster2 1 39841 True
iSCSI 0 79842 True
Management 3 79841 True

We will connect to the cluster network name using the role 3 network. The cluster networks are role 1 and will be used for cluster communications. iSCSI communication was detected on the storage network so it was created as a role 1 network, blocked for use by the cluster.

We will do a deep dive on cluster networks in another video.

Check out the other post in this series!

Building a Hyper-V Cluster – iSCSI Storage – Part 3/5

Configuring iSCSI storage for a Hyper-V Cluster

In this video we use iSCSI target server built in to Server 2012R2 to present shared storage to our cluster nodes.

Install and Configure iSCSI Target

We must first install the FS-iSCSITarget-Server feature. Once this is installed we will create a target on our storage server. Next we will create virtual disks for the witness disk and CSV. These virtual disks will be attached to the target and presented to our cluster nodes as LUNs. Finally, we will configure the target to allow access from the IQNs of our hyper-v host nodes.  We can discover the IQN of the hyper-v hosts by running the command: (Get-InitiatorPort).NodeAddress on the cluster nodes.

 PowerShell Commands

#Install target server
Install-WindowsFeature -Name FS-iSCSITarget-Server, iSCSITarget-VSS-VDS -IncludeManagementTools -Restart
#create target
New-IscsiServerTarget -TargetName HyperVCluster
New-IscsiVirtualDisk -Path c:\HVC1-W.vhdx -SizeBytes 1GB
New-IscsiVirtualDisk -Path c:\HVC1-CSV.vhdx -SizeBytes 50GB
Add-IscsiVirtualDiskTargetMapping -TargetName HyperVCluster -Path C:\HVC1-W.vhdx
Add-IscsiVirtualDiskTargetMapping -TargetName HyperVCluster -Path C:\HVC1-CSV.vhdx
#(Get-InitiatorPort).NodeAddress
#Allow nodes to access target LUNs
Set-IscsiServerTarget -TargetName HyperVCluster -InitiatorId @("IQN:iqn.1991-05.com.microsoft:2012r2-node1.demo.lcl","IQN:iqn.1991-05.com.microsoft:2012r2-node2.demo.lcl")

Connect Nodes to iSCSI Target

Once the target is created and configured, we need to attach the iSCSI initiator in each node to the storage. We will use MPIO to ensure best performance and availability of storage.  When we enable the MS DSM to claim all iSCSI LUNs we must reboot the node for the setting to take affect. MPIO is utilized by creating a persistent connection to the target for each data NIC on the target server and from all iSCSI initiator NICs on our hyper-v server.  Because our hyper-v servers are using converged networking, we only have 1 iSCSI NIC.  In our example resiliency is provided by the LBFO team we created in the last video.

PowerShell Commands

Set-Service -Name msiscsi -StartupType Automatic
Start-Service msiscsi
#reboot requres after claim
Enable-MSDSMAutomaticClaim -BusType iSCSI
Set-MSDSMGlobalDefaultLoadBalancePolicy -Policy RR
New-IscsiTargetPortal –TargetPortalAddress 192.168.1.107
$target = Get-IscsiTarget -NodeAddress *HyperVCluster*
$target| Connect-IscsiTarget -IsPersistent $true -IsMultipathEnabled $true -InitiatorPortalAddress 192.168.1.21 -TargetPortalAddress 10.0.1.10
$target| Connect-IscsiTarget -IsPersistent $true -IsMultipathEnabled $true -InitiatorPortalAddress 192.168.1.21 -TargetPortalAddress 10.0.1.11

Prepare the LUNs for use in the Cluster

Finally, once storage is available from both nodes, we must online, initialize and format the LUNs so that they will be ready for import into the cluster. This is only done from one node in the cluster as cluster disks must only ever be online on one node at a time.

 PowerShell Commands

#Prep Drives from one node
$Disk = get-disk|?{($_.size -eq 1GB) -or ($_.size -eq 50GB)}
$disk|Initialize-Disk -PartitionStyle GPT
$disk|New-Partition -UseMaximumSize -AssignDriveLetter| Format-Volume -Confirm:$false

Resources

What’s New for iSCSI Target Server in Windows Server 2012 R2
Storage Team Blog – iSCSI Target Server in Windows Server 2012 R2
Storage Team Blog – iSCSI Target Storage (VDS/VSS) Provider
iSCSI Target Cmdlets in Windows PowerShell
MultiPath I/O (MPIO) Cmdlets in Windows PowerShell
Bruce Langworthy – MSFT: Managing iSCSI Initiator connections with Windows PowerShell on Windows Server 2012

Check out the other post in this series!

Building a Hyper-V Cluster – Configuring Networks – Part 2/5

PowerShell Commands

# New Network LBFO Team
$NICname = Get-NetAdapter | %{$_.name}
New-NetLbfoTeam -Name LBFOTeam –TeamMembers $NICname -TeamingMode SwitchIndependent -LoadBalancingAlgorithm HyperVPort -Confirm:$false
# Attach new VSwitch to LBFO team
New-VMSwitch -Name HVSwitch –NetAdapterName LBFOTeam –MinimumBandwidthMode Weight –AllowManagementOS $false

# Create vNICs on VSwitch for parent OS
# Management vNIC
Add-VMNetworkAdapter –ManagementOS –Name Management –SwitchName HVSwitch
Rename-NetAdapter -Name "vEthernet (Management)" -NewName Management
#In this lab we are using one vLAN, typically each subnet gets its own vlan
#Set-VMNetworkAdapterVlan –ManagementOS –VMNetworkAdapterName Management –Access –VlanId 10
New-NetIPAddress -InterfaceAlias Management -IPAddress 192.168.0.101 -PrefixLength 24 -DefaultGateway 192.168.0.1 -Confirm:$false
#New-NetIPAddress -InterfaceAlias Management -IPAddress 192.168.0.102 -PrefixLength 24 -DefaultGateway 192.168.0.1 -Confirm:$false
Set-DnsClientServerAddress -InterfaceAlias Management -ServerAddresses 192.168.0.211, 192.168.0.212

# Cluster1 vNIC
Add-VMNetworkAdapter –ManagementOS –Name Cluster1 –SwitchName HVSwitch
Rename-NetAdapter -Name "vEthernet (Cluster1)" -NewName Cluster1
#In this lab we are using one vLAN, typically each subnet gets its own vlan
#Set-VMNetworkAdapterVlan –ManagementOS –VMNetworkAdapterName Cluster1 –Access –VlanId 2
New-NetIPAddress -InterfaceAlias Cluster1 -IPAddress 10.0.2.20 -PrefixLength 24 -Confirm:$false
#New-NetIPAddress -InterfaceAlias Cluster1 -IPAddress 10.0.2.21 -PrefixLength 24 -Confirm:$false

# Cluster2 vNIC
Add-VMNetworkAdapter –ManagementOS –Name Cluster2 –SwitchName HVSwitch
Rename-NetAdapter -Name "vEthernet (Cluster2)" -NewName Cluster2
#In this lab we are using one vLAN, typically each subnet gets its own vlan
#Set-VMNetworkAdapterVlan –ManagementOS –VMNetworkAdapterName Cluster2 –Access –VlanId 3
New-NetIPAddress -InterfaceAlias Cluster2 -IPAddress 10.0.3.20 -PrefixLength 24 -Confirm:$false
#New-NetIPAddress -InterfaceAlias Cluster2 -IPAddress 10.0.3.21 -PrefixLength 24 -Confirm:$false

# iSCSI vNIC
Add-VMNetworkAdapter –ManagementOS –Name iSCSI –SwitchName HVSwitch
Rename-NetAdapter -Name "vEthernet (iSCSI)" -NewName iSCSI
#In this lab we are using one vLAN, typically each subnet gets its own vlan
#Set-VMNetworkAdapterVlan –ManagementOS –VMNetworkAdapterName iSCSI –Access –VlanId 1
New-NetIPAddress -InterfaceAlias iSCSI -IPAddress 10.0.1.20 -PrefixLength 24 -Confirm:$false
#New-NetIPAddress -InterfaceAlias iSCSI -IPAddress 10.0.1.21 -PrefixLength 24 -Confirm:$false

Cluster Network Roles

In the video we leverage PowerShell to deploy converged networking to our Hyper-V hosts.  We have 2 physical network adapters to work with, but need to implement all of the network roles in the table below so that we will be able to deploy a cluster per best practices.  To accomplish this we create a team and attach a virtual switch.  This vSwitch is shared with the host and the VMs.  The host is given 4 vNICs on the virtual switch to accommodate the various types of network traffic (Storage, Cluster1, Cluster2, Management).  The failover cluster creation process will automatically detect iSCSI traffic on our storage network and set it for no cluster access.  It will also detect the default gateway on the management interface and set that network for cluster use and client use.  This is the network where we will create our cluster network name when the cluster is formed.  The remaining two network are non routed and are used for internal cluster communication.  Cluster communications, CSV traffic and cluster heart beat will use BOTH of these networks equally. One of the networks will be used for live migration traffic. In 2012R2 we have the option of using SMB3 for Live Migration to force the cluster to use both Cluster Only networks if we prefer that to the default compression option.  In the video we don’t care which of the cluster networks is preferred for live migration, so we simply name our networks Cluster1 and Cluster2.

We break the traffic into 4 vNICs rather than just using one because this will help us to ensure network traffic is efficiently utilizing the hardware.  By default the management vNIC will be using VMQ. Because we created the LBFO team using Hyper-V Port the vNICs will be balanced across the physical NICs in the team.  Because the networks roles are broken out into separate vNICs, we can also later apply QoS policies at the vNIC level to ensure important traffic has first access to the network.

When using converged networks, the multiple vNICs provide the ability to fine tune the quality of service for each type of traffic, while the high availability is provided by the LBFO team they are created on. If we had unlimited physical adapters, we would create a team for the Management and a separate team for VM Access Networks. We would use two adapters configured with MPIO for our storage network.  The remaining two cluster network would each be configured on a single physical adapter as failover clustering will automatically fail cluster communication between cluster networks in the event of failures.  Given you number of available physical adapters, you may choose many different possible configurations.  In doing so keep the network traffic and access requirements outlined below in mind.

Network   access type
Cluster Role Purpose of the   network access type Network traffic   requirements Recommended   network access
Storage None Access   storage through iSCSI or Fibre Channel (Fibre Channel does not need a network   adapter). High   bandwidth and low latency. Usually,   dedicated and private access. Refer to your storage vendor for guidelines.
Virtual machine access N/A Workloads   running on virtual machines usually require external network connectivity to   service client requests. Varies Public   access which could be teamed for link aggregation or to fail over the   cluster.
Management Cluster   and Client Managing   the Hyper-V management operating system. This network is used by Hyper-V   Manager or System Center Virtual Machine Manager (VMM). Low   bandwidth Public   access, which could be teamed to fail over the cluster.
Cluster and Cluster Shared Volumes (Cluster 1) Cluster   Only Preferred network used by the cluster for   communications to maintain cluster health. Also, used by Cluster Shared   Volumes to send data between owner and non-owner nodes. If storage access is   interrupted, this network is used to access the Cluster Shared Volumes or to   maintain and back up the Cluster Shared Volumes. Transfer virtual machine   memory and state. The cluster should have access to more than one network for   communication to ensure the cluster is highly available. Usually   low bandwidth and low latency. Occasionally, high bandwidth. Private   access
Live migration (Cluster 2) Cluster   Only High   bandwidth and low latency during migrations. Private   access
Table adapted from Hyper-V: Live Migration Network Configuration Guide

Resources

Networking Overview for 2012/R2
NIC Teaming Overview 2012/R2
Windows PowerShell Cmdlets for Networking 2012/R2

Check out the other post in this series!

Building a Hyper-V Cluster – Installing Roles & Features – Part 1/5

 PowerShell Commands

Install-WindowsFeature -Name Hyper-V, Multipath-IO, Failover-Clustering -IncludeManagementTools -Restart
Get-WindowsFeature|?{$_.Installed -eq $true}

Hardware Requirements

Hyper-V requires a 64-bit processor that includes the following:

  • Hardware-assisted virtualization. This is available in processors that include a virtualization option—specifically processors with Intel Virtualization Technology (Intel VT) or AMD Virtualization (AMD-V) technology.
  • Hardware-enforced Data Execution Prevention (DEP) must be available and enabled. Specifically, you must enable Intel XD bit (execute disable bit) or AMD NX bit (no execute bit).
  • SLAT (Second Level Address Translation) is recommended for performance improvements and required for RemoteFX vGPUs.

Windows Server Editions Supporting Hyper-V

VM Licenses Included
2012R2 Hyper-V Server 0
2012R2 Standard 2
2012R2 Datacenter Unlimited

Check out the other post in this series!

Building a Hyper-V Cluster – Part 0/5

In this Quick Start Series we will show you how quickly and easily you can set up your own Hyper-V Cluster using server 2012R2 and iSCSI target server for shared storage.  In each video we show you how to configure the server using the GUI and then we show how to do the same configuration steps in PowerShell.
To reproduce the environment in this video series you need:
  • 2 physical computers for Hyper-V hosts
  • 1 VM/Physical server for iSCSI target software
  • Install any Windows Server 2012R2 SKU Core/Full
  • Network connectivity with at least 1 NIC between all the systems

Hello world!

Welcome to Hyper-V Rockstar, a video blog helping you to become a Hyper-V Rockstar!

In this blog we will be covering a range of virtualization topics from quick and easy setups to deep dives.

Some of the topics we will cover:

  • Virtualization with Hyper-V
  • Failover Clustering
  • PowerShell Management
  • System Center Virtual Machine Manager (SCVMM)
  • Azure Cloud Services

Jason Ochoa
Eric DeBord