linux集成multipath软件用于识别多路径。
multipath和udev关系:
单块磁盘直接用udev做绑定和授权;multipath将多块磁盘合并成1块磁盘,再通过udev做绑定和授权。
补充:
在redhat6和redhat7略有些不同。
主要在于配置文件中这行代码在redhat7中没有。
redhat6配置文件
defaults {
user_friendly_names yes
find_multipaths yes
}
blacklist {
wwid 26353900f02796769
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^hd[a-z]"
devnode "^sda"
}
multipaths {
multipath {
wwid 14f504e46494c45524f564e7645362d374b306d2d68496c46
alias oracle-fs01-5G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c4552794350396f362d4d5048582d67575747
alias oracle-fs02-10G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
}
devices {
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
}
redhat7配置文件
defaults {
user_friendly_names yes
find_multipaths yes
}
blacklist {
wwid 26353900f02796769
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^hd[a-z]"
devnode "^sda"
}
multipaths {
multipath {
wwid 14f504e46494c455277514b5457692d7466796c2d4f745058
alias oracle-fs01-10G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c45523362636375652d473232552d53376150
alias oracle-fs02-10G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c455269475a474a452d64534f4e2d6976574e
alias oracle-arch-5G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c4552655a635138662d4667354c2d6f36596f
alias oracle-data-7G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
}
devices {
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
###用于redhat6,redhat7没有这个
#getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
###用于redhat6,redhat7没有这个
#getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
###用于redhat6,redhat7没有这个
#getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
###用于redhat6,redhat7没有这个
#getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
}
--------------------
前提条件
一、安装iscis initiator软件
二、iscsi服务是否启动和自启动
三、启动iscsi
四、识别存储
五、检查iscsi相关信息
另外,还要检查红帽的版本.
安装多路径软件
yum -y install device-mapper-multipath.x86_64
yum -y install device-mapper.x86_64
启动服务和开机启动
检查内核模块是否存在multipath,如果没有就添加模块
软件加载模块到内核中。当多路径出现故障后,通过什么方式切换,比如轮询方式
1、多路径模块
2、轮询算法
modprobe dm-multipath
modprobe dm-round-robin
启动服务
查看多路径状态
生成配置文件
提示multipath.conf不存在。需要运行/sbin/mpathconf生成。如果配置文件不生效,多路径服务可能启动不了。
(1)生成配置文件(推荐使用方式)
/sbin/mpathconf --enable
(2)直接拷贝配置文件到/etc目录下
查看多路径状态
配置文件说明!!!
vim /etc/multipath.conf
一:
排除本地盘,不让多路径识别到。
二:
wwid:就是硬盘的uuid
alias:别名,随便取名
path_grouping_policy:路径组的策略,比如两条链路同时启用还是使用单条链路。
默认:multibus,所有路径默认是能同时使用的。
failover:每个优先组群有一个路径
path_checker:
readsector0默认读取第一扇区。
path_selector:
选择下一条路径进行IO,默认是轮询。
failback:
故障切换,manual参数是手工
no_path_retry
当路径失效后,尝试5次后切换。
其中四条链路同时使用时最优的方法,单条链路带宽可能不够
三:
设备配置。
ventor:存储供应商。
product:产品型号
path_grouping_policy:默认组策略
getuid_callout:获取唯一设备号的程序。方法是:
/lib/udev/scsi_id --whitelisted --device=/dev/sdc
path_checker:访问路径的方法,比如读取0扇区
path_selector:默认采用轮询
hardware_handler:将切换路径组或者处理IO错误时执行硬件具体操作的模块。
默认为0
failback:
当路径坏了多少秒后再切换。
四、defaults中的默认参数
这个表示是否使用别名?
获取磁盘的UUID,从输出内容中找寻代码。获取磁盘信息等。
multipath -v3
paths list
----------
uuid hcil dev dev_t pri dm_st
2:0:0:0 sda 8:0 1 undef
14f504e46494c4552794350396f362d4d5048582d67575747 40:0:0:0 sdb 8:16 1 undef
14f504e46494c4552794350396f362d4d5048582d67575747 39:0:0:0 sdc 8:32 1 undef
14f504e46494c45524f564e7645362d374b306d2d68496c46 39:0:0:1 sde 8:64 1 undef
14f504e46494c4552794350396f362d4d5048582d67575747 38:0:0:0 sdd 8:48 1 undef
14f504e46494c45524f564e7645362d374b306d2d68496c46 40:0:0:1 sdf 8:80 1 undef
14f504e46494c4552794350396f362d4d5048582d67575747 37:0:0:0 sdg 8:96 1 undef
14f504e46494c45524f564e7645362d374b306d2d68496c46 38:0:0:1 sdh 8:112 1 undef
14f504e46494c45524f564e7645362d374b306d2d68496c46 37:0:0:1 sdi 8:128 1 undef
Mar 09 14:20:23 | Initialized new file [/etc/multipath/bindings]
改写配置文件!!!
(1)首先屏蔽本地的磁盘。设置这个参数,在生成多路径设备时忽略逻辑磁盘。用于屏蔽。
(2)有两种方法屏蔽磁盘
第一种方法是uuid格式类似于,uuid使用blkid查看。
第二种方法,直接屏蔽sda。
(3)改写multipath代码块。
multipath {
wwid 3600508b4000156d700012000000b0000 使用真实的多路径uuid
alias yellow 名字改成oracle-fs01
path_grouping_policy multibus
path_checker readsector0
path_selector "round-robin 0"
failback manual manual改成immediate,自动切换,不需要手工切换。
rr_weight priorities
no_path_retry 5
}
(4)修改device代码块
device {
vendor "COMPAQ " 可以改成openfiler
product "HSV110 (C)COMPAQ" 可以改成virtualDisk
path_grouping_policy multibus 策略默认
getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
failback 15
rr_weight priorities
no_path_retry queue
}
(5)将配置文件模板进行备份,将已经做好的配置文件拷贝到linux中。以下是修改好的配置文件。
--------------------
defaults {
user_friendly_names yes
find_multipaths yes
}
blacklist {
wwid 26353900f02796769
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^hd[a-z]"
devnode "^sda"
}
multipaths {
multipath {
wwid 14f504e46494c45524f564e7645362d374b306d2d68496c46
alias oracle-fs01-5G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
multipath {
wwid 14f504e46494c4552794350396f362d4d5048582d67575747
alias oracle-fs02-10G
path_grouping_policy multibus
#path_checker readsector0
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry 5
}
}
devices {
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
device {
vendor "openfiler"
product "virtual disk"
path_grouping_policy multibus
getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
path_checker readsector0
path_selector "round-robin 0"
hardware_handler "0"
}
}
(6)命令进行更新。这里报错,报无效的关键字,排错。将multipath大括号中的path_checker去掉即可。
(7)命令参考
查询多路径的运行状况
多路径其他参考命令
注意!!!dm-0,dm-1是设备内部盘,请勿使用!因为号码会变动
1、多路径配置完成后,生成两个设备文件。切记!
千万不能用dm-0,dm-1来挂载,因为这个是设备内部盘,盘号会变动的。
而oracle-fs01-5G这个才是标准多路径!!!!
多路径设置完成,生成新的磁盘设备,比如:oracle-system-10G
[root@oracle1 ~]# multipath -ll
oracle-data-7G (14f504e46494c4552655a635138662d4667354c2d6f36596f) dm-5 OPNFILER,VIRTUAL-DISK
size=6.9G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:3 sdj 8:144 active ready running
|- 34:0:0:3 sdm 8:192 active ready running
|- 35:0:0:3 sdp 8:240 active ready running
`- 36:0:0:3 sdq 65:0 active ready running
oracle-arch-5G (14f504e46494c455269475a474a452d64534f4e2d6976574e) dm-4 OPNFILER,VIRTUAL-DISK
size=5.0G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:2 sdf 8:80 active ready running
|- 34:0:0:2 sdi 8:128 active ready running
|- 35:0:0:2 sdn 8:208 active ready running
`- 36:0:0:2 sdo 8:224 active ready running
oracle-grid-10G (14f504e46494c455277514b5457692d7466796c2d4f745058) dm-2 OPNFILER,VIRTUAL-DISK
size=10G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:0 sdb 8:16 active ready running
|- 34:0:0:0 sdc 8:32 active ready running
|- 35:0:0:0 sdh 8:112 active ready running
`- 36:0:0:0 sdg 8:96 active ready running
oracle-system-10G (14f504e46494c45523362636375652d473232552d53376150) dm-3 OPNFILER,VIRTUAL-DISK
size=10G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
|- 33:0:0:1 sdd 8:48 active ready running
|- 34:0:0:1 sde 8:64 active ready running
|- 35:0:0:1 sdl 8:176 active ready running
`- 36:0:0:1 sdk 8:160 active ready running
[root@oracle1 ~]#
修改磁盘组给Oracle用户使用
groupadd asmadmin
useradd grid -g asmadmin
设置udev。
vim /etc/udev/rules.d/99-oracle.rules
KERNEL=="dm-*",OWNER="grid",GROUP="asmadmin",MODE="0660"
linux重启多路径服务。最好重启服务器。
systemctl restart multipathd.service