Saturday, 16 June 2012

How to Configure iSCSI Multipathing (MPIO) in VMware vSphere 5 using ESXCLI (UPDATE)


This is an update of January's post   How to Configure iSCSI Multipathing (MPIO) in VMware vSphere 5 using ESXCLI – with modifications to create just one iSCSI vSphere Standard Switch with two iSCSI VMkernels in, as opposed to a switch per VMkernel. Additionally, it now adds an iSCSI Virtual Machine Port Group. Credit to Stefan Lapers for his help.

The Commands Below Will ...

i. Enable the iSCSI Software Adapter
ii. Create one vSphere standard switch
iii. Create two VMkernel's for iSCSI
iv. Configure the 'Failover and Load Balancing' to have one active physical NIC per iSCSI VMkernel
v. Bind the iSCSI VMkernels to the iSCSI Software Adapter vmhba
vi. Add a send target portal
vii. Set the multi-pathing to default to round-robin
viii. Perform a rescan for storage devices and new volumes
ix. Add an iSCSI Virtual Machine Port Group
The commands can be applied via an SSH connection (PuTTY or similar) to the ESXi 5 host to be configured (Note: to enable SSH access, first start the SSH service on the host using the vSphere Client.) The commands can be run as a batch script by pasting into PuTTY (testing in the lab had a complete iSCSI and MPIO configuration applied in less that 20 seconds!)

Notes

1. In practice, Part 1 should be run separately to enable the iSCSI Software Adapter, in order to obtain the iSCSI Initiator name to input into the SAN software to allow access to volumes; also to check the vmhba number.
2. Edit the following variables as per requirements: vmnic4, vmnic5, 10.10.10.111 & subnet , 10.10.10.121 & subnet, vmhba33, 10.10.10.50:3260
3. The line in Part 6 works for a Storage Array Type of VMW_SATP_DEFAULT_AA (includes HP P4000.) If you want the multipathing to default to round-robin for devices not detected as VMW_SATP_DEFAULT_AA, then this line will need to be modified (for example: Equallogic uses VMW_SATP_EQL.)
4. See http://pubs.vmware.com/vsphere-50/index.jsp for the vSphere CLI Reference.
5. The lines beginning with 'echo' are just there to explain what the line underneath does
6. The below can be modified for than 2-way MPIO (vSphere 5 supports up to 8-way MPIO.)

The ESXCLI Commands

echo @ START COPYING HERE
echo @ PART 1 Enable iSCSI Software Adapter
esxcli iscsi software set -e on
echo @ PART 2 Create iSCSI vSwitch and VMkernels
echo @ Add new standard switch called iSCSI_Switch
esxcli network vswitch standard add -v iSCSI_Switch
echo @ Add vmnic4 and vmnic5 to iSCSI_Switch
esxcli network vswitch standard uplink add -u vmnic4 -v iSCSI_Switch
esxcli network vswitch standard uplink add -u vmnic5 -v iSCSI_Switch
echo @ Set vmnic4 and vmnic5 as active adapters for iSCSI_Switch
esxcli network vswitch standard policy failover set -a vmnic4,vmnic5 -v iSCSI_Switch
echo @ Add portgroups iSCSI_VMkernel1 and iSCSI_VMkernel2 to iSCSI_Switch
esxcli network vswitch standard portgroup add -p iSCSI_VMkernel1 -v iSCSI_Switch
esxcli network vswitch standard portgroup add -p iSCSI_VMkernel2 -v iSCSI_Switch
echo @ Add VMkernel interfaces vmk11 and vmk12 to iSCSI_VMkernel portgroups
esxcli network ip interface add -i vmk11 -p iSCSI_VMkernel1
esxcli network ip interface add -i vmk12 -p iSCSI_VMkernel2
echo @ Configure IP Addressing of vmk11 and vmk12
esxcli network ip interface ipv4 set -i vmk11 -I 10.10.10.111 -N 255.255.255.0 -t static
esxcli network ip interface ipv4 set -i vmk12 -I 10.10.10.121 -N 255.255.255.0 -t static
echo @ Apply iSCSI VMkernel failover order
esxcli network vswitch standard portgroup policy failover set -p iSCSI_VMkernel1 -a vmnic4
esxcli network vswitch standard portgroup policy failover set -p iSCSI_VMkernel2 -a vmnic5
echo @ PART 3 Bind iSCSI VMkernels to iSCSI Software Adapter
esxcli iscsi networkportal add -A vmhba33 -n vmk11
esxcli iscsi networkportal add -A vmhba33 -n vmk12
echo @ PART 4 Add portgroup iSCSI_VM_Network to iSCSI_Switch
esxcli network vswitch standard portgroup add -p iSCSI_VM_Network -v iSCSI_Switch
echo @ PART 5 Add send target portal for iSCSI SAN
esxcli iscsi adapter discovery sendtarget add -A vmhba33 -a 10.10.10.50:3260
echo @ PART 6 Set multipathing to default to round-robin
esxcli storage nmp satp set -P VMW_PSP_RR -s VMW_SATP_DEFAULT_AA
echo @ PART 7 Rescan for storage devices and new volumes
esxcli storage core adapter rescan -a
esxcli storage filesystem rescan
echo @ FINISH COPYING HERE

No comments:

Post a Comment