1.安装iscsi
yum install iscsi-initiator*
2.发现路径
注意:多路径两条都需要执行发现
iscsiadm --mode discovery --type sendtargets --portal 192.168.5.235:3260
iscsiadm --mode discovery --type sendtargets --portal 10.10.10.23:3260
3.查看发现记录
iscsiadm --mode node
iscsi信息:
/var/lib/iscsi/
/var/lib/iscsi/send_targets
/var/lib/iscsi/nodes
4.添加磁盘
iscsiadm --mode node --targetname iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd --portal 192.168.5.235:3260 --login
iscsiadm --mode node --targetname iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd --portal 10.10.10.23:3260 --login
退出磁盘组
iscsiadm --mode node --targetname iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd --portal 192.168.5.235:3260 --logout
5.multipath安装
rpm -qa |grep device-mapper
yum install device-mapper device-mapper-multipath
multipath -ll 查看多路径状态
6.创建multipath配置文件
/sbin/mpathconf --enable
7.添加配置策略
vi /etc/multipath.conf
defaults {
user_friendly_names yes
path_grouping_policy multibus
failback immediate
no_path_retry fail
}
8.启动服务
service multipathd start
service multipathd reload
#查看磁盘信息
ll /dev/mapper/mpath*
ll /dev/dm*
cat /etc/multipath/bindings
9.绑定多路径wwid
注意:没有绑定路径uuid 时,客户端重启,可能导致盘符发生变化
cat /etc/multipath/bindings 查看盘符wwid
ll /dev/disk/by-id/
ll /dev/disk/by-path/
wwid:
根据SCSI标准,每个SCSI磁盘都有一个WWID,类似于网卡的MAC地址,要求是独一无二。
uuid:
UUID是有文件系统在创建时候生成的,用来标记文件系统,类似WWID一样也是独一无二的。
multipaths {
multipath {
wwid 14f504e46494c45524e71564841702d3345616c2d64465a4a
alias mpatha
}
multipath {
wwid 14f504e46494c45524969446e61792d754351472d6d337a4a
alias mpathb
}
}
-----------------------可选配置---------------------------
devices {
device {
vendor "COMPAQ "
product "HSV110 (C)COMPAQ"
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
}
}
blacklist {
}
service multipathd restart
multipath -ll #查看是否生效
10.multipath+udev
说明:
其中/dev/mapper/mpathn 是软件虚拟出来的多路径设备,可以被我们用来挂载使用
/dev/dm-n 这个是软件自身使用的,不能被软件以外使用。不可挂载。
获取RESULT
在 Linux 7下,可以使用如下命令:
# /usr/lib/udev/scsi_id -g -u /dev/sdb
在 Linux 6下,可以使用如下命令:
# /sbin/scsi_id -g -u /dev/sdb
在 Linux 5下,可以使用如下命令:
# /sbin/scsi_id -g -u -s /block/sdb/sdb
udev绑定:
cd /etc/udev/rules.d
touch 99-oracle-asmdevices.rules
--------centos6,redhat6 共2种方式----------
touch 99-oracle-asmdevices.rules
KERNEL=="dm-*", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="14f504e46494c45527065327354512d6f4945332d4c495679", NAME="asmdisk1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="dm-*", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="14f504e46494c45526c4b3238447a2d385737532d62497a70", NAME="asmdisk2", OWNER="grid", GROUP="asmadmin", MODE="0660"
udevadm info --query=all --name=/dev/mapper/mpatha |grep -i DM_UUID
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45527065327354512d6f4945332d4c495679",NAME="asmdisk1",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45526c4b3238447a2d385737532d62497a70",NAME="asmdisk2",OWNER="grid",GROUP="asmadmin",MODE="0660"
/sbin/udevadm control --reload-rules
/sbin/start_udev 重启udev生效
------------centos7,redhat7 共3种方式 ------------------------
udevadm info --query=all --name=/dev/mapper/mpatha |grep -i DM_UUID
不推荐使用这种asmdisk的权限为root,不安全
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45524e71564841702d3345616c2d64465a4a",SYMLINK+="asmdisk1",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45524969446e61792d754351472d6d337a4a",SYMLINK+="asmdisk2",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45524e71564841702d3345616c2d64465a4a",RUN+="/bin/sh -c 'mknod /dev/asmdisk1 b $major $minor; chown grid:asmadmin /dev/asmdisk1; chmod 0660 /dev/asmdisk1'"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45524969446e61792d754351472d6d337a4a",RUN+="/bin/sh -c 'mknod /dev/asmdisk2 b $major $minor; chown grid:asmadmin /dev/asmdisk2; chmod 0660 /dev/asmdisk2'"
KERNEL=="dm-*", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="14f504e46494c45527065327354512d6f4945332d4c495679", NAME="asmdisk1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="dm-*", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="14f504e46494c45526c4b3238447a2d385737532d62497a70", NAME="asmdisk2", OWNER="grid", GROUP="asmadmin", MODE="0660"
重启UDEV:
systemctl restart systemd-udevd.service
udevadm control --reload-rules
udevadm trigger
systemctl status systemd-udevd.service
异常处理
Openfiler iscsiadm: No portals found 解决方法
注释掉/etc/initiators.deny文件里的内容即可正常连接。
[root@localhost ~]# cat /etc/initiators.allow
# PLEASE DO NOT MODIFY THIS CONFIGURATION FILE!
# This configuration file was autogenerated
# by Openfiler. Any manual changes will be overwritten
# Generated at: Mon May 4 17:41:31 ALMT 2020
iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd 192.168.5.0/24
# End of Openfiler configuration
[root@localhost ~]# cat /etc/initiators.deny
# PLEASE DO NOT MODIFY THIS CONFIGURATION FILE!
# This configuration file was autogenerated
# by Openfiler. Any manual changes will be overwritten
# Generated at: Mon May 4 17:41:31 ALMT 2020
iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd ALL
# End of Openfiler configuration
emc 生产存储多路径配置
vi /etc/multipath.conf
defaults {
user_friendly_names yes
}
devices {
device {
vendor "DellEMC"
product "PowerStore"
path_selector "queue-length 0"
path_grouping_policy "group_by_prio"
path_checker "tur"
detect_prio "yes"
failback "immediate"
no_path_retry 3
rr_min_io_rq 1
hardware_handler "1 alua"
prio "alua"
fast_io_fail_tmo 15
max_sectors_kb 1024 #only for RHEL 6.9 and above
}
# other devices
}