In modern data centers, servers are connected to a storage network. Typically, a server is connected to a redundant
SAN environment, using a redundant network infrastructure. But this can be risky because storage paths are presented twice and users doesn't know which device to use. Using a Linux multipath driver, a kernel-based I/O path manager for redundant connections, can solve this problem.
So, why would you use Linux multipathing in the data center? Imagine that a server is connected over two independent network paths to a storage area network (SAN) with one available logical unit number (LUN). The server would see that single LUN twice, meaning that the server would see two new disks presented by the SAN. If the server had one disk called /dev/sda before connecting to the SAN, it would see /dev/sdb and /dev/sdc. Both would refer to the same LUN on the SAN, but the server would see two different devices since different paths are used to access the device (see Listing 1).
msh:~ # lsscsi
[0:0:0:0] disk ATA WDC WD2500BEKT-7 01.0 /dev/sda
[1:0:0:0] cd/dvd TEAC DVD-ROM DV-28SW 3.2C /dev/sr0
[6:0:0:0] disk IET VIRTUAL-DISK 0 /dev/sdb
[7:0:0:0] disk IET VIRTUAL-DISK 0 /dev/sdc
Listing 1. Without using Linux multipath, you only see independent devices.
In this case, you can't connect to only one of these devices; if the device fails, your server won't benefit from the redundancy the SAN provides and it will fail to connect to storage.
The Linux kernel contains a multipath driver, which is thoroughly tested and fully integrated. Always use the Linux multipath driver instead of a proprietary driver from the storage vendor. Install the multipath driver -- this example uses OpenSUSE 12.3 Linux OS -- then use systemctl start multipathd.service to show a new device that the device mapper handles. For an overview of the current multipath topology, use the multipath –l command (see Listing 2).
msh:~ # multipath -l
14945540000000000de4669ff39769745da00b2c8269dba2e dm-0 IET ,VIRTUAL-DISK
size=9.8G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=0 status=active
| `- 6:0:0:0 sdb 8:16 active undef running
`-+- policy='service-time 0' prio=0 status=enabled
`- 7:0:0:0 sdc 8:32 active undef running
Listing 2. The multipath –l command gives an overview of current multipath topology in the Linux OS.
The multipath –l command lists all devices created using the UUID -- the long unique hexadecimal number on the first output line -- and the device mapper name. System admins can use either of these to address the multipath device.
Avoid using the /dev/dm-0 name to address the multipath device as a permanent solution. The kernel creates this name when it first finds the device. On the next reboot, when more devices are added to the device mapper, /dev/dm-0 might very well change to /dev/dm-1 or some other device number.
The UUID-based name isn't intuitive, so you'll want to define a more useable name. To do this, create a file /etc/multipath.conf and define a name for your multipath device (see Listing 3).
path_selector “queue-length 0”
Listing 3. Define logical names in /etc/multipathd.conf.
Reboot your server, and you'll have a multipath device that you can address as /dev/clustervol1. It will always give you access to the same storage device from your cluster nodes. If you're creating partitions, you'll partition only /dev/clustervol1.
About the author:
Sander van Vugt is an independent trainer and consultant based in the Netherlands. He is an expert in Linux high availability, virtualization and performance. He has authored many books on Linux topics, including Beginning the Linux Command Line, Beginning Ubuntu LTS Server Administration and Pro Ubuntu Server Administration.