How to setup/create/configure fence_mpath
Environment
- Red Hat Enterprise Linux 6 and later (with the High Availability Add-on)
Issue
- How to configure
fence_mpathas stonith device in pacemaker cluster? fence_mpathdoes not successfully fence a node
Resolution
-
Edit
/etc/multipath.confon each node and in the defaults section, add areservation_keyline that contains a key (in hexadecimal form) that is specific to that node.For example, on
node1:defaults { user_friendly_names yes find_multipaths yes reservation_key 0x1 }And on node 2:
defaults { user_friendly_names yes find_multipaths yes reservation_key 0x2 } -
Reload multipath configuration on both nodes.
## RHEL 6 # service multipathd reload ## RHEL 7 and later # systemctl reload multipathd -
Configure a shared stonith device, specifying the list of multipath devices to manage, and the mapping of node names to key. Unlike
fence_scsithefence_mpathaccepts the multipath devices in thedevicesattribute. In order to create a map of node names to keys, we have to set an attribute to inform pacemaker the name of the value in key/value pairs withinpcmk_host_mapwith the attributepcmk_host_argument. Thepcmk_host_mapwill contain a mapping of the<cluster node name>:<key>. We will need to use the option--forceas we are omitting the required attributekeyfrom being configured (instead we are settingkeyas the value inpcmk_host_map). Do note that configuringfence_mpathas shared stonith device will prevent pacemaker from logging messages about a missingportattribute.# pcs stonith create mpath fence_mpath devices="/dev/mapper/mpath1,/dev/mapper/mpath2" pcmk_host_map="node1:1;node2:2" pcmk_monitor_action="metadata" pcmk_reboot_action="off" pcmk_host_argument="key" meta provides=unfencing --forceWith the release of This content is not included.
fence-agents-4.2.1-30.el7you no longer have to include the optionpcmk_host_argumentwithfence_mpathwhen usingpcmk_host_map. Thefence_mpathwill assume the value in the pair is thekeyfor the node.# pcs stonith create mpath fence_mpath devices="/dev/mapper/mpath1,/dev/mapper/mpath2" pcmk_host_map="node1:1;node2:2" pcmk_monitor_action="metadata" pcmk_reboot_action="off" meta provides=unfencingWith the release of
fence-agents-mpath-4.10.0-86.el9_6thereservation_keyvalue in/etc/multipath.confcan be used inpcmk_host_mapinstead of requiring only integers.# pcs stonith create mpath fence_mpath devices="/dev/mapper/mpath1,/dev/mapper/mpath2" pcmk_host_map="node1:0x1;node2:0x2" pcmk_monitor_action="metadata" pcmk_reboot_action="off" meta provides=unfencing -
Check that multipath devices contain registration keys used in stonith devices.
# mpathpersist -i -r -d /dev/mapper/mpath1 # mpathpersist -i -k -d /dev/mapper/mpath1If more debug information is needed for clearer diagnostics, feel free to use
-v 3or-v 4:# mpathpersist -v 3 -i -r -d /dev/mapper/mpath1 # mpathpersist -v 3 -i -k -d /dev/mapper/mpath1The first command should just show a single reservation with one of the node's keys (it doesn't matter which one), and the second command should show you several keys for each node (most likely corresponding to the number of paths each node has to the device). If seen, then unfencing is successful and can move on to testing fencing.
-
Test fencing by panicking a node with
echo c > /proc/sysrq-triggerthen running the mpathpersist commands from previous step again. The registration keys for fenced node should be gone, and if it was the reservation holder, the key on the reservation should correspond to a different node now. If that's the case and you don't see any errors, then fencing is set up successfully.
Note that fence_mpath is different from fence_scsi in that you have to supply a key for each node; it does not auto-generate a key for the node where it is being run. So the stonith device configuration will be different from what you may be used to with fence_scsi. You will have to specify keys explicitly in the stonith devices.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.