Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

4.2. 配置文件黑名单

多路径配置文件的 blacklist 部分指定在系统配置多路径设备时不能使用的设备。黑名单中的设备将无法分组到多路径设备中。
In older releases of Red Hat Enterprise Linux, multipath always tried to create a multipath device for every path that was not explicitly blacklisted. As of Red Hat Enterprise Linux 6, however, if the find_multipaths configuration parameter is set to yes, then multipath will create a device only if one of three conditions are met:
  • There are at least two paths that are not blacklisted with the same WWID.
  • The user manually forces the creation of the device by specifying a device with the multipath command.
  • A path has the same WWID as a multipath device that was previously created (even if that multipath device does not currently exist). Whenever a multipath device is created, multipath remembers the WWID of the device so that it will automatically create the device again as soon as it sees a path with that WWID. This allows you to have multipath automatically choose the correct paths to make into multipath devices, without have to edit the multipath blacklist.
    If you have previously created a multipath device without using the find_multipaths parameter and then you later set the parameter to yes, you may need to remove the WWIDs of any device you do not want created as a multipath device from the /etc/multipath/wwids file. The following shows a sample /etc/multipath/wwids file. The WWIDs are enclosed by slashes (/):
    # Multipath wwids, Version : 1.0
    # NOTE: This file is automatically maintained by multipath and multipathd.
    # You should not need to edit this file in normal circumstances.
    #
    # Valid WWIDs:
    /3600d0230000000000e13955cc3757802/
    /3600d0230000000000e13955cc3757801/
    /3600d0230000000000e13955cc3757800/
    /3600d02300069c9ce09d41c31f29d4c00/
    /SWINSYS  SF2372         0E13955CC3757802/
    /3600d0230000000000e13955cc3757803/
    
With the find_multipaths parameter set to yes, you need to blacklist only the devices with multiple paths that you do not want to be multipathed. Because of this, it will generally not be necessary to blacklist devices.
If you do need to blacklist devices, you can do so according to the following criteria:
By default, a variety of device types are blacklisted, even after you comment out the initial blacklist section of the configuration file. For information, see 第 4.2.2 节 “根据设备名称将设备列入黑名单”.

4.2.1. 根据 WWID 将设备列入黑名单

您可根据全球识别号将单独的设备列入黑名单,即在配置文件的 blacklist 部分加入 wwid 条目。
以下示例显示了在配置文件中可将 WWID 为 26353900f02796769 的设备列入黑名单的行。
blacklist {
       wwid 26353900f02796769
}

4.2.2. 根据设备名称将设备列入黑名单

You can blacklist device types by device name so that they will not be grouped into a multipath device by specifying a devnode entry in the blacklist section of the configuration file.
The following example shows the lines in the configuration file that would blacklist all SCSI devices, since it blacklists all sd* devices.
blacklist {
       devnode "^sd[a-z]"
}
You can use a devnode entry in the blacklist section of the configuration file to specify individual devices to blacklist rather than all devices of a specific type. This is not recommended, however, since unless it is statically mapped by udev rules, there is no guarantee that a specific device will have the same name on reboot. For example, a device name could change from /dev/sda to /dev/sdb on reboot.
By default, the following devnode entries are compiled in the default blacklist; the devices that these entries blacklist do not generally support DM Multipath. To enable multipathing on any of these devices, you would need to specify them in the blacklist_exceptions section of the configuration file, as described in 第 4.2.6 节 “黑名单之外的设备”.
blacklist {
       devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
       devnode "^(td|ha)d[a-z]"
}

4.2.3. 根据设备类型将其加入黑名单

You can specify specific device types in the blacklist section of the configuration file with a device section. The following example blacklists all IBM DS4200 and HP devices.
blacklist {
       device {
               vendor  "IBM"
               product "3S42"       #DS4200 Product 10
       }
       device {
               vendor  "HP"
               product "*"
       }
}

4.2.4. Blacklisting By udev Property (Red Hat Enterprise Linux 7.5 and Later)

The blacklist and blacklist_exceptions sections of the multipath.conf configuration file support the property parameter. This parameter allows users to blacklist certain types of devices. The property parameter takes a regular expression string that is matched against the udev environment variable name for the device.
The following example blacklists all devices with the udev property ID_ATA.
blacklist {
        property "ID_ATA"
}

4.2.5. Blacklisting By Device Protocol (Red Hat Enterprise Linux 7.6 and Later)

You can specify the protocol for a device to be excluded from multipathing in the blacklist section of the configuration file with a protocol section. The protocol strings that multipath recognizes are scsi:fcp, scsi:spi, scsi:ssa, scsi:sbp, scsi:srp, scsi:iscsi, scsi:sas, scsi:adt, scsi:ata, scsi:unspec, ccw, cciss, nvme, and undef. The protocol that a path is using can be viewed by running the command multipathd show paths format "%d %P".
The following example blacklists all devices with an undefined protocol or an unknown SCSI transport type.
blacklist {
        protocol "scsi:unspec"
        protocol "undef"
}

4.2.6. 黑名单之外的设备

You can use the blacklist_exceptions section of the configuration file to enable multipathing on devices that have been blacklisted by default.
For example, if you have a large number of devices and want to multipath only one of them (with the WWID of 3600d0230000000000e13955cc3757803), instead of individually blacklisting each of the devices except the one you want, you could instead blacklist all of them, and then allow only the one you want by adding the following lines to the /etc/multipath.conf file.
blacklist {
        wwid "*"
}

blacklist_exceptions {
        wwid "3600d0230000000000e13955cc3757803"
}
当在配置文件的 blacklist_exceptions 指定设备时,您必须以指定黑名单的相同方法来指定例外情况。例如:在 devnode 黑名单条目中指定的设备无法使用 WWID 将其指定为例外情况,即使列入黑名单的设备和该 WWID 关联也不行。同样,devnode 例外也只适用于 devnode 条目,而 device 例外只适用于 device 条目。
The property parameter works differently than the other blacklist_exception parameters. If the parameter is set, the device must have a udev variable that matches. Otherwise, the device is blacklisted. This parameter allows users to blacklist SCSI devices that multipath should ignore, such as USB sticks and local hard drives. To allow only SCSI devices that could reasonably be multipathed, set this parameter to SCSI_IDENT_|ID_WWN) as in the following example.
blacklist_exceptions {
        property "(SCSI_IDENT_|ID_WWN)"
}