DM-Multipath Configuration
This guide covers configuring Linux Device-Mapper Multipathing (multipathd) for redundant SAN paths, automatic failover, and I/O load balancing across dual-controller iSCSI storage arrays.
Prerequisites
Section titled “Prerequisites”# Install multipath-toolsapt-get install -y multipath-tools
# Load kernel modulesmodprobe dm-multipathmodprobe dm-round-robinmodprobe dm-service-time
# Start multipathdsystemctl enable --now multipathdBasic Configuration
Section titled “Basic Configuration”multipath.conf
Section titled “multipath.conf”# Create multipath configurationcat > /etc/multipath.conf <<EOFdefaults { user_friendly_names yes find_multipaths smart path_checker tur path_grouping_policy group_by_prio prio alua failback immediate no_path_retry queue}
blacklist { devnode "^sd[a-z]" devnode "^hd[a-z]" devnode "^cciss.*"}
devices { device { vendor "LIO-ORG" product "*" path_checker tur hardware_handler "1 alua" path_grouping_policy group_by_prio prio alua failback immediate no_path_retry 10 }}EOF
# Restart multipathdsystemctl restart multipathdALUA Configuration
Section titled “ALUA Configuration”Configure ALUA on Target
Section titled “Configure ALUA on Target”# On iSCSI target (LIO)targetcli /iscsi/iqn.2024-01.hu.pilab:iscsiman.target-01/tpg1 set attribute alua_support=1
# Create ALUA grouptargetcli /iscsi/iqn.2024-01.hu.pilab:iscsiman.target-01/tpg1/alua create name=default_alua
# Set ALUA statetargetcli /iscsi/iqn.2024-01.hu.pilab:iscsiman.target-01/tpg1/alua/default_alua set alua_access_state=0Configure ALUA on Initiator
Section titled “Configure ALUA on Initiator”# multipath.confdevices { device { vendor "LIO-ORG" product "*" hardware_handler "1 alua" prio alua path_grouping_policy group_by_prio }}Path Policies
Section titled “Path Policies”Round Robin
Section titled “Round Robin”# multipath.confdefaults { path_grouping_policy multibus path_selector "round-robin 0" rr_min_io_rq 100}Service Time
Section titled “Service Time”# multipath.confdefaults { path_grouping_policy group_by_prio path_selector "service-time 0"}Queue Length
Section titled “Queue Length”# multipath.confdefaults { path_grouping_policy group_by_prio path_selector "queue-length 0"}Failover Configuration
Section titled “Failover Configuration”Immediate Failover
Section titled “Immediate Failover”# multipath.confdefaults { failback immediate}Manual Failover
Section titled “Manual Failover”# multipath.confdefaults { failback manual}Delayed Failover
Section titled “Delayed Failover”# multipath.confdefaults { failback 30 # 30 second delay}Path Checking
Section titled “Path Checking”TUR (Test Unit Ready)
Section titled “TUR (Test Unit Ready)”# multipath.confdefaults { path_checker tur}Direct I/O
Section titled “Direct I/O”# multipath.confdefaults { path_checker directio}Read Sector 0
Section titled “Read Sector 0”# multipath.confdefaults { path_checker readsector0}Monitoring
Section titled “Monitoring”Check Multipath Status
Section titled “Check Multipath Status”# List multipath devicesmultipath -ll
# Output example:# mpatha (360050764008181c60000000000000001) dm-0 LIO-ORG,iscsiman.target-01# size=100G features='0' hwhandler='1 alua' wp=rw# |-+- policy='service-time 0' prio=50 status=active# | `- 6:0:0:0 sdb 8:16 active ready running# `-+- policy='service-time 0' prio=10 status=enabled# `- 7:0:0:0 sdc 8:32 active ready runningCheck Path Status
Section titled “Check Path Status”# Check path statusmultipath -l | grep -A10 "mpatha"
# Check individual pathsmultipathd show pathsCheck Performance
Section titled “Check Performance”# Check I/O statsiostat -x /dev/dm-0 1
# Check throughputfio --name=multipath-test --ioengine=libaio --iodepth=16 \ --rw=randread --bs=4k --direct=1 --size=1G \ --filename=/dev/dm-0Troubleshooting
Section titled “Troubleshooting”Paths Not Detected
Section titled “Paths Not Detected”# Check iscsi sessionsiscsiadm -m session -P3
# Check multipathd statussystemctl status multipathd
# Check multipathd logsjournalctl -u multipathd -f
# Reconfigure multipathmultipathd reconfigurePath Failures
Section titled “Path Failures”# Check path statusmultipath -ll | grep failed
# Check path checkermultipathd show paths | grep failed
# Check logsjournalctl -u multipathd -f | grep -i failPerformance Issues
Section titled “Performance Issues”# Check path prioritiesmultipathd show paths
# Check path groupingmultipath -l | grep "policy="
# Check I/O schedulercat /sys/block/dm-0/queue/schedulerBest Practices
Section titled “Best Practices”1. Use ALUA
Section titled “1. Use ALUA”Always use ALUA for optimal path selection:
# multipath.confdevices { device { hardware_handler "1 alua" prio alua }}2. Configure Failover
Section titled “2. Configure Failover”Configure appropriate failover policy:
# multipath.confdefaults { failback immediate no_path_retry queue}3. Monitor Paths
Section titled “3. Monitor Paths”Regularly monitor path status:
# Check path statusmultipath -ll
# Set up monitoringecho "*/5 * * * * root multipath -ll | grep failed" >> /etc/crontab4. Test Failover
Section titled “4. Test Failover”Regularly test failover scenarios:
# Disable pathecho offline > /sys/block/sdb/device/state
# Check multipathmultipath -ll
# Re-enable pathecho running > /sys/block/sdb/device/state