多路径(multipath)简介及配置

0    293    1

Tags:

👉 本文共约78442个字,系统预计阅读时间或需295分钟。

普通的电脑主机都是一个硬盘挂接到一个总线上,这里是一对一的关系,而到了有光纤组成的SAN(Storage Area Network,存储网络)环境,由于主机和存储通过了光纤交换机连接,这样的话,就构成了多对多的关系。也就是说,主机到存储可以有多条路径可以选择,即主机到存储之间的**I/O多条路径可以选择。**

既然,每个主机到所对应的存储可以经过几条不同的路径,如果是同时使用的话,I/O流量如何分配?其中一条路径坏掉了,如何处理?还有在操作系统的角度来看,每条路径,操作系统会认为是一个实际存在的物理盘,但实际上只是通向同一个物理盘的不同路径而已,这样是在使用的时候,就给用户带来了困惑。多路径软件就是为了解决上面的问题应运而生的。多路径的主要功能就是和存储设备一起配合实现如下功能:

1.故障的切换和恢复

2.I/O流量的负载均衡

3.磁盘的虚拟化

由于多路径软件是需要和存储在一起配合使用的,不同的厂商基于不同的操作系统,都提供了不同的版本。并且有的厂商,软件和硬件也不是一起卖的,如果要使用多路径软件的话,可能还需要向厂商购买license才行。比如EMC公司基于linux下的多路径软件,就需要单独的购买license。

其中,EMC提供的就是PowerPath,HDS提供的就是HDLM。当然,使用系统自带的免费多路径软件包,同时也是一个比较通用的包,可以支持大多数存储厂商的设备,即使是一些不是出名的厂商,通过对配置文件进行稍作修改,也是可以支持并运行的很好的。

※ 请与IBM的RDAC、Qlogic的failover驱动区分开,它们都仅提供了Failover的功能,不支持Load Balance方式。但multipath根据选择的策略不同,可支持多种方式,如:Failover、Multipath等。

-------------------------- 多路径常用命令
rpm -ivh device-mapper-multipath-libs-0.4.9-72.el6.x86_64.rpm
rpm -ivh device-mapper-multipath-0.4.9-72.el6.x86_64.rpm

[root@raclhr-12cR1-N1 Packages]# rpm -qa|grep device-mapper
device-mapper-multipath-0.4.9-72.el6.x86_64
device-mapper-persistent-data-0.2.8-2.el6.x86_64
device-mapper-1.02.79-8.el6.x86_64
device-mapper-event-libs-1.02.79-8.el6.x86_64
device-mapper-event-1.02.79-8.el6.x86_64
device-mapper-multipath-libs-0.4.9-72.el6.x86_64
device-mapper-libs-1.02.79-8.el6.x86_64

rpm -qa|grep multipath
modprobe dm-multipath
modprobe dm-round-robin
lsmod |grep multipath
chkconfig --level 2345 multipathd on
chkconfig --list|grep multipathd
chkconfig --list multipathd
/sbin/mpathconf
service multipathd restart
#/etc/init.d/multipathd restart
ps -ef|grep multipathd
/sbin/mpathconf --enable --find_multipaths y --with_module y --with_chkconfig y
ll /etc/multipath.conf
multipath -F
multipath -v2
more /etc/multipath/wwids
multipath -ll
dmsetup ls|sort
ll /dev/dm-*
multipath -v3 -ll
multipathd -k
service multipathd reload

---------------获取wwid
--在RHEL 6中,可以通过如下方式获取磁盘wwid:
for i in cat /proc/partitions | awk {'print $4'} |grep sd; do echo "### $i: scsi_id --whitelist /dev/$i"; done
-- 在RHEL 5中,可以通过如下方式获取磁盘wwid:
for i in cat /proc/partitions | awk {'print $4'} |grep sd; do echo "### $i: scsi_id -g -u -s /block/$i"; done

编辑/etc/multipath.conf

for i in f g h i j k l m ;doecho "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --device=/dev/\$name\",RESULT==\"scsi_id --whitelisted --device=/dev/sd$i\",NAME=\"asm-disk$i\",OWNER=\"grid\",GROUP=\"asmadmin\",MODE=\"0660\""done

配置udev规则

脚本如下所示:

for i in f g h i j k l m ;doecho "KERNEL==\"dm-*\", BUS==\"block\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\",RESULT==\"scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i\",NAME=\"asm-disk$i\",OWNER=\"grid\",GROUP=\"asmadmin\",MODE=\"0660\"" >> /etc/udev/rules.d/99-oracleasm.rulesdone



Linux MultiPath多路径软件实施说明

原文地址:Linux MultiPath多路径软件实施说明 作者:kuqlan

Multipath的工作原理

当multipath启动的时候,它通过系统命令scsi_id -eg -s /block/sdX得到proc/partitions 里面所有块设备的 UUID(universally unique identify),然后把所有具有同一个UUID的块设备组成一个Group,在/dev/mapper 生产一个对应的单独的设备。当设备生成后就可以使用fdisk或者parted进行分区,分区可以使用kpartx命令进行注册,然后就可以是用系统命令进行创建文件系统和mount 。

一般在系列安装过程中都会同时安装device-mapper软件包,使用linux自带命令rpm查询一下是否已经安装次软件包。使用命令 rpm –ivh 进行安装,安装以下rpm包:

device-mapper-*

device-mapper-multipath-*

device-mapper-1*

启动多路径及配置多路径

启动多路径,通过mpathconf命令创建默认模板。创建默认配置,启动和激活multipathd进程,可以使用以下命令:

mpathconf --enable --with_multipathd y

配置完成后建议重新启动多路径软件:

/etc/init.d/multipathd restart

备注:启动完成后会在/etc/下生成multipath.conf 文件以及在/etc/multipath下生成bindings 及wwid,其中wwid记录了系统中所有挂载盘的盘唯一ID,Bindings记录了ID对应的映射盘一般绑定完后会在/dev/mapper下产生类似于mpathx等文件

备注-----------------------------------------------------------------------------------------------------

如果没有没有生成可以按照Deploying Oracle RAC 11g R2 Database on Red Hat EnterpriseLinux 6

的如下方式来进行操作:

\1. As the root user, install the device-mapper-multipath package using the yum package

manager.

# yum install device-mapper-multipath

\2. Copy the multipath.conf file found within /usr/share/doc/device-mapper-multipath-0.4.9/

to /etc/

# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/

\3. Capture the scsi id of the local disk(s) on the system.

# scsi_id --whitelisted --replace-whitespace –-device=/dev/sda

3600508b1001030353434363646301200

\4. Uncomment and modify the blacklist section within the /etc/multipath.conf file to include

the scsi id of the local disk on the system. Once complete, save the changes made to

the multipath.conf file.

blacklist {

wwid 3600508b1001030353434363646301200

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

devnode "^hd[a-z]"

}

\5. Start the multipath daemon.

# service multipathd start

Starting multipathd daemon: [ OK ]

\6. Enable the multipath daemon to ensure it is started upon boot time.

# chkconfig multipathd on

\7. Identify the dm- device, size, and WWID of each device mapper volume for Oracle

OCR and voting disks, data disks and recovery disks. In this example, volume mpathb

is identified via the following command:

# multipath -ll

多路径(multipath)简介及配置

Figure Multipath Device (mpathb)

\8. Uncomment the defaults section found within the /etc/multipath.conf file.

defaults {

udev_dir /dev

polling_interval 10

path_selector "round-robin 0"

path_grouping_policy multibus

getuid_callout "/lib/udev/scsi_id --whitelisted

--device=/dev/%n"

prio alua

path_checker readsector0

rr_min_io 100

max_fds 8192

rr_weight priorities

failback immediate

no_path_retry fail

user_friendly_names yes

}

NOTE: The standard options can be customized to better fit your storage array's

capabilities. Check with your storage vendor for details.

\9. Un-comment the multipath section found within the /etc/multipath.conf file and create

an alias for each device mapper volume in order to enable persistent naming of those

volumes. Once complete, save the changes made to the multipath.conf file. The output

should resemble the example below. For reference, refer the Oracle data volumes

created for the reference environment as displayed in Table 2.4.3: Oracle OCR,

Voting Disk, & Data File Sizes.

/etc/multipath.conf

multipaths {

multipath {

wwid 3600c0ff000d7e7a854a0f65101000000

alias db1

}

multipath {

wwid 3600c0ff000dabfe562a0f65101000000

alias db2

}

multipath {

wwid 3600c0ff000d7e7a874a0f65101000000

alias fra

}

multipath {

wwid 3600c0ff000dabfe585a0f65101000000

alias redo

}

multipath {

wwid 3600c0ff000dabfe596a0f65101000000

alias ocrvote1

}

multipath {

wwid 3600c0ff000dabfe5a2a0f65101000000

alias ocrvote2

}

multipath {

wwid 3600c0ff000dabfe5b4a0f65101000000

alias ocrvote3

}

}

10.Restart the device mapper multipath daemon.

# service multipathd restart

ok

Stopping multipathd daemon: [ OK ]

Starting multipathd daemon: [ OK ]

11.Verify the device mapper paths and aliases are displayed properly. Below is an

example of one device mapper device labeled fra.

# multipath -ll

fra (3600c0ff000d7e7a89e85ac5101000000) dm-10 HP,MSA2324fc

size=186G features='1 queue_if_no_path' hwhandler='0' wp=rw

|-+- policy='round-robin 0' prio=130 status=active

| |- 3:0:0:3 sdd 8:48 active ready running

| |- 3:0:1:3 sdh 8:112 active ready running

| |- 4:0:0:3 sdt 65:48 active ready running

| `- 4:0:1:3 sdx 65:112 active ready running

`-+- policy='round-robin 0' prio=10 status=enabled

|- 3:0:2:3 sdl 8:176 active ready running

|- 3:0:3:3 sdp 8:240 active ready running

|- 4:0:2:3 sdab 65:176 active ready running

`- 4:0:3:3 sdaf 65:240 active ready running

----------------------------------------------------------------------------------------------

配置文件

​ 默认情况下,DM-Multipath 为大多数多路径的使用提供配置值。另外,DM-Multipath 支持大多数常见的、支持 DM-Multipath 的存储阵列。默认配置值和支持的设备请参考 /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf.defaults 文件。

您可以编辑 /etc/multipath.conf 覆盖 DM-Multipath 的默认配置。如果有必要,您还可以默认配置文件不支持的存储阵列。

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!
多路径(multipath)简介及配置后续精彩内容已被小麦苗无情隐藏,请输入验证码解锁本站所有文章!
验证码:
请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“DB宝”或者“www_xmmup_com”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦。
  • 18509239930
  • 个人微信

  • DB宝
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部