查看:
1 查看主机上光纤HBA
lspci | grep Fibre
2 查看主机上光纤HBA的WWN
cat /sys/class/fc_host/host*/port_name
3 查看光纤HBA卡端口状态
cat /sys/class/fc_host/hostX/port_state
cat /sys/class/fc_host/host*/port_state
cat /sys/class/fc_host/host2/port_state
hostX:代表具体的光纤HBA卡端口。
配置:
1.安装多路径软件
# device-mapper-multipath主要提供multipathd和multipath等工具和 multipath.conf等配置文件
# multipath-tools 这个软件包可以产生模板,在多路径的管理和监控工具,主要进行路径状态的检测,管理工作
yum install -y device-mapper-multipath device-mapper-multipath-libs device-mapper device-mapper-libs device-mapper-event device-mapper-event-libs
2. 检查dm_multipath安装是否正常
lsmod | grep ^dm_multipath
若未成功加载使用下列命初始化DM,或重启系统
modprobe dm-multipath
modprobe dm-round-robin
3. 生成multipath配置文件
cp /usr/share/doc/device-mapper-multipath/multipath.conf /etc/multipath.conf
或通过
/sbin/mpathconf --enable
来自动生成配置文件
查看默认配置命令
multipath -t
4.获取wwid(存储上为wwid,linux操作系统上为uuid,unix操作系统上为wwid)
/usr/lib/udev/scsi_id -g -u -d /dev/sdN
或
ls /dev/disk/by-uuid
5. 配置多路径
# 黑名单语法
#blacklist {
# devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
# devnode "^hd[a-z]"
# wwid 1ATA_VBOX_HARDDISK_VB82d3887f-a892e124 #排除sda wwid
#}
#默认配置
#getuid_callout参数定义设置通过什么命令获取wwid(uuid)
#user_friendly_names使用用户友好的名称,而不是使用WWIDs作为名称
#默认为"round-robin 0"轮询
#queue-length 0 将下一个IO发送给负载最小的路径
#defaults {
# polling_interval 10
# path_selector "round-robin 0"
# path_grouping_policy multibus
# uid_attribute ID_SERIAL
# 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
#}
defaults {
user_friendly_names yes
find_multipaths yes
}
# 配置多路径,比如映射设备的名称,multipath负载均衡的方法
blacklist {
devnode "^sda"
}
defaults {
user_friendly_names no
}
multipaths {
multipath {
wwid 360a98000383037796e5d4d63674c6170
aliasocr01
}
multipath {
wwid 360a98000383037796e5d4d63674c6172
aliasocr02
}
multipath {
wwid 360a98000383037796e5d4d63674c6174
aliasocr03
}
multipath {
wwid 360a98000383037796e5d4d63674c616b
aliasfra01
}
multipath {
wwid 360a98000383037796e5d4d63674c6166
aliasdata01
}
}
devices {
device {
vendor "SUN"
product "SUN_6180"
path_grouping_policy multibus
getuid_callout "/sbin/scsi_id -g -u -s /block/%n"
path_checker readsector0
path_selector "round-robin 0"
}
}
6.启动多路径软件服务
linux6及以下:
[root@centos ~]# /etc/init.d/multipathd start
或
[root@centos ~]# service multipathd start
linux7:
[root@centos ~]# systemctl start multipathd
7.确认服务状态
linux6及以下:
[root@centos ~]# service multipathd status
linux7:
[root@centos ~]# systemctl status multipathd
8.设置服务开机启动
linux6及以下:
[root@centos ~]#
chkconfig –level 35 multipathd on
chkconfig –list multipathd
linux7:
systemctl enable multipathd
systemctl is-enabled multipathd
9.查看多路径
multipath -ll
10.刷新所有未使用的多路径设备映射
multipath -F
11.v2扫描磁盘
multipath -v2
#v3显示详细信息
multipath -v3
12.再次查看多路径
multipath -ll
注意:
multipath -r命令强制刷新multipath的规则
刷新规则
# #Linux5
/sbin/udevcontrol reload_rules
# #Linux6 and Linux7
udevadm control --reload-rules
重启UDEV服务
# #Linux5 and Linux6
/sbin/start_udev
# #Linux7
systemctl restart systemd-udevd.service
udev规则(oracle使用/dev/asm*磁盘名称)
multipaths {
multipath {
wwid 360a98000383037796e5d4d63674c6170
aliasocr01
}
multipath {
wwid 360a98000383037796e5d4d63674c6172
aliasocr02
}
multipath {
wwid 360a98000383037796e5d4d63674c6174
aliasocr03
}
multipath {
wwid 360a98000383037796e5d4d63674c616b
aliasfra01
}
multipath {
wwid 360a98000383037796e5d4d63674c6166
aliasdata01
}
}
配合
ACTION=="add|change", KERNEL=="dm-*", OPTIONS:="nowatch"
ACTION=="add|change", KERNEL=="dm-*", ENV{DM_UUID}=="mpath-360060160050068005caafe076c87e396", RUN+="/bin/sh -c 'mknod /dev/asm-ocr01 b $major $minor;chown grid:asmadmin /dev/asm-ocr01;chmod 0660 /dev/asm-ocr01'"
ACTION=="add|change", KERNEL=="dm-*", ENV{DM_UUID}=="mpath-360060160050068005caafe076c87e397", RUN+="/bin/sh -c 'mknod /dev/asm-data01 b $major $minor;chown grid:asmadmin /dev/asm-data01;chmod 0660 /dev/asm-data01'"
ACTION=="add|change", KERNEL=="dm-*", ENV{DM_UUID}=="mpath-360060160050068005caafe076c87e398", RUN+="/bin/sh -c 'mknod /dev/asm-fra01 b $major $minor;chown grid:asmadmin /dev/asm-fra01;chmod 0660 /dev/asm-fra01'"
ACTION=="add|change", KERNEL=="dm-*", OPTIONS:="nowatch"
ACTION=="add|change", KERNEL=="dm-*", ENV{DM_NAME}=="asm-ocr01", RUN+="/bin/sh -c 'mknod /dev/asm-ocr01 b $major $minor;chown grid:asmadmin /dev/asm-ocr01;chmod 0660 /dev/asm-ocr01'"
ACTION=="add|change", KERNEL=="dm-*", ENV{DM_NAME}=="asm-data01", RUN+="/bin/sh -c 'mknod /dev/asm-data01 b $major $minor;chown grid:asmadmin /dev/asm-data01;chmod 0660 /dev/asm-data01'"
ACTION=="add|change", KERNEL=="dm-*", ENV{DM_NAME}=="asm-fra01", RUN+="/bin/sh -c 'mknod /dev/asm-fra01 b $major $minor;chown grid:asmadmin /dev/asm-fra01;chmod 0660 /dev/asm-fra01'"
#vmware模式多路径
虚拟机关机后*.vmx文件添加
disk.EnableUUID = "TRUE"
操作系统内添加
cat >> /etc/scsi_id.config <<EOF
options=--whitelisted --replace-whitespace
EOF
虚拟机手动添加/dev/sdb的wwid到multipath信息库
multipath -a /dev/sdb
#查看wwid
more /etc/multipath/wwids
more /etc/multipath/bindings
#再次重启服务
systemctl restart multipathd
udevadm test /block/sdbACTION=="add|change", KERNEL=="dm-*", OPTIONS:="nowatch"
ACTION=="add|change", ENV{SUBSYSTEM}=="block", ENV{ID_SERIAL}=="36000c29fa0ec7945fd841e40096edc8d", RUN+="/bin/sh -c 'mknod /dev/asm-ocr01 b $major $minor;chown grid:asmadmin /dev/asm-ocr01;chmod 0660 /dev/asm-ocr01'"
multipaths {
multipath {
wwid 36000c29fa0ec7945fd841e40096edc8d
aliasocr01
uid 1001 #grid用户的uid
gid 1002 #grid用户的gid asmadmin
mode 0600
}
}
/usr/lib/udev/scsi_id -g -u -d /dev/sdN
#查看vendor
cat /sys/block/sdb/device/vendor
#查看product
cat /sys/block/sdb/device/model
cat /proc/scsi/scsi
lsscsi -v
#查看wwid
more /etc/multipath/wwids
more /etc/multipath/bindings