Configure iSCSI with Multipathing on RHEL 6
I recently had to configure iSCSI with multipathing on RHEL 6. It wasn't too hard and these instructions will presumably work with other Redhat based versions & distros
It involves installing/configuring the iSCSI utilities and then installing/configuring Device-Mapper. Device-Mapper will automatically discover devices with multiple paths and creates a mpath device that can be used to load balance/failover between all the paths.
- Install iSCSI and Device-Mapper
# yum install iscsi-initiator-utils # yum install device-mapper-multipath
- Start iSCSI
# chkconfig iscsi on # chkconfig iscsid on # service iscsi start # service iscsid start
- Find your hosts IQN and Update your iSCSI Array
Each iSCSi device will have a iSCSI Qualified Name (IQN). This name is used to manage LUN masking on the iSCSI arrays.
# cat /etc/iscsi/initiatorname.iscsiOnce you have your IQN you then need to go to your iSCSI array and carve out the LUNs you plan to present to the server. You will then need to map the IQNs to the LUNs to allow the server to see them. How this is accomplished depends on your iSCSI array and you will need to review it's documentation.
- iSCSI Discovery and Set Automatic Login
Once the server has been given permission to the LUNs you will need to have the server perform a iSCSI discovery of the array for it to see the LUNs.
# iscsiadm -m discovery -t sendtargets -p X.X.X.Xwhere X.X.X.X is an IP address of the iSCSI array. Any IP address that the array uses for iSCSI traffic should work. Then configure the host to automatically login to the discovered iSCSI Array.
# iscsiadm -m node -L automatic
- Check iSCSI Sessions
Now check to make sure the host has logged into the iSCSI Array.
# iscsiadm -m session tcp:  10.4.108.54:3260,4 iqn.1986-03.com.hp:storage.p2000g3.105011a8ce tcp:  10.4.108.52:3260,3 iqn.1986-03.com.hp:storage.p2000g3.105011a8ce tcp:  10.4.108.51:3260,1 iqn.1986-03.com.hp:storage.p2000g3.105011a8ce tcp:  10.4.108.53:3260,2 iqn.1986-03.com.hp:storage.p2000g3.105011a8ce
Above we can see that we have four paths to the iSCSI Array. In this environment my RHEL server has a single NIC on the iSCSI network and the iSCSI array has four NICs. This gives us four paths. If My RHEL server had a second NIC on the iSCSI network, then I would have eight paths.
If no sessions are active try restarting your iscsid service.
- Create Multipath Config File
The multipath.conf file, located under /etc, tells the device-mapper how to do the muitpathing. It configures such things as the path selector policy, what devices to include/exlude from mutipathing, if it does failback, etc.
There is a defaults section and then there should be a device specific section for your array. The default multipath.conf includes many common arrays, so you may not need to change much. In my case it didn't include the HP P2000 G3, so I did some googling and found some info on HP's web site on what I needed to configure.
In any case I recommend reading the manpath (and for the rest of the commands/config files also).
- Load Multipath Module and start Multipath Service
# modprobe dm-multipath # service multipathd start # chkconfig multipathd on
- Run the Multipath Command and Check Status
# multipath # multipath -l mpathc (3600c0ff00010a5ce0102db4d01000000) dm-6 HP,P2000 G3 iSCSI size=186G features='1 queue_if_no_path' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=-1 status=active |- 7:0:0:1 sdb 8:16 active undef running |- 6:0:0:1 sdc 8:32 active undef running |- 8:0:0:1 sdd 8:48 active undef running `- 5:0:0:1 sde 8:64 active undef running mpatha (3600508b1001c41183c9ba577f396df7c) dm-0 HP,LOGICAL VOLUME size=137G features='1 queue_if_no_path' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=-1 status=active `- 0:0:0:1 sda 8:0 active undef runningHere we can see that we have two multipath devices, mpatha and mpathc. mpatha is for the local disk and we can see a single path to sda. This could probably be configured to be ignored/black listed in the mutipath.conf. The second device is mpathc and it includes sdb, sdc, sdd, & sde. These four sd devices each correspond to an ISCSI path. As shown above my system has four paths to the iSCSI storage so I have four sd devices. You can also see that the IO policy is sent to “round-robin” which means that IO is sent down each of the four paths in a round-robin fashion.
- Create File System and Mount iSCSI LUN
Now you create a file system and mount the ISCSI LUN like any other disk, simply whatever mpath device is assigned to your LUN as the target for the operations.
Also when you are adding the iSCSI LUN to fstab make sure to include _netdev in the options, this tells the OS that the FS is dependent on network and needs to be mounted/unmounted after/before networking is started/shutdown.