load balancing active/active SAN’s

Posted by Duncan Epping in April 1st, 2008
Published in Server

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.


19 user comments or pingbacks in this post

Follow-up this post comment rss or leave a trackback
1. SUGLIANI Timo said,

What about using rr policy directly ?

2. Duncan Epping said,

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

3. Chris said,

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 said,

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

5. Ernst (Himself) said,

@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 said,

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 said,

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

8. bishop said,

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 said,

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

10. Peter said,

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 said,

>Peter
mmm… dos2unix ?

12. Duncan Epping said,

probably indeed

13. varya said,

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 said,

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

Leave A Reply Below

Currently browsing load balancing active/active SAN’s

 Username (*required)

 Email Address (*private)

 Website (*optional)

Pingback and trackback

Link trail from various blogs:
Pingback on April 1st, 2008 at 21:26
Pingback on February 3rd, 2009 at 01:54

Topics Search

Yellow-Bricks recommends:







VMware Fusion and VMware Workstation: Support Yellow-Bricks and get a 10% discount on select VMware products.

Train Signal:
Learn Virtualization technology with Train Signal. Support us and learn how to fully utilize VMware products at the same time! Click here for more info!

Advertisements

Recent Comments

Tags

Info