Showing posts with label Hyper-V 3.0. Show all posts
Showing posts with label Hyper-V 3.0. Show all posts

Tuesday, May 22, 2012

Rapid VM deployment with Powershell on Hyper-V 3

I have conducted a web seminar for 'Microsoft Partner Readiness Webminar' Module 2a which focusing on working with Hyper-V 3 with Powershell.

In my first demo 'Demo1', I have showed to the audience on how we could rapidly deploy VMs Without the use of:-
1. Hyper-V Manager
2. System Center Virtual Machine Manager

The Power of Powershell in managing VMs in Hyper-V

Most of us thought that with the Hyper-V Manager, we could do most of the administrative tasks easily. Well, time to rethink if you have hundreds (if not thousands) of VMs running on you Hyper-V infrastructure and you have to do the following :-
1. To find out the Startup Memory, Minimum Memory and Maximum Memory each VM
2. To find out vCPU count of each VM
3. To find out the vSwitch and VLAN ID each VM connected
With the few tasks as listed, immediately we know how complicated things going to be, and a good example is that we have to right-click each and every VM, properties just to find out these information.

Let think this through with Powershell, you could simply use these to solve the tasks above :-
1. Get-VMMemory -VMNAME <vmname> | ft vmname, startupmemory, minimummemory, maximummemory
2. Get-VMProcessors -VMNAME <vmname> | ft vmname, count
3. Get-VMnetwork

How Aboout Bulk Creating VMs ?

Yes ! Of course we can do that, in fact there are numerous ways in getting this done. In this blog I am going to share with you how we pre-defined the VMs configuration in an CSV spreadsheet and then use powershell to created alll these VMs.

I have change the script I shared last at How-To: Rapid Deploy VM Using Powershell to the following

$vmdefaultpath = "D:\VMs"
$ParentVHD = "D:\Hyper Base\WIN2K8R2SP1_Ent_Sysprep_180days_Updated20120404.vhd"
$path = "D:\vms\VMs.csv"
import-csv -path $path|ForEach-Object {
$erroractionpreference = 0    
$vmName = $_.Name
[int] $vmmemory = $_.Memory
$vmcpucount = $_.Cpucount
$vmSwitch = $_.Network
$vmpath = $vmdefaultpath
#Create the VM
New-VM -Name $vmname -Path $vmdefaultpath
#Set the VM Memory properties
Set-VM -Name $vmname -StaticMemory -MemoryStartupBytes $vmstartmemory
#Set the vCPU
Set-VMProcessor -VMName $vmname -Count $vmcpucount
#Connect the VM to vSwitch
Connect-VMNetworkAdapter -VMName $vmname -SwitchName $vmSwitch
#Create VHD for the VM
New-VHD -Path $vmpath\$vmname\$vmname.vhd -ParentPath $ParentVHD
#Add the VHD to the VM to IDE 0 Location 0
Add-VMHardDiskDrive -vmname $vmname -ControllerType IDE -ControllerNumber 0 -Path $vmpath\$vmname\$vmname.vhd
Write-Host -BackgroundColor Green -ForegroundColor Black "Virtual Machine $vmname has been successfully created"     

The script above:-
1. Reads all VM configuration listed in VMs.csv and create in Hyper-V 3 host
2. Stores all VMs configuration files, snapshots, and VHDs in D:\VMs\
3. Creates diferrencing disk for each VMs with the Parent VHD in D:\Hyper Base\
4. Creates VMs with static memory

You have to change this script properties to suit your environment if you plan to use this.

Below is the video i have captured, showing how the script works for my demo.

Sunday, April 22, 2012

Hyper-V Live Migration of Windows Server 8 Beta

Hyper-V Live Migration of Yesterday
When Hyper-V 2.0 introduced together with Windows Server 2008 R2, it was indeed has brought Microsoft into the leader quadrant as one of the Virtualization player in the market. One of the feature which brought Hyper-V close (if not at par) with other rivals is the introduce of Cluster Shared Volume (CSV) which has brought Live Migration (a.k.a VMotion in VMWare) a reality. With Hyper-V 2.0 and CSV, Microsoft introduce the High Availability (HA) to their Virtualization solutions.

Live migration allows you to transparently move running virtual machines from one Hyper-V node of the failover cluster to another Hyper-V node in the same cluster without a dropped network connection or perceived downtime. All virtual machines are stored in the shared storage area which can be an iSCSI or Fiber-Channel Storage Area Network (SAN) , and the running virtual machine state is managed by one of the nodes. A technical write up in detail of Using Live Migration with Cluster Shared Volumes in Windows Server 2008 R2 is made available for some of us who want to dig further how stuffs works.

Hyper-V Live Migration of Today
Windows Server 8 Beta is available now and among all interesting new features, Hyper-V 3.0 is in bundled a lot more new features. In this blog, we will look at Live Migration in compare to Hyper-V 2.0 which introduced with Windows Server 2008 R2.

In Hyper-V 3.0, Live Migration are now refer to Hyper-V Virtual Machine Mobility which consists of:

  • Live Migration Without Shared Storage
  • Live Migration with SMB Shared Storage
  • Live Migration with Failover Cluster
  • Storage Migration (YES, you can now live migrate VM's storage)
The Key benefits of Live Migration in Windows Server 8 Beta is delivers improved performance and flexibility. It is also now available inside and outside of clustered environments—both with and without shared storage.

Live Migration Without Shared Storage
Also know as 'Shared Nothing Live Migration' is the most jaw dropping feature in Hyper-V 3.0. As its name suggest, you do not require any shared storage for Live Migration to kick off. AWESOME !!
Be aware that this option of Live Migration does not provide any High Availability (HA) capability. In my very own opinion, you may consider this option in a small scale deployment/environment.

Live Migration with SMB Shared Storage (SMB)
Hyper-V 3.0 Live Migration could now leverage on SMB 2.2 in WIndows Server 8 Beta. With SMB 2.2, file sharing performance is greatly enhanced and the most significant enhancement direct affect the capabilities of Hyper-V 3.0 is the support of multichannel.

And as i am writing this blog, SMB 3.0 is there for Windows Server 2012. Read more at Windows Server Blog. Our friends, Beh Chor How, has an experience on this and he had this blog at V-Enfra.

If you are not ready to deploy a clustered Hyper-V environment and wanting to enjoy the live migration almost similar with Hyper-V Cluster, then this will be one of the options for you. Sweet and simple ! :-)

Live Migration with Failover Clusters
The similar feature (if not the same) Hyper-V cluster with Failover Cluster introduced in Windows Server 2008 R2. To mention a few significant improvement, these are:-

  • Simultaneous Live Migration
  • VM Liive Migration Queue
  • Clustered Share Volume (CSV 2.0)  

This will be the most ideal deployment for enterprise level organisation for highly virtualized infrastructure and HA capabilities.

Live Storage Migration
Oh yes, 'LIVE STORAGE MIGRATION', is a new thing in Hyper-V 3.0 Clustered. You may get more details at Windows Server 8- Truly Live Storage Migration.