Monday, November 12, 2012

Luns policy round robin esxi


This article describes how to set policy for path selection to Round Robin ( default is Fixed) via command line. Doing it via Vsphere GUI could be quite time consumiung :)

  tested on Esxi 4.1.0 #1 SMP Release build-348481


1.       To generate the luns file in /tmp
1a. create file esxihosts with host names e.g.
Host1
Host2
Host3


for x in `cat esxihosts `; do echo --------------$x------------; ssh $x "esxcfg-mpath -b | grep ^naa | awk '{print $1}' > /tmp/luns "; done

2.       Copy script to all hosts in the cluster:
for x in `cat esxihosts `; do scp setroundrobin  $x:/tmp/; done

Script is:
cat setroundrobin

#!/bin/sh
#
# To generate the luns file in /tmp
#
# esxcfg-mpath -b | grep ^naa | awk '{print $1}' > /tmp/luns
#
# NOTE: remove the internal disk from the luns file first
#

luns=/tmp/luns

for i in `cat $luns`
do
   echo $i
   esxcli nmp device setpolicy --device $i --psp VMW_PSP_RR
   sleep 3
done

exit 0

3.       Execute the script on all hosts:
for x in `cat esxihosts `; do echo --------------$x------------; ssh $x " sh /tmp/setroundrobin"; done

No comments:

Post a Comment