linux下安装多路径multipath

环境:

OS:Centos 7

 

1.安装多路径
[root@localhost ios]# yum install device-mapper-multipath

2.开机自启动
[root@localhost ios]# systemctl enable multipathd.service

3.配置配置文件

拷贝一份模板配置文件到etc目录
[root@localhost /]# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/

根据实际情况进行修改
# vi /etc/multipath.conf
blacklist {
    devnode "^sda"
}
defaults {
    user_friendly_names yes
    path_grouping_policy multibus
    failback immediate
    no_path_retry fail
}


4.启动服务
systemctl start multipathd.service

5.查看相关配置文件
服务器启动之后设备的wwid会自动添加到/etc/multipath/wwids文件中,wwid自动生成到该文件中,不需要进行编辑,如下:
[root@localhost multipath]# more /etc/multipath/wwids
# 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:
/VBOX_HARDDISK_VBa08577cb-9ee269dc/
/VBOX_HARDDISK_VB74301632-13d08c3c/
/VBOX_HARDDISK_VBfa94873f-504b6993/
/VBOX_HARDDISK_VB4f84df6d-a94b8da6/

绑定文件/etc/multipath/bindings,该文件里面的映射关系是自动生成的,不需要进行手工编辑
[root@localhost multipath]# more /etc/multipath/bindings
# Multipath bindings, Version : 1.0
# NOTE: this file is automatically maintained by the multipath program.
# You should not need to edit this file in normal circumstances.
#
# Format:
# alias wwid
#
mpatha VBOX_HARDDISK_VBa08577cb-9ee269dc
mpathb VBOX_HARDDISK_VB74301632-13d08c3c
mpathc VBOX_HARDDISK_VBfa94873f-504b6993
mpathd VBOX_HARDDISK_VB4f84df6d-a94b8da6


6.查看服务
[root@localhost ios]# multipath -ll
mpathd (VBOX_HARDDISK_VB4f84df6d-a94b8da6) dm-4 ATA     ,VBOX HARDDISK   
size=40G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 6:0:0:0 sde 8:64 active ready running
mpathc (VBOX_HARDDISK_VBfa94873f-504b6993) dm-3 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 5:0:0:0 sdd 8:48 active ready running
mpathb (VBOX_HARDDISK_VB74301632-13d08c3c) dm-2 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 4:0:0:0 sdc 8:32 active ready running
mpatha (VBOX_HARDDISK_VBa08577cb-9ee269dc) dm-1 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 3:0:0:0 sdb 8:16 active ready running
[root@localhost ios]#


执行lsblk命令就可以看到多路径磁盘mpatha了
[root@localhost ios]# lsblk
NAME              MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda                 8:0    0   50G  0 disk  
├─sda1              8:1    0  300M  0 part  /boot
├─sda2              8:2    0  5.6G  0 part  [SWAP]
└─sda3              8:3    0 44.1G  0 part  
  └─vgroot-lvroot 253:0    0 44.1G  0 lvm   /
sdb                 8:16   0   30G  0 disk  
└─mpatha          253:1    0   30G  0 mpath
sdc                 8:32   0   30G  0 disk  
└─mpathb          253:2    0   30G  0 mpath
sdd                 8:48   0   30G  0 disk  
└─mpathc          253:3    0   30G  0 mpath
sde                 8:64   0   40G  0 disk  
└─mpathd          253:4    0   40G  0 mpath
sr0                11:0    1 1024M  0 rom   
loop0               7:0    0  4.4G  0 loop  /mnt

7.查看设备情况

[root@localhost mapper]# ls -al /dev/mapper
total 0
drwxr-xr-x.  2 root root     160 Apr 11 21:37 .
drwxr-xr-x. 19 root root    3300 Apr 11 21:37 ..
crw-------.  1 root root 10, 236 Apr 10 05:30 control
lrwxrwxrwx.  1 root root       7 Apr 11 21:43 mpatha -> ../dm-1
lrwxrwxrwx.  1 root root       7 Apr 11 21:43 mpathb -> ../dm-2
lrwxrwxrwx.  1 root root       7 Apr 11 21:43 mpathc -> ../dm-3
lrwxrwxrwx.  1 root root       7 Apr 11 21:43 mpathd -> ../dm-4
lrwxrwxrwx.  1 root root       7 Apr 10 05:30 vgroot-lvroot -> ../dm-0

8.重新编辑配置文件
编辑 /etc/multipath.conf 文件,用于安置oracle rac


multipaths {
       multipath {
               wwid                    VBOX_HARDDISK_VBa08577cb-9ee269dc
               alias                   ocrdisk01
               path_grouping_policy    multibus
       }
       multipath {
               wwid                    VBOX_HARDDISK_VB74301632-13d08c3c
               alias                   ocrdisk02
               path_grouping_policy    multibus
       }
       multipath {
               wwid                    VBOX_HARDDISK_VBfa94873f-504b6993
               alias                   ocrdisk03
               path_grouping_policy    multibus
       }       
       multipath {
               wwid                    VBOX_HARDDISK_VB4f84df6d-a94b8da6
               alias                   datadisk01
               path_grouping_policy    multibus
       }  
}

9.重启加载配置
[root@localhost multipath]# multipath -r
查看加载后的配置
[root@localhost multipath]# multipath -ll
ocrdisk03 (VBOX_HARDDISK_VBfa94873f-504b6993) dm-3 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 5:0:0:0 sdd 8:48 active ready running
datadisk01 (VBOX_HARDDISK_VB4f84df6d-a94b8da6) dm-4 ATA     ,VBOX HARDDISK   
size=40G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 6:0:0:0 sde 8:64 active ready running
ocrdisk02 (VBOX_HARDDISK_VB74301632-13d08c3c) dm-2 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 4:0:0:0 sdc 8:32 active ready running
ocrdisk01 (VBOX_HARDDISK_VBa08577cb-9ee269dc) dm-1 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=active
  `- 3:0:0:0 sdb 8:16 active ready running

可以看到mapper下面的磁盘名称也改变了
[root@localhost mapper]# ls -al /dev/mapper/
total 0
drwxr-xr-x.  2 root root     160 Apr 11 22:16 .
drwxr-xr-x. 19 root root    3300 Apr 11 21:37 ..
crw-------.  1 root root 10, 236 Apr 10 05:30 control
lrwxrwxrwx.  1 root root       7 Apr 11 22:16 datadisk01 -> ../dm-4
lrwxrwxrwx.  1 root root       7 Apr 11 22:16 ocrdisk01 -> ../dm-1
lrwxrwxrwx.  1 root root       7 Apr 11 22:16 ocrdisk02 -> ../dm-2
lrwxrwxrwx.  1 root root       7 Apr 11 22:16 ocrdisk03 -> ../dm-3
lrwxrwxrwx.  1 root root       7 Apr 10 05:30 vgroot-lvroot -> ../dm-0
[root@localhost mapper]#


10.若不想使用配置别名的话,可以修改如下文件(但是不建议修改),将映射关系写到配置文件
vi /etc/multipath/bindings

ocrdisk01 VBOX_HARDDISK_VBa08577cb-9ee269dc
ocrdisk02 VBOX_HARDDISK_VB74301632-13d08c3c
ocrdisk03 VBOX_HARDDISK_VBfa94873f-504b6993
datadisk01 VBOX_HARDDISK_VB4f84df6d-a94b8da6

然后进行重新加载配置
删除后进行加载
[root@localhost multipath]# multipath -F
[root@localhost multipath]# multipath -r
[root@localhost multipath]# multipath -ll
ocrdisk03 (VBOX_HARDDISK_VBfa94873f-504b6993) dm-3 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=enabled
  `- 5:0:0:0 sdd 8:48 active ready running
datadisk01 (VBOX_HARDDISK_VB4f84df6d-a94b8da6) dm-4 ATA     ,VBOX HARDDISK   
size=40G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=enabled
  `- 6:0:0:0 sde 8:64 active ready running
ocrdisk02 (VBOX_HARDDISK_VB74301632-13d08c3c) dm-2 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=enabled
  `- 4:0:0:0 sdc 8:32 active ready running
ocrdisk01 (VBOX_HARDDISK_VBa08577cb-9ee269dc) dm-1 ATA     ,VBOX HARDDISK   
size=30G features=‘0‘ hwhandler=‘0‘ wp=rw
`-+- policy=‘service-time 0‘ prio=1 status=enabled
  `- 3:0:0:0 sdb 8:16 active ready running

linux下安装多路径multipath

上一篇:「Zabbix」- please increase CacheSize configuration parameter @20210412


下一篇:linux保存git账号密码