Tuesday, March 5, 2013

Using the vSphere 5 CLI for Storage Configuration

When Adding a new host, SAN or LUN to your vSphere environment there are some CLI commands and configuration settings you should consider.  Since Windows 7 is my primary desktop OS, I use the VMware vSphere CLI for Windows.  You can download the latest version from VMware's downloads site.

Before using any of the commands below, please review your SAN manufacturers best practices documentation for vSphere environments.  Can't find any?  Then you bought the wrong SAN!  Seriously, most manufacturers provide something around documentation - if Google doesn't help try using Bing... better yet, try contacting your VAR.

View Devices and Their Settings
To view devices and some of their related settings, use the following command:
esxcli -s [HOSTNAME] -u root -p [PASSWORD] storage nmp device list

Set Storage Array Type and Path Selection Policy
One of the first things you'll want to do is change the DEFAULT Path Selection Policy (PSP) for whatever storage array types (SATP) you're using.  This way, when adding a new LUN/device, the type will be set to the proper type automatically.  Most modern arrays support ROUND ROBIN.  To change the array type, use the following command:
esxcli -s [ESXHOST] -u root -p [PASSWORD] storage nmp satp set --default-psp VMW_PSP_RR --satp VMW_SATP_ALUA (or VMW_SATP_CX, etc.)

Note that this will not change/update existing LUNs/devices.  I recommend using the vSphere client for this unless you have many that need to be updated.  In this case, use the following command:
FOR /F %G IN ('esxcli --server [HOSTNAME] --username root --password [PASSWORD] storage nmp device list ^| findstr naa.600') DO esxcli --server [HOSTNAME] --username root --password [PASSWORD] storage nmp device set --device %G --psp VMW_PSP_RR

Note 1: In the above command, I loop through and set the RR policy for all devices that begin with "naa.600" - set the NAA ID for your environment as needed.

Note 2: the Linux command uses grep but Windows has FINDSTR.  Took a bit for me to figure out but if nothing else, this is the big find in this article - your welcome!

Set the IOPs Value
Finally, most array manufacturers recommend setting IOPS to "1".  To change the IOPs parameter, use the following command (again, thank you FINDSTR!):
FOR /F %G IN ('esxcli --server [HOSTNAME] --username root --password [PASSWORD] storage nmp device list ^| findstr naa.6005') DO esxcli --server [HOSTNAME] --username root --password [PASSWORD] storage nmp psp roundrobin deviceconfig set -d %G --iops 1 --type iops

Note:  As in the previous command, I loop through and set the IOPs parameter for devices that start with "naa.600" - set this for your environment as needed.

Now the "devices" hosted on your array should be optimally configured for use by vSphere 5.  Don't forget to go through and check each host.

Other Helpful Commands

esxcli storage vmfs extent list
esxcli storage core device detached list
esxcli storage core device detached remove -d [NAA ID]
esxcli storage core adapter rescan [ -A vmhba# | --all ]
esxcli storage filesystem list
esxcli storage filesystem unmount [-u <UUID> | -l <label> | -p <path> ]



No comments:

Post a Comment