1.安装iscsi

  1. yum install iscsi-initiator*

2.发现路径

注意:多路径两条都需要执行发现

  1. iscsiadm --mode discovery --type sendtargets --portal 192.168.5.235:3260
  2. iscsiadm --mode discovery --type sendtargets --portal 10.10.10.23:3260

3.查看发现记录

  1. iscsiadm --mode node
  2. iscsi信息:
  3. /var/lib/iscsi/
  4. /var/lib/iscsi/send_targets
  5. /var/lib/iscsi/nodes

4.添加磁盘

  1. iscsiadm --mode node --targetname iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd --portal 192.168.5.235:3260 --login
  2. iscsiadm --mode node --targetname iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd --portal 10.10.10.23:3260 --login
  3. 退出磁盘组
  4. iscsiadm --mode node --targetname iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd --portal 192.168.5.235:3260 --logout

5.multipath安装

  1. rpm -qa |grep device-mapper
  2. yum install device-mapper device-mapper-multipath
  3. multipath -ll 查看多路径状态

6.创建multipath配置文件

  1. /sbin/mpathconf --enable

7.添加配置策略

vi /etc/multipath.conf

  1. defaults {
  2. user_friendly_names yes
  3. path_grouping_policy multibus
  4. failback immediate
  5. no_path_retry fail
  6. }

8.启动服务

  1. service multipathd start
  2. service multipathd reload
  3. #查看磁盘信息
  4. ll /dev/mapper/mpath*
  5. ll /dev/dm*
  6. 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一样也是独一无二的。

  1. multipaths {
  2. multipath {
  3. wwid 14f504e46494c45524e71564841702d3345616c2d64465a4a
  4. alias mpatha
  5. }
  6. multipath {
  7. wwid 14f504e46494c45524969446e61792d754351472d6d337a4a
  8. alias mpathb
  9. }
  10. }
  11. -----------------------可选配置---------------------------
  12. devices {
  13. device {
  14. vendor "COMPAQ "
  15. product "HSV110 (C)COMPAQ"
  16. path_grouping_policy multibus
  17. getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
  18. path_checker readsector0
  19. path_selector "round-robin 0"
  20. hardware_handler "0"
  21. failback 15
  22. rr_weight priorities
  23. no_path_retry queue
  24. }
  25. }
  26. blacklist {
  27. }
  1. service multipathd restart
  2. multipath -ll #查看是否生效

10.multipath+udev

说明:
其中/dev/mapper/mpathn 是软件虚拟出来的多路径设备,可以被我们用来挂载使用
/dev/dm-n 这个是软件自身使用的,不能被软件以外使用。不可挂载。

  1. 获取RESULT
  2. Linux 7下,可以使用如下命令:
  3. # /usr/lib/udev/scsi_id -g -u /dev/sdb
  4. Linux 6下,可以使用如下命令:
  5. # /sbin/scsi_id -g -u /dev/sdb
  6. Linux 5下,可以使用如下命令:
  7. # /sbin/scsi_id -g -u -s /block/sdb/sdb
  8. udev绑定:
  9. cd /etc/udev/rules.d
  10. touch 99-oracle-asmdevices.rules
  11. --------centos6,redhat6 2种方式----------
  12. touch 99-oracle-asmdevices.rules
  13. 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"
  14. 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"
  15. udevadm info --query=all --name=/dev/mapper/mpatha |grep -i DM_UUID
  16. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45527065327354512d6f4945332d4c495679",NAME="asmdisk1",OWNER="grid",GROUP="asmadmin",MODE="0660"
  17. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45526c4b3238447a2d385737532d62497a70",NAME="asmdisk2",OWNER="grid",GROUP="asmadmin",MODE="0660"
  18. /sbin/udevadm control --reload-rules
  19. /sbin/start_udev 重启udev生效
  20. ------------centos7,redhat7 3种方式 ------------------------
  21. udevadm info --query=all --name=/dev/mapper/mpatha |grep -i DM_UUID
  22. 不推荐使用这种asmdisk的权限为root,不安全
  23. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45524e71564841702d3345616c2d64465a4a",SYMLINK+="asmdisk1",OWNER="grid",GROUP="asmadmin",MODE="0660"
  24. KERNEL=="dm-*",ENV{DM_UUID}=="mpath-14f504e46494c45524969446e61792d754351472d6d337a4a",SYMLINK+="asmdisk2",OWNER="grid",GROUP="asmadmin",MODE="0660"
  25. 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'"
  26. 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'"
  27. 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"
  28. 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"
  29. 重启UDEV:
  30. systemctl restart systemd-udevd.service
  31. udevadm control --reload-rules
  32. udevadm trigger
  33. systemctl status systemd-udevd.service

异常处理

Openfiler iscsiadm: No portals found 解决方法

注释掉/etc/initiators.deny文件里的内容即可正常连接。

  1. [root@localhost ~]# cat /etc/initiators.allow
  2. # PLEASE DO NOT MODIFY THIS CONFIGURATION FILE!
  3. # This configuration file was autogenerated
  4. # by Openfiler. Any manual changes will be overwritten
  5. # Generated at: Mon May 4 17:41:31 ALMT 2020
  6. iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd 192.168.5.0/24
  7. # End of Openfiler configuration
  8. [root@localhost ~]# cat /etc/initiators.deny
  9. # PLEASE DO NOT MODIFY THIS CONFIGURATION FILE!
  10. # This configuration file was autogenerated
  11. # by Openfiler. Any manual changes will be overwritten
  12. # Generated at: Mon May 4 17:41:31 ALMT 2020
  13. iqn.2006-01.com.openfiler:tsn.e9d3f5c823fd ALL
  14. # End of Openfiler configuration

emc 生产存储多路径配置
vi /etc/multipath.conf

  1. defaults {
  2. user_friendly_names yes
  3. }
  4. devices {
  5. device {
  6. vendor "DellEMC"
  7. product "PowerStore"
  8. path_selector "queue-length 0"
  9. path_grouping_policy "group_by_prio"
  10. path_checker "tur"
  11. detect_prio "yes"
  12. failback "immediate"
  13. no_path_retry 3
  14. rr_min_io_rq 1
  15. hardware_handler "1 alua"
  16. prio "alua"
  17. fast_io_fail_tmo 15
  18. max_sectors_kb 1024 #only for RHEL 6.9 and above
  19. }
  20. # other devices
  21. }