Wednesday, November 20, 2013

How to build a System Center Virtual Machine Manager 2012 R2 lab - part 5

In the previous post we setup two Hyper-V servers. Time has come to setup the storage back-end for your System Center Virtual Machine Manager 2012 R2 lab. No need for an alternative solution like FreeNas or OpenFiler because nowadays Windows Server 2012 R2 and Hyper-V Server 2012 R2 have some really cost-effective new storage options, such as Storage Spaces and Hyper-V over SMB 3.0. And of course you definitively want to take advantage of these features for your lab, so, “Winology”, here we come! Before you get started on this I suggest that you take a deep look at this Microsoft document that explains what’s new in the ISCSI Target Server in this last release: http://blogs.technet.com/b/filecab/archive/2013/07/31/iscsi-target-server-in-windows-server-2012-r2.aspx


Very well. Create a fourth virtual machine named LAB2013ISCSI01. This virtual machine will be installed as Server Core, and you will give it 192.168.134.15 as IP address. The steps to perform are the same you did for the three other VMs (the DC and the two Hyper-V servers), so start configuring networking:
Get-NetAdapter -Name Ethernet0 | % {
 $_ | Set-NetIPInterface -Dhcp Disabled
 $_ | New-NetIPAddress -IPAddress 192.168.134.15 -PrefixLength 24 -DefaultGateway 192.168.134.2
 $_ | Set-DnsClientServerAddress -ServerAddresses 192.168.134.10
}
then proceed to configure Remote Desktop and Windows Firewall. Concerning Windows Firewall, I invite you to use a function I wrote a few months back to disable it (you can check it out at http://www.happysysadm.com/2013/03/disabling-windows-firewall-in-powershell.html). This will be a good learning experience for any Powershell novice:


You have now to create the ISCSI targets. Let’s see which one of the available roles can help you:
Get-WindowsFeature | ? name -like *iscsi*

Display Name                                            Name
------------                                            ----
        [ ] iSCSI Target Server                         FS-iSCSITarget-Server
        [ ] iSCSI Target Storage Provider (VDS and V... iSCSITarget-VSS-VDS
Cool there you have it! A small tip: you don’t need the second listed role because providers are for remote Target management only, so you have to add the first role. Open Powershell, and run the following cmdlet:
Add-WindowsFeature FS-iSCSITarget-Server

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {File and iSCSI Services, File Server,...
WARNING: Windows automatic updating is not enabled. To ensure that your newly-installed role or feature is automatically updated, turn on Windows Update.
To put in place the back-end storage, you will take advantage of the feature of Windows 2012 named Storage Spaces. Start to add three disks to the LAB2013ISCSI01 virtual machine:


Use Get-PhysicalDisk to check that these three physical disks are seen from Windows (this should happen straight away):
Get-PhysicalDisk

FriendlyName  CanPool       OperationalS HealthStatus Usage                Size
                            tatus
------------  -------       ------------ ------------ -----                ----
PhysicalDisk0 False         OK           Healthy      Auto-Select         60 GB
PhysicalDisk1 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk2 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk3 True          OK           Healthy      Auto-Select        100 GB
That’s very good. Now filter down only the disks that are available to be added to a Storage Pool:
Get-PhysicalDisk -CanPool $true

FriendlyName  CanPool       OperationalS HealthStatus Usage                Size
                            tatus
------------  -------       ------------ ------------ -----                ----
PhysicalDisk1 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk2 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk3 True          OK           Healthy      Auto-Select        100 GB
Notice that the switch that you find in many online documents –ispooled is wrong. This parameter do not exist. "Get-PhysicalDisk -CanPool $True" must be used instead.
Then we have to create the Storage Pool:
New-StoragePool -FriendlyName "LAB2013SPOOL01" -PhysicalDisks (Get-PhysicalDisk –CanPool $True) -StorageSubSystemFriendlyName ((Get-StorageSubSystem).Friendlyname)
FriendlyName    OperationalStat HealthStatus    IsPrimordial    IsReadOnly
                us
------------    --------------- ------------    ------------    ----------
LAB2013SPOOL01  OK              Healthy         False           False
Once the pool is ready, you have to set up a new virtual hard-disk on it. That’s done with the New-VirtualDisk cmdlet. This cmdlet has three possible storage layout:
  • simple (similar to RAID0, insecure but fast) 
  • mirror (similar to RAID1, increased reliability but reduced capacity) 
  • parity (similar to RAID5, protect against single disk failure)
Parity is the best possible layout in this scenario so go for it:
New-VirtualDisk -StoragePoolFriendlyName "LAB2013SPOOL01" -FriendlyName
LibraryDisk -ResiliencySettingName Parity -Size 250GB -ProvisioningType Thin
FriendlyName  ResiliencySet OperationalS HealthStatus IsManualAtta         Size
              tingName      tatus                     ch
------------  ------------- ------------ ------------ ------------         ----
LibraryDisk   Parity        OK           Healthy      False              250 GB
Proceed to the initialization of this disk and assign all the space to a X: partition with the help of the -UseMamimumSize switch:
Get-VirtualDisk -FriendlyName "LibraryDisk" | % {
 $_ | get-disk | Initialize-Disk -PartitionStyle "GPT"
 $_ | get-disk | New-Partition -DriveLetter X -UseMaximumSize
}
PartitionNumber  DriveLetter Offset                    Size Type
---------------  ----------- ------                    ---- ----
2                X           135266304            249.87 GB Basic
Format-Volume -DriveLetter X -FileSystem NTFS -NewFileSystemLabel "LibraryPartition”
DriveLetter FileSystemL FileSystem  DriveType  HealthStat SizeRemain       Size
            abel                               us                ing
----------- ----------- ----------  ---------  ---------- ----------       ----
X           LibraryP... NTFS        Fixed      Healthy     249.75 GB  249.87 GB
Now, since you are in a lab and you want to test as many cmdlets as possible, why not to enable the Deduplication mechanism we have already explored in past posts:
Add-WindowsFeature FS-Data-Deduplication
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Data Deduplication}
WARNING: Windows automatic updating is not enabled. To ensure that your newly-installed role or feature is automatically updated, turn on Windows
Update.
Import-Module Deduplication
Enable-DedupVolume -Volume X:

Enabled            UsageType          SavedSpace           SavingsRate
-------            ---------          ----------           -----------
True               Default            0 B                  0 %
It’s time now to create a Logical Unit (LU) in the form of a VHDX file on that partition.

Note how the extension has changed from VHD under Windows 2012 to VHDX under Windows 2012 R2. The main difference is that a VHD can be as large as 2TB where VHDX can go up to 64TB. Also VHDX are more resilient to VM hard shutdown.

The next cmdlet to use is New-IscsiVirtualDisk: what it actually does is to create a new iSCSI Virtual Hard Disk (VHDX) object with the specified file path and size. After the iSCSI VHDX object has been created, the virtual disk will be assigned to an iSCSI target. Then, once any allowed initiator connects to that target, it will have access to the virtual disk.
New-IscsiVirtualDisk -Path x:\LUN01.vhdx -size 10GB

ClusterGroupName   :
ComputerName       : LAB2013ISCSI01.lab2013.local
Description        :
DiskType           : Dynamic
HostVolumeId       : {C79A68FA-24D7-455A-907A-59E33B9DFA76}
LocalMountDeviceId :
OriginalPath       :
ParentPath         :
Path               : x:\LUN01.vhdx
SerialNumber       : FED7206D-8E1B-46B5-A495-9FB6B59CFE26
Size               : 10737418240
SnapshotIds        :
Status             : NotConnected
VirtualDiskIndex   : 286335802
New-IscsiVirtualDisk -Path x:\LUN02.vhdx -size 120GB

ClusterGroupName   :
ComputerName       : LAB2013ISCSI01.lab2013.local
Description        :
DiskType           : Dynamic
HostVolumeId       : {C79A68FA-24D7-455A-907A-59E33B9DFA76}
LocalMountDeviceId :
OriginalPath       :
ParentPath         :
Path               : x:\LUN02.vhdx
SerialNumber       : A369C59D-EAFE-462A-8645-5B8A33BA2A69
Size               : 128849018880
SnapshotIds        :
Status             : NotConnected
VirtualDiskIndex   : 232699603
New-IscsiVirtualDisk -Path x:\LUN03.vhdx -size 120GB

ClusterGroupName   :
ComputerName       : LAB2013ISCSI01.lab2013.local
Description        :
DiskType           : Dynamic
HostVolumeId       : {C79A68FA-24D7-455A-907A-59E33B9DFA76}
LocalMountDeviceId :
OriginalPath       :
ParentPath         :
Path               : x:\LUN03.vhdx
SerialNumber       : 25AA6011-239E-468D-9DB4-DD53EE7ED5B6
Size               : 128849018880
SnapshotIds        :
Status             : NotConnected
VirtualDiskIndex   : 673788947
You have just created three virtual disks (two bigger and one smaller, you'll see later why). Create now a new ISCSI target (pay attention to the type definition prefix IQN before the actual iqn and to the use of the array syntax @() to pass more than one IQN at the time):
New-IscsiServerTarget -TargetName Target01 -InitiatorIds @("IQN: iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local","IQN: iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local")
ChapUserName                :
ClusterGroupName            :
ComputerName                : LAB2013ISCSI01.lab2013.local
Description                 :
EnableChap                  : False
EnableReverseChap           : False
EnforceIdleTimeoutDetection : True
FirstBurstLength            : 65536
IdleDuration                : 00:00:00
InitiatorIds                : {Iqn:-iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local,
                              Iqn:-iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local}
LastLogin                   :
LunMappings                 : {}
MaxBurstLength              : 262144
MaxReceiveDataSegmentLength : 65536
ReceiveBufferCount          : 10
ReverseChapUserName         :
Sessions                    : {}
Status                      : NotConnected
TargetIqn                   : iqn.1991-05.com.microsoft:lab2013iscsi01-target01-target
TargetName                  : Target01
Repeat that step twice for the other VHDX:
New-IscsiServerTarget -TargetName Target02 -InitiatorIds @("IQN: iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local","IQN: iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local")
New-IscsiServerTarget -TargetName Target03 -InitiatorIds @("IQN: iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local","IQN: iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local")
Or (if you prefer to use the IP address, which I must admit it’s simpler):
New-IscsiServerTarget -TargetName Target01 -InitiatorIds ipaddress:192.168.134.20,ipaddress:192.168.134.21
New-IscsiServerTarget -TargetName Target02 -InitiatorIds ipaddress:192.168.134.20,ipaddress:192.168.134.21
New-IscsiServerTarget -TargetName Target03 -InitiatorIds ipaddress:192.168.134.20,ipaddress:192.168.134.21
Then assign each target to a specific VHDX:
Add-IscsiVirtualDiskTargetMapping Target01 X:\LUN01.vhdx
Add-IscsiVirtualDiskTargetMapping Target02 X:\LUN02.vhdx
Add-IscsiVirtualDiskTargetMapping Target03 X:\LUN03.vhdx
Ok, that’s all for the ISCSI Target Server configuration. Just note the Target IQN for reference:
Get-IscsiServerTarget | select targetIqn

TargetIqn
---------
iqn.1991-05.com.microsoft:lab2013iscsi01-target03-target
iqn.1991-05.com.microsoft:lab2013iscsi01-target02-target
iqn.1991-05.com.microsoft:lab2013iscsi01-target01-target
Time to configure the ISCSI initiators on the Hyper-V servers, which I will explain in the next post!

1 comment:

Related Posts Plugin for WordPress, Blogger...