linux 自带的多路径

时间:2022-11-25 22:15:05

Linux自带多路径详解

  一、多路径解释

  多路径,顾名思义就是有多种选择的路径。在SAN或IPSAN环境,主机和存储之间外加了光纤交换机,这就导致主机和存储之间交换速度和效率增强,一条路径肯定是不行的,也是不安全不稳定的。多路径就是要来解决从主机到磁盘之间最快,最高效的问题。主要实现如下几个功能

  故障的切换和恢复

  IO流量的负载均衡

  磁盘的虚拟化

  多路径之前一直是存储厂商负责解决,竟来被拆分出来单独卖钱了。

  构架基本是这样的:存储,多路径软件,光纤交换机,主机,主机系统。

  二、LINUX下的multipath

  1、查看是否自带安装?

  [root@web2 multipath]# rpm -qa|grep device

  device-mapper-1.02.39-1.el5

  device-mapper-1.02.39-1.el5

  device-mapper-multipath-0.4.7-34.el5

  device-mapper-event-1.02.39-1.el5

  [root@web2 multipath]#

  2、安装

  rpm -ivh device-mapper-1.02.39-1.el5.rpm    #安装映射包

  rpm -ivh device-mapper-multipath-0.4.7-34.el5.rpm  #安装多路径包

  外加加入开机启动

  chkconfig �Clevel 2345 multipathd on          #设置成开机自启动multipathd

  lsmod |grep dm_multipath                      #来检查安装是否正常

  3、配置

# on the default devices.

blacklist {

devnode "^(ram|raw|loop|fd|md|dm-|sr|sr|scd|st)[0-9]*"

devnode "^hd[a-z]"

}

devices {

device {

vendor "HP"

path_grouping_policy multibus

features "1 queue_if_no_path"

path_checker readsector()

failback immediate

}

}<br><br>完整的配置如下:

blacklist {

devnode "^sda"

}

defaults {

user_friendly_names no

}

multipaths {

multipath {

wwid                    14945540000000000a67854c6270b4359c66c272e2f356321

alias                   iscsi-dm0

path_grouping_policy    multibus

path_checker            tur

path_selector           "round-robin 0"

}

multipath {

wwid                    14945540000000000dcca2eda91d70b81edbcfce2357f99ee

alias                   iscsi-dm1

path_grouping_policy    multibus

path_checker            tur

path_selector           "round-robin 0"

}

multipath {

wwid                    1494554000000000020f763489c165561101813333957ed96

alias                   iscsi-dm2

path_grouping_policy    multibus

path_checker            tur

path_selector           "round-robin 0"

}

multipath {

wwid                    14945540000000000919ca813020a195422ba3663e1f03cc3

alias                   iscsi-dm3

path_grouping_policy    multibus

path_checker            tur

path_selector           "round-robin 0"

}

}

devices {

device {

vendor                  "iSCSI-Enterprise"

product                 "Virtual disk"

path_grouping_policy    multibus

getuid_callout          "/sbin/scsi_id -g -u -s /block/%n"

path_checker            readsector0

path_selector           "round-robin 0"

}

}

 4、命令

[root@web2 ~]# multipath -h

multipath-tools v0.4.7 (03/12, 2006)

Usage: multipath        [-v level] [-d] [-h|-l|-ll|-f|-F|-r]

[-p failover|multibus|group_by_serial|group_by_prio]

[device]

-v level        verbosity level

0                    no output

1                    print created devmap names only

2                    default verbosity

3                    print debug information

-h              print this usage text

-b file         bindings file location

-d              dry run, do not create or update devmaps

-l              show multipath topology (sysfs and DM info)

-ll             show multipath topology (maximum info)

-f              flush a multipath device map

-F              flush all multipath device maps

-r              force devmap reload

-p policy       force all maps to specified policy :

failover             1 path per priority group

multibus             all paths in 1 priority group

group_by_serial      1 priority group per serial

group_by_prio        1 priority group per priority lvl

group_by_node_name   1 priority group per target node

device          limit scope to the device's multipath

(udev-style $DEVNAME reference, eg /dev/sdb

or major:minor or a device map name)

[root@web2 ~]#

  5、启动关闭

  # /etc/init.d/multipathd start      #开启mulitipath服务

  service multipath start

  service multipath restart

  service multipath shutdown

  6、如何获取wwid

  1、

  [root@vxfs01 ~]# cat /var/lib/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

  #

  mpath0 36006016051d50e0035744871c912de11

  mpath1 36006016051d50e0034744871c912de11

  mpath2 36006016051d50e0032744871c912de11

  mpath3 36006016051d50e0039744871c912de11

  mpath4 36006016051d50e003a744871c912de11

  2、

  [root@vxfs01 ~]# multipath -v3 |grep 3600

  sdb: uid = 36006016051d50e003a744871c912de11 (callout)

  sdc: uid = 36006016051d50e003a744871c912de11 (callout)

  sdd: uid = 36006016051d50e003a744871c912de11 (callout)

  sde: uid = 36006016051d50e003a744871c912de11 (callout)

  36006016051d50e003a744871c912de11 1:0:0:0 sdb 8:16  0   [undef][ready] DGC,RAI

  36006016051d50e003a744871c912de11 1:0:1:0 sdc 8:32  1   [undef][ready] DGC,RAI

  36006016051d50e003a744871c912de11 2:0:0:0 sdd 8:48  1   [undef][ready] DGC,RAI

  36006016051d50e003a744871c912de11 2:0:1:0 sde 8:64  0   [undef][ready] DGC,RAI

  Found matching wwid [36006016051d50e003a744871c912de11] in bindings file.