device-mapper (dm): working with multipath-tools. Part 1
Device-mapper (hereafter, dm) is one of the best collection of device drivers that I have ever worked with. It brings high availability, flexibility and more to the Linux 2.6 kernel. Device-mapper is a Linux 2.6 kernel infrastructure that provides a generic way to create virtual layers of a block device while supporting stripping, mirroring, snapshots, concatenation, multipathing, etc. While many modules are built on top of device-mapper, the focus of this article is on multipath-tools. Note that I will be using the terms multipath, multipath-tools and dm-multipath interchangeably to signify the same package. Also note that dm-multipath is the name of the repackaged multipath-tools redistributed under Red Hat in their Advanced Server Linux distribution.
Device-mapper multipath provides the following features (taken from HP dm-multipath reference guide):
- Allows the multivendor Storage RAID systems and host servers equipped with multivendor Host Bus Adapters (HBAs) redundant physical connectivity along the independent Fibre Channel fabric paths available
- Monitors each path and automatically reroutes (failover) I/O to an available functioning alternate path if an existing connection fails
- Provides an option to perform fail-back of the LUN to the repaired paths
- Implements failover or failback actions transparently without disrupting applications
- Monitors each path and notifies if there is a change in the path status
- Facilitates the load balancing among the multiple paths
- Provides CLI with display options to configure and manage Multipath features
- Provides all Device Mapper Multipath features support for any LUN newly added to the host
- Provides an option to have customized names for the Device Mapper Multipath devices
- Provides persistency to the Device Mapper Multipath devices across reboots if there are any change in the Storage Area Network
- Provides policy based path grouping for the user to customize the I/O flow through specific set of paths
Installing multipath-tools
Installing multipath-tools is usually as simple as going to your distributions repository, finding the package and select it to be installed. You can always download it and build it from source; but most likely your distribution should have it in its repository. Again, note that multipath-tools runs on top of device-mapper, so you will need device-mapper installed in order to utilize multipath-tools.
Configuring multipath-tools
The two main or key components to manage and monitor in the multipath-tools package are the multipath.conf file and also the multipathd daemon. Both serve vital functions to help load a configuration and monitor it. Sometimes after the multipath-tools package has been installed, the multipath.conf file could be found in /etc. If not you can always run a search for an existing template, which in some distributions can exist in the following directories:
Redhat –
$ cd /usr/share/doc/device-mapper-multipath-<version no.>/multipath.conf.defaults |
SuSE –
$ cd /usr/share/doc/packages/multipath-tools/multipath.conf.synthetic |
To edit the multipath.conf file simply open it up in a text editor:
$ vim /etc/multipath.conf |
This is just an example. Your multipath.conf file may be configured differently to accommodate certain features and limitations with the external data storage that you are working with
# Blacklist all devices by default. Remove this to enable multipathing |
In older versions of this multipath.conf file there is a known typo. In the blacklist section make sure that you correct the known error:
devnode “^hd[a-z][[0-9]*]” should read devnode “^hd[a-z][0-9]*”
Please understand what you set before activating the dm multipathed disk devices. For example the default_path_grouping_policy is set to failover and not multibus. That means despite the number of LUN path I have accessing the same logical volume, only one remains active at a single time. If the active path were to fail, then there would be a failover to a secondary defined path. Multibus simply send I/O requests across all paths which are marked as active unless failed. My path_checker is a Test Unit Ready (TUR), which is a low level SCSI command (opcode 0×00) to validate that the SCSI unit is ready to accept I/O requests. Also supported as path checkers are readsector0 and directio. Here is a guide to some of these field definitions.
Another extremely important field to this multipath.conf file is the blacklist. This tells the multipath-tools module to omit any device with the following characteristics, when scanning and grouping devices into device-mapper for multipathing.
There is so much more to this multipath.conf and I know I am only touching the surface of it but there is a wealth of information out there to help understand the vast amount of details buried within. I must admit though, that the coolest feature is that you can define specific settings for device specific environments. If you are working with a specific model of Compaq, Mylex or even Xyratex storage devices, these can be defined separately without interfering with any other connected storage device. Here is an example taken from the default multipath.conf file:
# device { |
Obviously your definition would not be commented out.
Earlier I had mentioned the multipathd daemon. You can start or stop the daemon in the following ways:
Redhat -
$ service multipathd start |
SuSE -
$ /etc/init.d/boot.multipath start |
Note that multipathd will not function appropriately until you have all the appropriate modules loaded. In my case it is dm_round_robin, dm_mirror, dm_multipath and dm_mod.
Scanning the SCSI bus for multipath devices
To have the utility scan or update the nodes on the scsi bus/channel(s) you must type the following command:
$ multipath -v2 |
Everything gets grouped according to WWID into a dm device. Multiple LUN mappings of the same LD will be given an alias (read below for these aliases).
To kill this mapping table you can simply run:
$ dmsetup remove_all |
or by removing each individual entry:
$ dmsetup remove /dev/mapper/32003000bb55555cd |
Once the mapping table is created you should be able to look in the following 3 paths to find a list of all dm devices either written as a dm-x device or under its WWID (World Wide Identifier).
$ ls /dev/dm- |
Pick one of the paths and format the device as you normally would with any other raw Linux device to be mounted.
$ mke2fs -F /dev/dm-0 ...... |
Mount the device and verify that it is mounted by typing df at the command line. Now to see all your active paths and monitor them during the test procedure you can type either multipath –ll or multipath –l at the command line.
$ multipath -ll |
The results show that there are two LUN paths representing a single logical volume. One is set to active while the other is enabled and ready until the path fails over.
Note that a lot of individuals make the mistake of formatting and mounting the sd devices. This is not allowed when using device-mapper. sdc and sdg present dm device dm-0 or WWID 32002000bb55555cd. These are virtual devices labeled to represent multiple LUN mappings to the same LD. So you must use the dm labels as opposed to the sd ones.
Stay tuned for Part 2. Whenever that is going to be.
