• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Yellow Bricks

by Duncan Epping

  • Home
  • ESXTOP
  • Stickers/Shirts
  • Privacy Policy
  • About
  • Show Search
Hide Search

load balancing active/active SAN’s

Duncan Epping · Apr 1, 2008 ·

Ernst, a regular poster of the Dutch VMug, posted a script for load balancing paths to an active/active SAN. What it does is select the next path for a LUN, in other words if there are four paths LUN1 will be reached via Path1, LUN2 via Path2 etc.

The script, also available for download here:

#!/bin/bash
for PATHS in 2 4 6 8
do
STPATHS=${PATHS}
COUNTER=”1″

for LUN in $(esxcfg-mpath -l | grep “has ${STPATHS} paths” | awk ‘{print $2}’)
do
esxcfg-mpath –lun=${LUN} –path=$(esxcfg-mpath -q –lun=${LUN} | grep FC | awk ‘{print $4}’ | awk ‘{print NR “S\t ” $0}’ | grep ${COUNTER}S | awk ‘{print $2}’) –preferred
COUNT=`expr ${COUNTER} + 1`
COUNTER=${COUNT}
if [[ ${COUNTER} -gt ${STPATHS} ]]
then
COUNTER=”1″
fi
done
done

This will result in the following outcome with “esxcfg-mpath -l”:

Disk vmhba2:1:4 /dev/sdh (512000MB) has 4 paths and policy of Fixed
FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:4 On active preferred
FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:4 On
FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:4 On
FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:4 On

Disk vmhba2:1:5 /dev/sdi (512000MB) has 4 paths and policy of Fixed
FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:5 On
FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:5 On active preferred
FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:5 On
FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:5 On

Disk vmhba2:1:6 /dev/sdj (307200MB) has 4 paths and policy of Fixed
FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:6 On
FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:6 On
FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:6 On active preferred
FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:6 On

Disk vmhba2:1:7 /dev/sdk (307200MB) has 4 paths and policy of Fixed
FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:7 On
FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:7 On
FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:7 On
FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:7 On active preferred

Disk vmhba2:1:8 /dev/sdl (512000MB) has 4 paths and policy of Fixed
FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:8 On active preferred
FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:8 On
FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:8 On
FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:8 On

Disk vmhba2:1:9 /dev/sdm (512000MB) has 4 paths and policy of Fixed
FC 16:0.1 50060b0000646c8a<->50060e8004f2e812 vmhba2:1:9 On
FC 16:0.1 50060b0000646c8a<->50060e8004f2e873 vmhba2:2:9 On active preferred
FC 19:0.1 50060b0000646062<->50060e8004f2e802 vmhba4:1:9 On
FC 19:0.1 50060b0000646062<->50060e8004f2e863 vmhba4:2:9 On

In other words, when you run this script each LUN will be addressed via a specific path and all HBA’s and SAN Disk Controllers will be used instead of the default first path / first controller policy. This will result in a better performance and distribution of load on the SAN Disk Controllers.

Related

Server 3.0.x, 3.5, ESX, Storage, VMware

Reader Interactions

Comments

  1. SUGLIANI Timo says

    1 April, 2008 at 22:00

    What about using rr policy directly ?

  2. Duncan Epping says

    1 April, 2008 at 22:30

    Well it’s definitely worth looking into, but it’s still experimental so I would not use it in a production site.

    • vinod says

      2 February, 2011 at 18:25

      This is great script. I need help in fixing an issue in my envirionment and looking for similar kind of script but with little changes.
      My storage is active/active EVA 81k. The LUN A at EVA is configured for Controller A Failover/Failback and lun B is configured for Controller B failover/failback

      Requirement:
      for lun A (vmhba1:0:1)we want to load balance it with 4 ports of controller A (8,9,a,b)
      for lun B (vmhba1:0:2)we want to load balance it with 4 ports of controller B (c,d,e,f)

      Could you please help to acheive the above requirement please.

      Thanks! in advance..

      • Duncan says

        2 February, 2011 at 20:03

        Why not just use Round Robin?

  3. Chris says

    2 April, 2008 at 07:31

    Hi,

    what happens if I loose one path, will ESX than automatically switch to an other or is the setup via the script fix?
    Regards,
    Chris

  4. Duncan Epping says

    2 April, 2008 at 08:20

    It will chose another path automatically. this is fixes as in “preferred path”.

  5. Ernst (Himself) says

    2 April, 2008 at 18:30

    @Duncan: We have the script running in a production enviroment with +/-1400 VM’s and its working splendid

    @Chris: If one patth fails ESX will automaticly failover to one of the other paths. We tested this extencively and it was working just fine even under heavy load

  6. Lasse says

    19 May, 2008 at 08:11

    Would be nice for us. Have over 400 VM’s
    I’m a new at scripting, anyone can get me a tip how to run this

  7. Duncan Epping says

    19 May, 2008 at 19:53

    Download the script. Upload it with winscp to your esx host. than run it with ./lbpath.sh

  8. bishop says

    17 October, 2008 at 22:09

    Toss a sleep into the loop there. Our EMC SAN doesn’t seem to be robust enough to handle all those path changes without wedging itself. Our customers were not pleased when we had to shut down an entire cluster, un-present a LUN, bring up the cluster without the VMs using that LUN, allow the SAN to run a verification and then re-present the LUN and bring up the VMs.

    so:

    then
    COUNTER=”1″
    + sleep 1800
    fi
    done
    done

    Don’t be like me, kids. Keep your SAN people happy.

  9. bishop says

    17 October, 2008 at 22:10

    Ugh. The previous looked much better before the webform bobbitted the spacing.

  10. Peter says

    3 November, 2008 at 13:48

    Script is not working for me…

    grep: 2: No such file or directory
    grep: paths.: No such file or directory
    awk: cmd. line:1: .{print
    awk: cmd. line:1: ^ parse error
    awk: cmd. line:2: (END OF FILE)
    awk: cmd. line:2: parse error
    grep: 4: No such file or directory
    grep: paths.: No such file or directory
    awk: cmd. line:1: .{print
    awk: cmd. line:1: ^ parse error
    awk: cmd. line:2: (END OF FILE)
    awk: cmd. line:2: parse error
    grep: 6: No such file or directory
    grep: paths.: No such file or directory
    awk: cmd. line:1: .{print
    awk: cmd. line:1: ^ parse error
    awk: cmd. line:2: (END OF FILE)
    awk: cmd. line:2: parse error
    grep: 8: No such file or directory
    grep: paths.: No such file or directory
    awk: cmd. line:1: .{print
    awk: cmd. line:1: ^ parse error
    awk: cmd. line:2: (END OF FILE)
    awk: cmd. line:2: parse error

    What did ido wrong?

  11. pichita says

    21 November, 2008 at 20:27

    >Peter
    mmm… dos2unix ?

  12. Duncan Epping says

    21 November, 2008 at 21:22

    probably indeed

  13. varya says

    21 December, 2008 at 22:05

    hi,i am a noob.
    i have 256 LUNs with MRU policy. i want to change all of them to fixed; can i use the above script?

  14. Duncan says

    21 December, 2008 at 22:26

    Yes you can, but is your SAN an active/active SAN or an Active/Passive SAN. If it’s an A/P SAN you must use MRU! Check the VMware compatability guide before you make the change!

    You would just need to add the line for the set to fixed bit.

    Duncan

  15. rotary laser levels says

    7 October, 2010 at 17:39

    Thank you so much for your opinion on load balancing active/active SAN’s » Yellow Bricks , I totally agree with you. It is fantastic to see a fresh outlook on this and I look forward to more.

  16. Kamil Azmer says

    27 April, 2011 at 17:16

    Hi.

    I like to ask regarding the esx storage policy, If i’m was using RR policy and not active the ALUA what will be happen and it’s will work for load-balancing?

    How it’s stable on vsphere 4.0 non update.

    What is the best setting for single processor controller with 2 path? Should i set to RR or FIXED?.

    Thank you

Primary Sidebar

About the author

Duncan Epping is a Chief Technologist in the Office of CTO of the Cloud Platform BU at VMware. He is a VCDX (# 007), the author of the "vSAN Deep Dive", the “vSphere Clustering Technical Deep Dive” series, and the host of the "Unexplored Territory" podcast.

Upcoming Events

May 24th – VMUG Poland
June 1st – VMUG Belgium

Recommended Reads

Sponsors

Want to support Yellow-Bricks? Buy an advert!

Advertisements

Copyright Yellow-Bricks.com © 2023 · Log in