[[storage_multipath]] Multipath --------- ifdef::wiki[] :pve-toplevel: :title: Storage: Multipath endif::wiki[] Multipath lets a node reach a SAN LUN over several connections, called paths, so that I/O continues when one of them fails. Device-mapper multipath combines the paths of a LUN into one block device, a map, which every node identifies by the World Wide Identifier (WWID) of the LUN. Use it for shared LVM on iSCSI or Fibre Channel. {pve} sets up the maps on all nodes and shows their state under *Datacenter -> SAN*. An iSCSI storage with *Multipath* enabled requests the maps of its LUNs, a Fibre Channel LUN needs a multipath entry. NVMe namespaces use the multipath support of the kernel instead, see xref:storage_nvmeof[NVMe over Fabrics], and are not covered here. Prerequisites ~~~~~~~~~~~~~ * All nodes run pve-manager 9.2.34 or later. Older nodes do not apply the multipath configuration, and drop the *Multipath* option of iSCSI storages when they save the storage configuration. * `multipath-tools` is installed on all nodes; it is only a recommended package. * For iSCSI, the array allows the initiator name of each node, which *Datacenter -> SAN* shows. * For Fibre Channel, zoning and LUN masking allow the HBA ports of each node, whose WWPNs `cat /sys/class/fc_host/host*/port_name` lists. * The same empty LUN is presented to the nodes that use it over redundant paths. For Fibre Channel, rescan the hosts on each node after mapping a LUN: + ---- # for host in /sys/class/fc_host/host*; do echo '- - -' > /sys/class/scsi_host/${host##*/}/scan; done ---- + If the LUN does not show up, check that the target ports of the array are `Online`: + ---- # for port in /sys/class/fc_remote_ports/rport-*; do echo $(cat $port/{port_name,port_state,roles}); done ---- [[storage_multipath_setup]] Setting Up Shared LVM ~~~~~~~~~~~~~~~~~~~~ . On a node that can access the LUN, select *Shared LVM on iSCSI* or *Shared LVM on Fibre Channel* under *Datacenter -> Storage -> Add*. The *Add Shared LVM* menu of *Datacenter -> SAN* has the same setups. . For iSCSI, enter the *ID* of the new storage, a portal and the target. If no iSCSI storage logs the nodes in to that target yet, the setup adds one named after the ID with a `-base` suffix, or as set under *Advanced*. Clear the nodes in the list of initiator names that should not use the storages. . Select the LUN after checking that no host uses it and that no data on it must be kept. For Fibre Channel, enter the *ID* of the new storage, and *Nodes* under *Advanced* limits it to some nodes. The volume group is named after the ID unless set under *Advanced*. If virtual machines need snapshots, enable *Allow Snapshots as Volume-Chain* before creating their disks, see xref:pvesm_lvm_config[LVM configuration]. . Check the paths of every node in the result before placing guests on the storage, as the setup only checked the LUN on the node serving the web UI. Nodes show *Pending* while they set up the LUN, for up to a minute. A node that stays *Missing* cannot reach the LUN or has no map for it. A node with `1/1` has no redundancy. For Fibre Channel, the setup uses an existing map as it is, so check that a map set up by hand exists on all nodes. Otherwise, it adds a multipath entry if there is none, with *Expected Paths* set to the paths of the node serving the web UI if it has at least two. Check that number, as a fabric may have been down during the setup. If the setup fails, check the error and the task log before retrying. Closing the setup before it added its storage removes an iSCSI storage that it added, unless a storage uses it or it was changed meanwhile. If the web UI lost its connection, check whether that iSCSI storage is left over. Other changes stay, such as a multipath entry that the Fibre Channel setup added. [thumbnail="screenshot/gui-storage-add-iscsi-lun.png"] The setup refuses a LUN on which it finds data. To keep a volume group that a LUN already holds, add it under *Datacenter -> Storage -> Add -> LVM* with *Shared* enabled. To reuse a LUN whose data is no longer needed, stop its users on all hosts, remove its storage references and use *Wipe* under *Node -> SAN* as `root@pam`. The wipe removes partition tables and file system and LVM signatures, and zeroes the start of the LUN; it is not a secure erase. It refuses a LUN that a process on the node has open, but cannot detect every user, nor any on other hosts. Other nodes can still show the old usage afterwards. Without the guided setup, add an iSCSI storage under *Datacenter -> Storage -> Add -> iSCSI* with *Multipath* enabled and *Use LUNs directly* cleared, then an *LVM* storage with it as *Base storage*, the LUN as *Base volume* and *Shared* enabled. On the command line: ---- # pvesm add iscsi --portal --target \ --content none --managed-multipath 1 # pvesm list --content images # pvesm add lvm --vgname --base --shared 1 ---- Use the full volume ID from the listing, which ends in `dm-uuid-mpath-`. Adding the LVM storage creates the volume group. For Fibre Channel, look up the WWID of the LUN with `pvesm scan san-luns` and add an entry for it. Once the scan shows a by-id path with `dm-uuid-mpath-`, create the volume group and storage on that node: ---- # pvesm scan san-luns --output-format json # pvesh create /cluster/multipath/wwid --wwid --paths-expected # pvesh create /nodes/localhost/disks/lvm --name \ --device /dev/disk/by-id/dm-uuid-mpath- --add_storage 1 ---- To limit a storage to some nodes, set `--nodes ` on the entry or iSCSI storage and on the LVM storage. For Fibre Channel, leave out `--add_storage 1` and add the storage with `pvesm add lvm --vgname --shared 1 --nodes `. Then check under *Datacenter -> SAN* that every node has the LUN with all its paths. Adding Another LUN ~~~~~~~~~~~~~~~~~~ Present the new LUN to the same nodes. iSCSI storages detect it by themselves, for Fibre Channel rescan the hosts as shown in the prerequisites. Then run the guided setup again. For iSCSI, select the same target to use its iSCSI storage, after enabling *Multipath* on it if needed, see xref:storage_multipath_config[Existing Configurations]. [[storage_multipath_grow]] Growing a LUN ~~~~~~~~~~~~~ . Grow the LUN on the array. Never shrink a LUN in use. . On Fibre Channel nodes, rescan each path of the LUN with `echo 1 > /sys/block//device/rescan`, for example for `sdc`. iSCSI storages rescan by themselves. . Wait until `multipath -ll ` or *Node -> SAN* shows the new size on every node. A map grows once all its paths have grown; if it does not, run `multipathd resize map `. . Run `pvresize /dev/disk/by-id/dm-uuid-mpath-` on one node. [[storage_multipath_remove]] Removing a LUN ~~~~~~~~~~~~~~ These steps retire a LUN together with its LVM storage. {pve} never flushes a map or removes a WWID by itself. A map that queues I/O without paths can hang guests and LVM commands, so switch it to fail I/O before unmapping the LUN: . Stop all users of the LUN on all hosts. Remove the storage with `pvesm remove ` and run `vgchange -an ` on every node. Both keep the data. . Make the map fail I/O without paths with `pvesh set /cluster/multipath/wwid/ --no-path-retry fail`. Without an entry, create one with `pvesh create /cluster/multipath/wwid --wwid --no-path-retry fail`, adding `--nodes ` if only some nodes see the LUN. . Wait until `multipath -ll ` no longer shows `queue_if_no_path` on any node. Note the paths of the map, such as `sdc`, with the WWID of each from `/sys/block//device/wwid`. . Unmap the LUN on the array. . On every node, flush the map with `multipath -f `. If it stays busy, stop its remaining users instead of forcing it. Then remove each noted path whose WWID is unchanged with `echo 1 > /sys/block//device/delete`. . Remove the entry with `pvesh delete /cluster/multipath/wwid/`. Removed earlier, the default retry policy of the array would apply to the map again. . On every node, wait until the WWID is gone from `/etc/multipath/conf.d/pve-aliases.conf`, about ten seconds, then run `multipath -w `. Check that `grep -c '^//$' /etc/multipath/wwids` prints 0, also after the next status update. If I/O already hangs because the LUN was unmapped first, run `multipathd disablequeueing map ` on the affected nodes and continue. [[storage_multipath_disconnect]] Removing the iSCSI storage of a target does not log out its sessions; use `iscsiadm` for that once no LUN of the target is in use. Checking Path Failures ~~~~~~~~~~~~~~~~~~~~~ [thumbnail="screenshot/gui-datacenter-san.png"] *Datacenter -> SAN* shows configuration errors of the nodes, and the LUNs that {pve} manages or that a storage uses with their state on each node. Other maps, for example those of a third-party storage plugin, are only counted under *Other Maps*. *Node -> SAN* lists all LUNs of a node with their paths. [thumbnail="screenshot/gui-node-san.png", float="left"] *Used By* under *Node -> SAN* names the storage that uses a LUN or, without one, the process that has it open for writing, for example a guest with the LUN as disk from a third-party storage plugin. Such a LUN can neither be wiped nor selected in a guided setup. The *State* of a LUN on a node is its count of usable paths out of the paths it has, or of its *Expected Paths* if more: green if all are usable, for example `2/2`, orange if not, for example `1/2`. A LUN without a multipath map shows its count without a green check, as nothing fails over between its paths. For several nodes, *State* lists each state of a node that is not fine, with the nodes in it if not all are, the worst first. If the only such state is *Unknown*, it lists the other nodes too. *Paths by Node*, or a double click on the LUN, shows the state of each node. *Multipath* shows how the map is managed: by an explicit entry, by a storage, or *Unmanaged* if {pve} did not set it up. *Failed*:: No path is usable, for example `Failed (0/2)`; I/O queues or fails depending on the retry policy. *Missing*:: The node should have a map for the LUN but has none. Check the LUN under *Node -> SAN* on that node, the *Message* of the node and its access on the array. *Unknown*:: The node has no current report or cannot tell whether it has the map. Check the node under *Nodes*. A node sends a xref:notification_events[multipath notification] when not all paths of a LUN are usable in two consecutive checks, and again when none is left in two checks. A notification waits one more check while other LUNs of the node change the same way, so that it lists them too. A recovery notification follows once all paths of the LUN are usable in two consecutive checks. Without *Expected Paths*, a map with fewer paths than when the problem was notified does not count, as the kernel removes failed paths after a while. With it, such a map counts once it has that many paths, but the notification then says that the alert is cleared rather than that paths are restored, as it does if *Expected Paths* was lowered meanwhile, or for a single path without *Expected Paths*, which does not tell whether others are missing. Such a notification also follows once two reports of the node no longer list the LUN. A node whose *Multipath Setup* is not *OK*, for example because `multipathd` is not running, sends no such notifications; check its *Message* under *Datacenter -> SAN*. A LUN that is *Missing* on a node is not notified either. During a path failure, expand the LUN under *Node -> SAN* on the affected node to see which paths failed. For iSCSI, *Node -> SAN -> iSCSI* shows the sessions. After restoring the connection, check that every node has all its paths again. Scripts can read the states with `pvesh get /cluster/san/status`. An iSCSI storage expects one path per portal, so the array should report to each node only the portals it can reach. For Fibre Channel, set *Expected Paths* in the multipath entry, as the guided setup does. Otherwise, a path that the kernel removed after a failure no longer counts as missing. A node reports up to about 700 LUNs. With more, it reports `too many LUNs to report`, and its LUNs are only shown under *Node -> SAN*. [[storage_multipath_entries]] Multipath Entries ~~~~~~~~~~~~~~~~~ An entry in `/etc/pve/multipath.cfg` makes the nodes set up the map of a LUN and holds its settings. Fibre Channel and SAS LUNs need one. For a LUN of an iSCSI storage with *Multipath* enabled, an entry is only needed for its settings. Manage the entries under *Datacenter -> SAN*, where *Add Multipath Entry* takes the WWID of a selected LUN, or with `pvesh` under `/cluster/multipath/wwid`. alias:: The name of the map. nodes:: The nodes that should have the map. All nodes if unset. no-path-retry:: What happens to I/O while all paths are down: `queue` holds it until a path returns, `fail` fails it at once, and a number holds it for that many path checks. If unset, the settings for the array apply, which queue for some arrays. With `queue`, the guests and processes using the LUN hang for as long as no path returns, for example if the LUN was deleted on the array before it was removed from the nodes, see xref:storage_multipath_remove[Removing a LUN]. paths-expected:: The number of paths each node should have. With fewer usable paths, the LUN shows in orange on that node, for example `1/2`. .Configuration Example (`/etc/pve/multipath.cfg`) ---- wwid: 36001405a1b2c3d4e5f60718293a4b5c6 alias db-lun no-path-retry 12 nodes node1,node2 paths-expected 4 ---- [[storage_multipath_config]] Array Settings and Existing Configurations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use the built-in device profiles unless the array vendor requires changes. *Multipath Overrides* under *Datacenter -> SAN* edits `/etc/pve/multipath-overrides.conf` for all nodes, for example to set a retry count for one array model: ---- devices { device { vendor "" product "" no_path_retry 12 } } ---- {pve} sets `auto_resize grow_only`, so a map grows once all its paths have grown. This applies to all maps of a node, also to those of third-party storage plugins. To resize them by hand instead, add this to the overrides: ---- defaults { auto_resize never } ---- To move from a hand-made `/etc/multipath.conf`: . Back up the configuration of every node. Move array settings to the overrides, and per-LUN settings and Fibre Channel WWIDs to multipath entries. . Enable *Multipath* on the existing iSCSI storages and keep their LVM base volumes. Check `multipathd show config` on every node before removing local settings. Do not edit the generated `/etc/multipath/conf.d/pve-*.conf` files. . Once *Datacenter -> SAN* shows the LUNs on every node, check with `lsblk` for active volumes that still use a single path, and stop and start or migrate their guests. See also the xref:storage_lvm[shared LVM autoactivation guidance].