Tag Archives: powercli

Path selection policy experience and powercli

In this post i will discuss on how to change the PSP (path selection policy) for FC luns.

The PSP determines how an ESXi host will send data to the FC storage. The default (in my scenario which is HDS) is FIXED.

FIXED is usually used for active / active array (i will not get in to details here about arrays differences) and the idea is that all paths are active but IO goes over only one of the paths. If a fail over occurs the IO will switch to one of the other paths and stay there. The problem with that policy is that the FC ports are not balanced, some of them are very utilized and some not. The other problem is that it is not best practice by VMware or HDS. The best practice is to use RoundRobin , which basically means the ESXi uses all paths and sends specific number of IO commands to each path and moves on to the next one, that way all paths are utilized.

Here is the FC ports utilization when using the FIXED psp:

unev1

This configuration can be done using the FAT / web client, but since i have too many ESXi’s and too many LUN’s i decided to go the powercli way.

At first i tried to use the set-scsilun command, and ran it on all LUN’s and ESXi’s in the cluster – something like this:

#### you can filter the luns based on needs

$luns = get-vmhost -name esxi1 | get-scsilun

$esxihosts = get-cluster -name cl | get-vmhost

foreach ($lun in $luns)

{

foreach ($esxi in $esxihosts)

{

$esxi | get-scsilun -canonicalname $lun.canonicalname | set-scsilun -multipathpolicy “roundrobin”

write-host ($esxi.name, $lun.canonicalname)

}

}

This script works well, but is very slow, each command takes about ~2 minutes. It would have taken me the whole weekend or even more just to change one of my clusters. So i decided i have to find a better way to do it, so i researched on other methods and came across the get-esxcli cmdlet , which i can to accomplish the same task but in a different way, i can change the inner loop in my script to this:

$esxcli = get-esxcli -vmhost $esxi

$esxcli.storage.nmp.device.set ($null,$lun.canonicalname, “roundrobin”)

write-host ($esxi.name, $lun.canonicalname)

It has the same outcome only much faster, each command takes less than 1 second, that means that the script took ponly couple of minutes to run, which is what i wanted.

Here is the utilization after the PSP was changed:

even1

I even took one that shows how the utilization gets even:

geteven1

Pretty nice, i think.

The get-esxcli cmdlet is quite powerful, it can be used to configure many things on ESXi’s, and to do it in an efficient way.

There is not a lot of documentation about it but its similar to the “esxcli” shell command, so its not too hard to figure the syntax.

BTW, there is an additional cmdlet to change the default PSP to roundrobin so new LUN’s will be configured automatically:

## This is satp for hds (can be different depends on array

$psp = “VMW_PSP_RR”

$satp = “VMW_SATP_DEFAULT_AA”

$esxcli.storage.nmp.satp.set ($null,$psp,$satp)

That’s about it, now i use the best practice, and have learned how to use powercli in an efficient way.

Tagged , ,

Using Vmware image builder

I know this is not new, but it does worth mentioning and i did worked with it lately, so why not?

Lets start, Image builder allows you to create custom made iso’s for installing and upgrading ESXi servers. Its a several PowerCLI cmdlets.

The benefits are that it limits the number of reboot you have to go through when upgrading, not to mention scenarios like Auto Deploy or the use of Nexus 1000v that you have to build your ISO file. Basically it lets you take an ISO and inject to it (or remove) and package (VIB) that you want.

It involves several phases:

1. Importing a depot. A depot can be a bundle of all vibs that are necessary that install ESXi, that you can download for VMware(or partner) web site, or it can be a specific patch, driver, extension. They all come in a form of zip file.

2. Creating an image profile. Well, actually to make it easy its better to just clone a profile.

3. Adding packages (vib’s) to the image profile.

4. Exporting the image profile to an ISO.

Lets get to business,

Step 1, the simplest way is to just download the depot that we are interested in, and putting it in a directory.

Make sure you use the latest release of PowerCLI, cause they have been known bugs with older releases.

Than just add the depot:

Add-esxsoftwaredepot thedepot.zip

You can add as many depots as you like, depends on the scenario. For example i added the cisco depot and the Nexus 1000v depot.

By Issuing the command: Get-esxsoftwaredepot you will see all the depots you have added.

Another command is get-esxsoftwarepackage that returns all the packages that are in the depots.

The last but very important command is get-esximageprofile , this command will return all the profiles that are in the depot.

Usually, when using a full installation of a depot the vendor (vmware or a partner) will create several profiles, for example a standard one and one without tools.

Step 2, We choose the profile that we want to use and just clone it so we can work on it later:

New-esximageprofile -cloneprofile nameoftheprofiletoclone -name newprofilename -vendor yourname

Step 3, now we are going to add the packages we need to the new profile we created:

add-esxsoftwarepackage -softwarepackage packagetoadd -imageprofile profilewecreated

Step 4, Exporting the profile to iso file:

Export-esximageprofile -imageprofile profilenametoexport -filepath filename -exporttoiso

 

That is it, you now have an iso file that you can use with Update manager , Auto Deploy or just install ESXi.

One thing to remember is, image builder does offer some kind of validation, for example when adding duplicate packages it automatically replaces the older with the new package, but it will not validate that you put in all the packages that are needed (well it cant guess). So make sure you test your iso’s before using them in production.

I hope someone can use it.

There you go, my first blog post.

 

 

Tagged , ,