How to Setup Multipath in Linux

A host system can be connected to a storage array using multiple physical connections and each physical connection provides one or more logical connections or paths between the host and a disk in the storage array.

Multipathing enables a host system to utilize multiple paths to a disk for redundancy and better I/O performance. In the event of a path failure all block I/O between the host and the disk are switched to an alternate path. This is referred to as Path Failover. Multipathing can be also configured to spread the block I/O load between the host and disk across a set of available paths.

Multipathing in Linux is offered by DM-Multipath which utilizes the device mapper framework of the kernel. The following table describes the components of DM-Multipath.

dm_multipath kernel module
re-routes block I/O and supports path failover
multipathd daemon
Monitor the paths and reacts to changes in the multipath configuration
multipath command
Configure and list multipath devices
kpartx command
Creates mapped devices for partitions on the multipath device
The following are the steps to setup DM-Multipath on CentOS / RHEL:

1. Verify device-mapper-multipath rpm is installed

# rpm -q device-mapper-multipath

2. Edit blacklist section of /etc/multipath.conf file

The blacklist section of /etc/multipath.conf file specifies the devices that are not used as a multipath device. Devices can be blacklisted based on device names (using devnode entry), wwid (using wwid entry) or vendor and prodouct id(using a device block entry) in the blacklist section. By default all devices are blacklisted using a devnode entry as shown below.
blacklist {
 devnode "*"

The above blacklist section needs to be modified to enable multipathing on your external storage device and to disable multipathing for devices such as internal disks, ram disk, floppy disk etc., for which DM-Multipath is not recommended.
Here is an example of blacklist section to disable most of the local devices that are not supported by DM-Multipath.
blacklist {
  devnode         "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
  devnode         "^hd[a-z][[0-9]*"

There are two devnode entries in the above example. The first one blacklists multipathing on devices such as ram disk, floppy disk, etc. The second devnode entry is to disable multipathing on local SCSI disks. This example assumes that the local disks devices have names like hda1, hdb1 etc.

The multipath -v3 command prints the multhipath devices, blacklisted devices, paths lists and other multipath configurations.

3. Change the default settings in /etc/multipath.conf file (if required)

DM-Multipath has many default settings that are compiled into the system. You can override these default settings by specifying them in the defaults section of /etc/multipath.conf file. This file also includes an example on how to configure some of the standard options. To change a default setting, you can just copy the relevant line from this example to the defaults section.

A complete list of all the default settings can be found in the file

4. Start the multipathd daemon

# service multipathd start

5. Enable multipathd service to start automatically

# chkconfig multipathd on

6. Verify the current multipath configuration

# multipath -ll
mpath0 (3600c0ff0001a6bcb6536d85206000000) dm-0 HP,P2000 G3 FC
[size=558G][features=1 queue_if_no_path][hwhandler=0][rw]
\_ round-robin 0 [prio=10][active]
 \_ 3:0:0:0 sda 8:0   [active][ready]

No comments:

Powered by Blogger.