Simple configuration of Multipath in Linux
1. Enable Multipath:
(1) Start The multipathd service
# Service multipathd start or #/etc/init. d/multipathd start
(2) modify the multipath configuration file/etc/multipath. conf:
A By default, all devices are in the multipath blacklist. Therefore, even if the multipathd service is started and added to the kernel module, multipath does not aggregate links, locate the following three rows and comment them out (add # At the beginning of the row)
# Devnode_blacklist {
# Devnode "*"
#}
B By default, after the dm device is generated in the multipath mode, a symbolic link in the name of the disk wwid is generated at the same time in/dev/mapper/to point to the corresponding dm device. To generate an mpath device, enable the user_friendly_names option to uncomment the three lines in the configuration file (remove the # sign at the beginning of the line)
Defaults {
User_friendly_names yes
}
(3) restart the multipathd service (the multipath service should be restarted after the multipath. conf file is modified)
(4) scan Disk
# Multipath-v2
After the preceding command is run, dm devices after link aggregation are displayed in the system, and corresponding devices are generated under the/dev/mapper/AND/dev/mpath/directories.
View the multipath Topology
# Multipath-ll
Another important file is/var/lib/multipath/bindings. The file contains the correspondence between the disk alias and the wwid. A typical example is as follows:
Mpath0 3600508b4000c3af700008000002d0000
(5) Pay attention to the problem that the multipath will also generate the corresponding dm device for the local disk. add the local disk to the blacklist in conf. For the configuration method, refer to the following example.
Devnode_blacklist {
Wwid 36005076b08164f4011ae88b23efb95fe
Devnode "^ (ram | raw | loop | fd | md | dm-| sr | scd | st) [0-9] *"
Devnode "^ hd [a-z]"
}
As shown in the preceding example, you can add the local disk to the blacklist by using the wwid or device name.
2. Fixed multipath device name:
The names of multipath devices are fixed in a one-to-one manner by using the wwid and the device alias. These devices corresponding to the alias are created in the/dev/mapper/directory, directly use the device in this directory during use.
(1) You can use/var/lib/multipath/bindings to obtain the wwid of all disks. After determining the alias of each disk, in/etc/multipath. add the corresponding configuration to the multipaths segment in conf. For example, name the disk with wwid 3600508b4000c3b9425c00000330000 as etl01 and the disk with wwid as Taobao as etl02. The configuration file is as follows:
Multipaths {
Multipath {
Wwid 3600508b4000c3b9425c00000330000
Alias etl01
}
Multipath {
Wwid 3600508b4000c3b9425c00000390000
Alias etl02
}
}
(2) After the configuration is complete, restart the multipathd service and run the following command to clear the existing multipath records.
# Multipath-F
Then, use multipath-v2 to scan the device again. The device file corresponding to the alias is generated in the/dev/mapper/directory.
# Ls/dev/mapper/
Control etl01 eth02
(3) If the storage links of multiple servers are identical and the device names on the same disk on each server are the same, you can configure the alias binding on one server, copy the configuration in the middle of multipaths {} to other servers, so that the devices under each server/dev/mapper/will be consistent.
Multipath for persistent LUN device names