PowerShell Script To Create A Converged Fabric For Clustered Windows Server 2012 Hyper-V Host

Note: This post was originally written using the Windows Server “8” (aka 2012) Beta.  The PowerShell cmdlets have changed in the Release Candidate and this code has been corrected to suit it.

After the posts of the last few weeks, I thought I’d share a script that I am using to build a converged fabric hosts in the lab.  Some notes:

  1. You have installed Windows Server 2012 on the machine.
  2. You are either on the console or using something like iLO/DRAC to get KVM access.
  3. All NICs on the host will be used for the converged fabric.  You can tweak this.
  4. This will not create a virtual NIC in the management OS (parent partition or host OS).
  5. You will make a different copy of the script for each host in the cluster to change the IPs.
  6. You could strip out all but the Host-Parent NIC to create converged fabric for standalone host with 2 or 4 * 1 GbE NICs

And finally …. MSFT has not published best practices yet.  This is still a beta release.  Please verify that you are following best practices before you use this script.

OK…. here we go.  Watch out for the line breaks if you copy & paste:

write-host “Creating virtual switch with QoS enabled”
New-VMSwitch “ConvergedNetSwitch” -MinimumBandwidthMode weight -NetAdapterName “ConvergedNetTeam” -AllowManagementOS 0

write-host “Setting default QoS policy”
Set-VMSwitch “ConvergedNetSwitch” -DefaultFlowMinimumBandwidthWeight 10

write-host “Creating virtual NICs for the management OS”
Add-VMNetworkAdapter -ManagementOS -Name “Host-Parent” -SwitchName “ConvergedNetSwitch”
Set-VMNetworkAdapter -ManagementOS -Name “Host-Parent” -MinimumBandwidthWeight 10

Add-VMNetworkAdapter -ManagementOS -Name “Host-Cluster” -SwitchName “ConvergedNetSwitch”
Set-VMNetworkAdapter -ManagementOS -Name “Host-Cluster” -MinimumBandwidthWeight 10

Add-VMNetworkAdapter -ManagementOS -Name “Host-LiveMigration” -SwitchName “ConvergedNetSwitch”
Set-VMNetworkAdapter -ManagementOS -Name “Host-LiveMigration” -MinimumBandwidthWeight 10

Add-VMNetworkAdapter -ManagementOS -Name “Host-iSCSI1” -SwitchName “ConvergedNetSwitch”
Set-VMNetworkAdapter -ManagementOS -Name “Host-iSCSI1” -MinimumBandwidthWeight 10

#Add-VMNetworkAdapter -ManagementOS -Name “Host-iSCSI2” -SwitchName “ConvergedNetSwitch”
#Set-VMNetworkAdapter -ManagementOS -Name “Host-iSCSI2” -MinimumBandwidthWeight 15

write-host “Waiting 30 seconds for virtual devices to initialise”
Start-Sleep -s 30

write-host “Configuring IPv4 addresses for the management OS virtual NICs”
New-NetIPAddress -InterfaceAlias “vEthernet (Host-Parent)” -IPAddress 192.168.1.51 -PrefixLength 24 -DefaultGateway 192.168.1.1
Set-DnsClientServerAddress -InterfaceAlias “vEthernet (Host-Parent)” -ServerAddresses “192.168.1.40”

New-NetIPAddress -InterfaceAlias “vEthernet (Host-Cluster)” -IPAddress 172.16.1.1 -PrefixLength “24”

New-NetIPAddress -InterfaceAlias “vEthernet (Host-LiveMigration)” -IPAddress 172.16.2.1 -PrefixLength “24”

New-NetIPAddress -InterfaceAlias “vEthernet (Host-iSCSI1)” -IPAddress 10.0.1.55 -PrefixLength “24”

#New-NetIPAddress -InterfaceAlias “vEthernet (Host-iSCSI2)” -IPAddress 10.0.1.56 -PrefixLength “24”

That will set up the following architecture:

image

QoS is set up as follows:

  • The default (unspecified links) is 10% minimum
  • Parent: 10%
  • Cluster: 10%
  • Live Migration: 20%

My lab has a single VLAN network.  In production, you should have VLANs and trunk the physical switch ports.  Then (I believe), you’ll need to add a line for each virtual NIC in the management OS (host) to specify the right VLAN (I’ve not tested this line yet on the RC release of WS2012 – watch out for teh VMNetowrkAdaptername parameter):

Set-VMNetworkAdapterVLAN –ManagementOS –VMNetworkAdapterName “vEthernet (Host-Parent)” –Trunk –AllowedVLANList 101

Now you have all the cluster connections you need, with NIC teaming, using maybe 2 * 10 GbE, 4 * 1 GbE, or maybe even 4 * 10 GbE if you’re lucky.

Another Reason To Use Converged Fabrics – Abstract The Host Configuration

Assuming that you converge all fabrics (including iSCSI and that may require DCB for NICs and physical switches) then my recent work in the lab has found me another reason to like converged fabrics, beyond using fewer NICs.

If I am binding roles (parent, live migration, etc) to physical NICs then any host networking configuration scripts that I write must determine what NIC is correct.  That would not be easy and would be subject to human cabling error, especially if hardware configurations change.

If however, I bind all my NICs into a team, and then build a converged fabric on that team, I have completely abstracted the physical networks from the logical connections.  Virtual management OS NICs and trunking/VLAN bindings mean I don’t care any more … I just need 2 or 4 NICs in my team and connected to my switch.

Now that physical bindings don’t matter, I have simplified my configuration and I can script my depoyments and configuration to my heart’s content!

The only question that remains … do I really converge my iSCSI connections?  More to come …

Windows Server 2012 Hyper-V Converged Fabrics & Remote Host Engineering

My lesson from the lab is this …  If you are implementing WS2012 Hyper-V hosts with converged fabrics then you need to realise that all of your NICs for RDP access will be committed to the NIC team and Hyper-V switch.  That means that while implementing or troubleshooting the switch and converged fabrics you will need some alternative to RDP/Remote Desktop.  And I’m not talking VNC/TeamViewer/etc.

In my lab, I have LOTS of spare NICs.  That won’t be true of field implementation.  I temporarily fired up an “RDP” NIC, configure my team, switch, and a virtual NIC for the Parent.  Then I RDPd into the Parent virtual NIC and disabled the “RDP” NIC.

In the field, I strongly advise using the baseboard management controller (BMC) to remotely log into the host while implementing, re-configuring or troubleshooting the converged fabrics setup.  Why?  Because you’ll be constantly interrupted if relying on RDP into one of the converged or virtual NICs.  You may even find NICs switching from static to DHCP addressing and it’ll take time to figure out what their new IPs are.

You’ll be saving money by converging fabrics.  Go ahead and cough up the few extra quid to get a BMC such as Dell DRAC or HP iLO fully configured and onto the network so you can reliably log into the server.  Plus it gives you other features like power control, remote OS installation, and so on.

Windows Server 2012 Hyper-V & Management OS Virtual NICs

We continue further down the road of understanding converged fabrics in WS2012 Hyper-V.  The following diagram illustrates a possible design goal:

image

Go through the diagram of this clustered Windows Server 2012 Hyper-V host:

  • In case you’re wondering, this example is using SAS or FC attached storage so it doesn’t require Ethernet NICs for iSCSI.  Don’t worry iSCSI fans – I’ll come to that topic in another post.
  • There are two 10 GbE NICs in a NIC team.  We covered that already.
  • There is a Hyper-V Extensible Switch that is connected to the NIC team.  OK.
  • Two VMs are connected to the virtual switch.  Nothing unexpected there!
  • Huh!  The host, or the parent partition, has 3 NICs for cluster communications/CSV, management, and live migration.  But … they’re connected to the Hyper-V Extensible Switch?!?!?  That’s new!  They used to require physical NICs.

In Windows Server 2008 a host with this storage would require the following NICs as a minimum:

  • Parent (Management)
  • VM (for the Virtual Network, prior to the Virtual Switch)
  • Cluster Communications/CSV
  • Live Migration

All that accumulation of NICs wasn’t a matter of bandwidth. What we really care about in clustering is quality of service: bandwidth when we need it and low latency. Converged fabrics assume we can guarantee those things. If we have those SLA features available to us (more in later posts) then 2 * 10 GbE physical NICs in each clustered hosts might be enough, depending on business and technology requirements of the site.  4 NICs per host … and that’s without NIC teaming.  Double the NICs!

The amount of NICs go up.  The number of switch ports goes up.  The wasted rack space cost goes up.  The power bill for all that goes up.  The support cost for your network goes up.  In truth, the complexity goes up.

NICs aren’t important.  Quality communications channels are important.

In this WS2012 converged fabrics design, we can create virtual NICs that attach to the Virtual Switch.  That’s done by using the Add-VMNetworkAdapter PowerShell cmdlet, for example:

Add-VMNetworkAdapter -ManagementOS -Name “Manage” -SwitchName External1

… where Manage will be the name of the new NIC and the name of the Virtual Switch is External1.  The –ManagementOS tells the cmdlet that the new vNIC is for the parent partition or the host OS.

You can then:

I think configuring the VLAN binding of these NICs with port trunking (or whatever) would be the right way to go with this.  That will further isolate the traffic on the physical network.  Please bear in mind that we’re still in the beta days and I haven’t had a chance to try this architecture yet.

Armed with this knowledge and these cmdlets, we can now create all the NICs we need that connect to our converged physical fabrics.  Next we need to look at securing and guaranteeing quality levels of communications.

Windows Server 2012 Hyper-V & The Hyper-V Extensible Switch

Before we looks at this new networking feature of W2012 Hyper-V, lets look at what we have been using in Windows Server 2008/R2.  Right now, if you create a VM, you give it one or more virtual network cards (vNICs).  Each vNIC is connected to a virtual network (basically a virtual unmanaged switch) and each switch is connected to one physical NIC (pNIC) or NIC team in the host.  Time for a visual:

image

Think about a typical physical rack server for a moment.  When you connect it to a switch the port is a property of the switch, right?  You can configure properties for that switch port like QoS, VLANs, etc.  But if you move that server to another location, you need to configure a new switch port.  That’s messy and time consuming.

In the above example, there is a switch port.  But Microsoft anticipated the VM mobility issue and port configuration.  Instead of the port being a property of the virtual network, it’s actually a property of the VM.  Move the VM, you move the port, and you move the port settings.  That’s clever; configure the switch port once and now it’s a matter of “where do you want your workload to run today?” with no configuration issues.

OK, now let’s do a few things:

  • Stop calling it a virtual network and now call it a virtual switch.
  • Now you have a manageable layer 2 network device.
  • Introduce lots of new features for configuring ports and doing troubleshooting.
  • Add certified 3rd-party extensibility.

We have different kinds of Virtual Switch like we did before:

  • External – connected to a pNIC or NIC team in the host to allow VM comms on the physical network.
  • Internal – Allows VMs to talk to each other on the virtual switch and with the host parent partition.
  • Private – An isolated network where VMs can talk to each other on the same virtual switch.

Although I’m focusing on the converged fabric side of things at the moment, the extensibility is significant.  Companies like Cisco, NEC, Five9, and others have announced how they are adding functionality.  NEC are adding their switch technology, Five9 are adding a virtual firewall, and Cisco have SR-IOV functionality and a Cisco Nexus 1000v that pretty much turns the Hyper-V Switch into a Cisco switch with all the manageability from their console.  The subject of extensibility is a whole other set of posts.

With a virtual switch I can do something as basic as this:

image

It should look kind of familiar Smile  I’ve already posted about NIC teaming in Windows Server 2012.  Let’s add a team!

image

With the above configuration, the VMs are now connected to both the NICs in the host.  If one NIC dies, the team fails over and the VMs talk through the other NIC.  Depending on you load distribution setting, your VMs may even use the aggregation of the bandwidth, e.g. 2 * 10 GbE to get 20 Gbps of bandwidth. 

With NIC teaming, we have converged two NICs and used a single pipe for VM communications.  We haven’t converged any fabrics just yet.  There’s a lot more stuff with policies and connections that we can do with the Virtual Switch.  There will be more posts on those topics soon, helping us get to the point where we can look at converging fabrics.

Windows Server 2012 Hyper-V & Network Card (NIC) Teaming

Every time Microsoft gave us a new version of Hyper-V (including W2008 R2 SP1) we got more features to get the solution closer in functionality to the competition.  With the current W2008 R2 SP release, I reckon that we have a solution that is superior to most vSphere deployments (think of licensed or employed features).  Every objection, one after the next, was knocked down: Live Migration, CSV, Dynamic Memory, and so on.  The last objection was NIC teaming … VMware had it but Microsoft didn’t have a supported solution.

True, MSFT hasn’t had NIC teaming and there’s a KB article which says they don’t support it.  NIC teaming is something that the likes of HP, Dell, Intel and Broadcom provided using their software.  If you had a problem, MSFT might ask you to remove it.  And guess what, just about every networking issue I’ve heard on on Hyper-V was driver or NIC teaming related.

As a result, I’ve always recommended against NIC teaming using OEM software.

We want NIC teaming!  That was the cry … every time, every event, every month.  And the usual response from Microsoft is “we heard you but we don’t talk about futures”.  Then Build came along in 2011, and they announced that NIC teaming would be included in W2012 and fully supported for Hyper-V and Failover Clustering.

image

NIC teaming gives us LBFO.  In other words, we can aggregate the bandwidth of NICs and have automatic failover between NICs.  If I had 2 * 10 GbE NICs then I could team them to have a single pipe with 20 Gbps if both NICs are working and connected.  With failover we typically connect both NICs to ports on different access switches.  The result is that if one switch, it’s NIC becomes disconnected, but the other one stays connected and the team stays up and running, leaving the dependent services available to the network and their clients.

Here’s a few facts about W2012 NIC teaming:

  • We can connect up to 32 NICs in a single team.  That’s a lot of bandwidth!
  • NICs in a single team can be different models from the same manufacturer or even NICs from different manufacturers.  Seeing as drivers can be troublesome, maybe you want to mix Intel and Broadcom NICs in a team for extreme uptime.  Then a dodgy driver has a lesser chance of bringing down your services.
  • There are multiple teaming modes for a team: Generic/Static Teaming requires the switches to be configured for the team and isn’t dynamic.  LACP is self-discovering and enables dynamic expansion and reduction of the NICs in the team.  Switch independent works with just a single switch – switches have no knowledge of the team.
  • There are two hashing algorithms for traffic distribution in the NIC team.  With Hyper-V switch mode, a VM’s traffic is limited to a single NIC.  In lightly loaded hosts, this might no distribute the network load across the team.  Apparently it can work well on heavily loaded hosts with VMQ enabled.  Address hashing uses a hashing algorithm to spread the load across NICs.  There is 4-tuple hashing (great distribution) but it doesn’t work with “hidden” protocols such as IPsec and fails back to 2-tuple hashing.
  •  

    NIC teaming is easy to set up.  You can use Server Manager (under Local Server) to create a team.  This GUI is similar to what I’ve seen from OEMs in the past. 

    image

    You can also use PowerShell cmdlets such as New-NetLbfoTeam and Set-VMNetworkAdapter.

    One of the cool things about a NIC team is that, just like with OEM versions, you can create virtual networks/connections on a team.  Each of those connections have have an IP stack, it’s own policies, and VLAN binding.

    image

    In the Hyper-V world, we can use NIC teams to do LBFO for important connections.  We can also use it for creating converged fabrics.  For example, I can take a 2U server with 2 * 10 GbE connections and use that team for all traffic.  I will need some more control … but that’s another blog post.

    Windows Server 2012 Hyper-V & Data Centre Bridging (DCB)

    DCB is a feature that is new to Windows Server 2012 networking and we can take advantage of this in creating converged fabrics in Hyper-V, private and public clouds.  According to Microsoft:

    IEEE 802.1 Data Center Bridging (DCB) is a collection of standards that defines a unified 802.3 Ethernet media interface, or fabric, for local area network (LAN) and storage area network (SAN) technologies. DCB extends the current 802.1 bridging specification to support the coexistence of LAN-based and SAN-based applications over the same networking fabric within a data center. DCB also supports technologies, such as Fibre Channel over Ethernet (FCoE) and iSCSI, by defining link-level policies that prevent packet loss.

    According to Wikipedia:

    Specifically, DCB goals are, for selected traffic, to eliminate loss due to queue overflow and to be able to allocate bandwidth on links. Essentially, DCB enables, to some extent, the treatment of different priorities as if they were different pipes. The primary motivation was the sensitivity of Fibre Channel over Ethernet to frame loss. The higher level goal is to use a single set of Ethernet physical devices or adapters for computers to talk to a Storage Area Network, Local Area network and InfiniBand fabric.

    Long story short: DCB is a set of Ethernet standards that leverage special functionality in a NIC to allow us to converge mixed classes of traffic onto that NIC such as SAN and LAN, which we would normally keep isolated.  If your host’s NIC has DCB functionality then W2012 can take advantage of it to converge your fabrics.

    image

    Windows Server 2012 Hyper-V Making Converged Fabrics Possible

    If you wanted to build a clustered Windows Server 2008 R2 host, how many NICs would you need?  With iSCSI, the answer would be 6 – and that’s without any NIC teaming for the parent, cluster, or VM comms.  That’s a lot of NICs.  Adding 4 ports into a host is going to cost hundreds of euros/dollars/pounds/etc.  But the real cost is in the physical network.  All those switch ports add up: you double the number of switches for NIC teaming, those things aren’t free, and the suck up power too.  We’re all about consolidation when we do virtualisation.

    Why do we have all those NICs in a W2008 R2 Hyper-V cluster?  The primary driver isn’t bandwidth.  The primary reason is to guarantee a level of service. 

    What if we had servers that came with 2 * 10 GbE NICs?  What if they could support not only 256 GB RAM, but 768 GB RAM?  That’s the kind of spec that Dell and HP are shipping now with their R720 and HP DL380 Gen8.  What if we had VM loads to justify these servers, then we needed 10 GbE for the Live Migration and backup loads?  What if there was a way to implement these servers with fewer network ports, that could take advantage of the cumulative 20 Gbps of bandwidth but with a guaranteed level of service?  Windows Server 2012 can do that!

    My goal with the next few posts is to describe the technologies that allow us to converge fabrics and use fewer network interfaces and switch ports.  Fabrics, what are they?  Fabric is a cloud term … you have a compute cluster (the hosts), a storage fabric (the storage area network, e.g. iSCSI or SMB 3.0), and fabrics for management, backup, VM networking and so on.  By converging fabrics, we use fewer NICs and fewer switch ports.

    There is no one right design.  In fact, at Build, the presenters showed lots of designs.  In recent weeks and months, MSFT bloggers have even shown a number of designs.  Where there was a “single” right way to do things in W2008 R2/SP1, there are a number of ways in W2012.  W2012 gives us options, and options are good.  It’s all a matter of trading off on tech requirements, business requirements, complexity, and budget.

    Watch out for the posts in the coming days.

    I’ve Got A Cool Demo Ready For Next Week

    On Monday I’ll be in Belfast and on Tuesday I’ll be in Dublin presenting at the Windows Server 2012 Rocks community events.  My topics for next week are Hyper-V and Networking.  Assuming the Internet connectivity works, I’ve got a very cool demo to show of some of the capabilities of Windows Server 2012 featuring:

    • Some of the great open source work by Microsoft
    • PowerShell scripting
    • New networking features
    • Virtualisation mobility

    Not to mention a bunch of other demos all pushing the HP ProLiant lab that I have at work.  The other demos are canned … experience has taught me that I can’t rely on hotel Internet … but this special demo is not recorded just so I can have something special for a live “will it break?” demo.

    If you’ve registered (click on the event to register), then don’t miss out.  And if you haven’t registered yet, then what are you waiting for?

    EDIT:

    The demo won’t break Smile

    Operations Manager 2012: Network Monitoring

    Speaker: Vishnu Nath, PM for Network Monitoring feature in OpsMgr 2012.

    Discovery, monitoring, visualisation and reporting.  Key takeaway; OpsMgr will help IT Operations gain visibility into the network layer of service to reduce meantime to resolution.  All the required MPs, dashboards, and reports are built in-box.  Server to network dependency discovery with support for over 80 vendors and 2000+ devices certified.  It supports SNMP V1, v2c and V3.  There is support for IPv4 and IPv6 endpoints. 

    Supported devices:

    • Bridges
    • Firewalls
    • Load balancers
    • Switches
    • Routers

    Discovery

    Process of identifying network devices to be monitored.  Designed to be simple, without the need to call in network admins.

    Demo

    You can run the normal discovery wizard to discover network devices.  There is also a Discovery Rule that you can configure n Administration/Network Management.  This can run on a regular schedule.  You can pick a management or gateway server to run the rule, and you set the server resource pool for the monitoring.  Note that the design guide prefers that you have a dedicated network monitoring resource pool (min 2 Mgmt servers) if doing this at scale.

    There are two discovery types, which are like the types of customer MSFT has encountered.  You list the IPs of devices and do explicit discovery.  Alternately, you can do a recursive discovery which crawls the network via router ARP and IP tables.  That’s useful if you don’t know the network architecture.

    You’ll need runas accounts for he community strings … read only passwords to MIBS and SNMP tables in the network devices.  It does not need read-write private strings.  Using a runas account secures the password/community string.  You can have a number of them for complex environments. 

    You can import a text file of device IP addresses for an explicit discovery.  You can use ICMP and/or SNMP access mode to monitor the device.  ICMP gives you ping up/down probe monitoring.  SNMP gives you more depth.  An ISP won’t give you SNMP access.  A secure environment might not allow ICMP into a DMZ.  You can set the SNMP version, and the runas account for each device.  During discovery, OpsMgr will try each community string you’ve entered.  It will remember which one works.  In some environments, devices can send trap alerts if they have failed logins and that can create a storm of alerts … SO BEWARE.  You can avoid this by selecting the right runas account per device.

    There are retry attempts, ICMP timeout, SNMP timeout.  You also can set a max device number discovery cap.  This is to avoid discovering more than you need to in a corporate environment.

    You can limit the discovery to Name, OID, or IP range.  And you can exclude devices.

    You can also do the discovery on a regular basis using a schedule.  Not important in static environment.  Maybe do it once a week in larger or more fluid environments.  You can run the discovery rule manually.  When you save the rule, you have the choice to run the rule right then.

    What’s Discovered

    • Connectivity of devices and dependencies, servers to network and network to network
    • VLAN membership
    • HSRP for Cisco
    • Stitching of switch ports to server NICs
    • Key components of devices: ports/interfaces/processor/ and memory I think

    The process:

    Probing (if not supported, it’s popped in pending management for you to look at. If OpsMgr knows it then they have built in MIBS to deal with it) –> Processing –> Post Processing (what VLANs, what devices are connected, NIC stitching mapping).

    • Works only on Gateway/management server
    • Single rule per gateway/management server
    • Discovery runs on a scheduled basis or on demand
    • Limited discoveries can be triggered by device traps – enabled on some devices. Some devices detect a NIC swap, and the device traps, and OpsMgr knows that it needs to rediscover this device.  Seamless and clever.

    Port/Interface Monitoring

    • Up/down
    • Volumes of inbound/outbound traffic
    • % utilization
    • Discards, drops, Errors

    Processor % utilization

    Memory counters (Cisco) and free memory

    Connection Health  on both ends of the connection

    VLAN health based on state of switches (rollup) in the VLAN

    HSRP Group Health is a rollup as well

    Network Monitoring

    • Supports resource pools for HA monitoring
    • Only certain ports monitored by default: ports connecting two network devices together or ports that the management server is connected to
    • User can override and monitor other ports if required

    Visualisation

    4 dashboards:

    • Network summary: This is the high level view, i.e. top 10 nodes list
    • Network node: Take any device and drill down into it.
    • Network interface: Drill into a specific interface to see traffic activity
    • Vicinity: neighbours view and connection health.

    Reporting

    5 reports:

    • Memory utilisation
    • CPU utilisation
    • Port traffic volume
    • Port error analysis
    • Port packet analysis

    Demo

    Behind the scenes they normalise data, e.g. memory free from vendor A and memory used from vendor B, so you have one consistent view.  You can run a task to enable port monitoring for (by default) un-monitored discovered ports (see above).  

    End

    You can author custom management packs with your own SNMP rules.  They used 2 industry standard MIBS and it’s worked on 90-95% of devices that they’ve encountered so far.  Means there’s a good chance it will work on future devices.