RDM : Perennial reservation

Are you hosting any MSCS workloads on ESXi ?
You probably forgot to set a perennial reservation.  I’ve used RDM’s in small environments and never really noticed any issues with slow ESXi node startups…Until recently.

The infrastructure I currently look after has a 3 node MSQL cluster with more than 25 RDM’s presented to them. A few days ago I had to add  another two ESXi nodes to the cluster and noticed that the nodes took longer than expected to start up.   This issues was related to KB1016106.

Due to the amount of RDM’s presented to the ESXi cluster, I would have to automate the process to perennially reserve the RDM’s across all the nodes.

Step 1

Determine what disks are actually RDM’s and get the naa.ID.





# Import VIM automation core snapin if not loaded
 
$imported = Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction 'SilentlyContinue'
 
if (!$imported)
{
 Write-Host -ForegroundColor "yellow" "Importing VMware.VimAutomation.Core..."
 try
 {
 Add-PSSnapin VMware.VimAutomation.Core -ErrorAction 'Stop'
 }
 catch
 {
 Write-Host "Something went wrong. ""VMware.VimAutomation.Core"" snapin not found. Try execute the script from PowerCli"
 }
}
 
$vchost = Read-Host "Please enter your VIserver FQDN/IP"


 try {
 
 Connect-VIServer $vchost -ErrorAction:Stop
 Write-Host -ForegroundColor Green "Connected to VI server"

 } catch {
 
 Write-Host -ForegroundColor Red "Unable to connect to the VI server"
 }
 
$vm = Read-Host "Please enter the VM name"
 
$rdms = get-vm $vm | get-harddisk | Where-Object {$_.DiskType -eq "RawPhysical"}
 
foreach ($rdm in $rdms){
 
$observed = New-Object -TypeName PSObject
$observed | Add-Member -MemberType NoteProperty -Name Parent -Value $rdm.Parent
$observed | Add-Member -MemberType NoteProperty -Name Name -Value $rdm.name
$observed | Add-Member -MemberType NoteProperty -Name ScsiCanonicalName -Value $rdm.ScsiCanonicalName
Write-Output $observed
}

Disconnect-VIServer $vchost -Confirm:$false


Step 2

Using the output obtained from step 1, execute this script against your individual ESXi nodes. You will need to use the “Scsi_CNAME” to reserve the devices on your ESXI node.  Create a new file containing each naa.ID similar to this :

perenial

 

Now you can start setting the reservation on your ESXi node with this script.



Add-PSSnapin VMware.VimAutomation.Core
 
 try {
 Get-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction:Stop
 Write-Host -ForegroundColor Green "Loaded ""VMware.VimAutomation.Core"" PSSnapin"
 } catch {
 Write-Host -ForegroundColor Red "Unable to load the required PS module ""VMware.VimAutomation.Core"""
 } 

$path_to_csv = Read-Host "Your path to the .csv input file"
$vmhost = Read-Host "Please supply your ESXi nodes FQDN"
$esxi_admin = Read-Host "Please specify user with root access"
$esxi_admin_pass = Read-Host "Please specify password"
$naas = Import-Csv $path_to_csv

foreach ($naa in $naas){
Connect-VIServer $VMHost -User $esxi_admin -Password $esxi_admin_pass 

 $myesxcli= get-esxcli $VMHost
 $rdmnaa = $naa.ScsiCanonicalName
 $myesxcli.storage.core.device.setconfig($false, "$rdmnaa", $true)
}

Disconnect-VIServer $VMHost -Confirm:$false 

Step 3

Verify that your reservation have been set. Grab one or two random naa.ID’s and check.

esxcli_per_res

 

Thats it, your done.

Share on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Google+0

Leave a Reply

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