Friday, November 27, 2020

Rename / Change the Multipath Device Names on Linux

 Each multipath device has a World Wide Identifier (WWID), which is guaranteed to be globally unique and unchanging. By default, the name of a multipath device is set to its WWID. Alternately, you can set the user_friendly_names option in the multipath configuration file, which sets the alias to a node-unique name of the form mpathn.

Although the form mpathn is much more friendly than WWID, many system administrators and database administrators like to use customized more meaningful names. For example, on Oracle Linux 7, a multipath disk is automatically nemed as /dev/mapper/mpathb, and it will be added to ASM diskgroup DATA. In order to distinguish it easily, I want to rename mpathb to asmDATA01 as following, 

1. Stop multipathd service

The service starts multipathd daemon which checks for failed paths and reconfigures the multipath map, so that this map regains its maximum performance and redundancy. The daemon reactivates restored paths, adds/removes device files as needed, and runs the multipath utility when events occur that require a device map reconfiguration. Restarting / stopping this service will not have impact on current online devices 

Run systemctl status multipathd to check if daemon is running
[root@host01]# systemctl status multipathd
● multipathd.service - Device-Mapper Multipath Device Controller
   Loaded: loaded (/usr/lib/systemd/system/multipathd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-11-26 21:14:24 EST; 21h ago
  Process: 18357 ExecStart=/sbin/multipathd (code=exited, status=0/SUCCESS)
  Process: 18354 ExecStartPre=/sbin/multipath -A (code=exited, status=0/SUCCESS)
  Process: 18352 ExecStartPre=/sbin/modprobe dm-multipath (code=exited, status=0/SUCCESS)
 Main PID: 18360 (multipathd)
   CGroup: /system.slice/multipathd.service
           └─18360 /sbin/multipathd

Run systemctl stop multipathd to stop the daemon
[root@host01]# systemctl stop multipathd
[root@host01]#
[root@host01]# systemctl status multipathd
● multipathd.service - Device-Mapper Multipath Device Controller
   Loaded: loaded (/usr/lib/systemd/system/multipathd.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Fri 2020-11-27 18:26:25 EST; 4s ago
  Process: 18357 ExecStart=/sbin/multipathd (code=exited, status=0/SUCCESS)
  Process: 18354 ExecStartPre=/sbin/multipath -A (code=exited, status=0/SUCCESS)
  Process: 18352 ExecStartPre=/sbin/modprobe dm-multipath (code=exited, status=0/SUCCESS)
 Main PID: 18360 (code=exited, status=0/SUCCESS)
 
2. Change mpathb to asmDATA01 in multipath binding file /etc/multipath/bindings

Original contents of /etc/multipath/bindings
mpatha 360060e8012a1b4005040a1b400000132
mpathb 360060e8012a1b4005040a1b400000133

New contentes
mpatha 360060e8012a1b4005040a1b400000132
asmDATA01 360060e8012a1b4005040a1b400000133

3. Remove old device name

Run multipath -f to remove old device name
[root@host01]# ls -l /dev/mapper
total 0
crw------- 1 root root 10, 236 Nov 17 12:17 control
lrwxrwxrwx 1 root root       8 Nov 26 18:56 mpatha -> ../dm-11
lrwxrwxrwx 1 root root       8 Nov 26 18:56 mpathb -> ../dm-13

[root@host01]# multipath -f /dev/mapper/mpathb

[root@host01]# ls -l /dev/mapper
total 0
crw------- 1 root root 10, 236 Nov 17 12:17 control
lrwxrwxrwx 1 root root       8 Nov 26 18:56 mpatha -> ../dm-11

4. Start multipathd service

Run systemctl start multipathd
[root@host01]# systemctl start multipathd

[root@host01]# systemctl status multipathd
● multipathd.service - Device-Mapper Multipath Device Controller
   Loaded: loaded (/usr/lib/systemd/system/multipathd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-11-27 18:26:38 EST; 4s ago
  Process: 20014 ExecStart=/sbin/multipathd (code=exited, status=0/SUCCESS)
  Process: 20011 ExecStartPre=/sbin/multipath -A (code=exited, status=0/SUCCESS)
  Process: 20009 ExecStartPre=/sbin/modprobe dm-multipath (code=exited, status=0/SUCCESS)
 Main PID: 20017 (multipathd)
   CGroup: /system.slice/multipathd.service
           └─20017 /sbin/multipathd

5. Validate if new device asmDATA01 is created 
[root@host01]# ls -l /dev/mapper
total 0
lrwxrwxrwx 1 root root       8 Nov 26 19:01 asmDATA01 -> ../dm-13
crw------- 1 root root 10, 236 Nov 17 12:17 control
lrwxrwxrwx 1 root root       8 Nov 26 18:56 mpatha -> ../dm-11

No comments: