Linux(centos7)如何实现配置iscsi存储多路径 及DM-Multipath的配置文件概述

Linux(centos7)如何实现配置iscsi存储多路径 及DM-Multipath的配置文件概述_第1张图片Linux(centos7)如何实现配置iscsi存储多路径 及DM-Multipath的配置文件概述_第2张图片

 安装多路径软件(系统默认安装)

#第一:安装多路径软件
    yum -y install device-mapper device-mapper-multipath

#第二:在CentOS7中启用多路径模块,mpathconf命令及相关模块加载(可以使用mpathconf -h查看用法)
使用 mpathconf 命令创建配置文件并启用多路径。若无需编辑该配置文件,可使用此命令启动多路径守护程序
    mpathconf --enable
    mpathconf --with_module y
    mpathconf --with_multipathd y

#第三:在CentOS7中,启动multipathd服务及设置开机自启
    systemctl start  multipathd.service
    systemctl enable multipathd.service

注意:系统决定多路径设备的属性时,会先检查多路径设置,然后检查设备设置,最后才检查多路径系统默认设置

挂载iscsi设备,并记录iscsi设备的全球识别符wwid号

#第一:发现
    iscsiadm --mode discovery --type sendtargets --portal 192.168.1.40
    iscsiadm --mode discovery --type sendtargets --portal 192.168.1.50

#第二:登录
    iscsiadm -d2 -m node -T iqn.1994-05.com.redhat:scst1 -p 192.168.1.40 --login
    iscsiadm -d2 -m node -T iqn.1994-05.com.redhat:scst1 -p 192.168.1.50 --login

#第三:查看磁盘(发现有两块相同大小容量的磁盘)
    fdisk -l

#第四:查看并记录iscsi设备的wwid号
    multipath -l

编辑多路径软件DM-Multipath的配置文件,并重启多路径软件

#第一:修改DM配置文件
    vim /etc/multipath.conf

defaults {
        user_friendly_names yes
        find_multipaths yes
}

multipaths {
        multipath {
                wwid    23237636464633731       #这是刚才记录的wwid号
                alias   vda                        #配置显示别名
                path_grouping_policy    multibus
                path_selector           "round-robin 0"     #轮巡策略
                failback                manual
                rr_weight               priorities
                no_path_retry           5
        }
}

blacklist {
        devnode "sda"
}

#第二:reload多路径软件
    systemctl reload  multipathd.service

#第三:查看磁盘设备(发现出现了一块/dev/mapper/vda的磁盘)
    fdisk -l

磁盘 /dev/mapper/vda:4293 MB, 4293693440 字节,8386120 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):4096 字节 / 524288 字节
磁盘标签类型:dos
磁盘标识符:0x00032eb1

#第四:分区,格式化,挂载使用

#第五:测试多路径
        down eth0 测试是否磁盘可写
        down eth1,同时启用eth0 测试是否磁盘可写

DM-Multipath的配置文件概述

    defaults    #DM Multipath 的常规默认设置。
    blacklist   #不被视为多路径的具体设备列表。
    blacklist_exceptions    #根据 blacklist 部分中的参数列出不在黑名单中的多路径设备
    multipaths  #各个独立多路径设备的特性设置。这些数值覆盖了在配置文件的 defaults 和 devices 部分中指定的数值
    devices     #各个存储控制器的设置。这些数值覆盖了在配置文件的 defaults 部分指定的数值。如果要使用不是默认支持的存储阵列,则可能需要为您的阵列创建 devices 子部分

    vim /etc/multipath.conf

# This is a basic configuration file with some examples, for device mapper
# multipath.
#
# For a complete list of the default configuration values, run either
# multipath -t
# or
# multipathd show config
#
# For a list of configuration options with descriptions, see the multipath.conf
# man page

## By default, devices with vendor = "IBM" and product = "S/390.*" are
## blacklisted. To enable mulitpathing on these devies, uncomment the
## following lines.
#blacklist_exceptions {
#  device {
#      vendor  "IBM"
#      product "S/390.*"
#  }
#}

## Use user friendly names, instead of using WWIDs as names.
defaults {
    user_friendly_names yes
    find_multipaths yes
}
##
## Here is an example of how to configure some standard options.
##
#
#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
#}
##
## The wwid line in the following blacklist section is shown as an example
## of how to blacklist devices by wwid.  The 2 devnode lines are the
## compiled in default blacklist. If you want to blacklist entire types
## of devices, such as all scsi devices, you should use a devnode line.
## However, if you want to blacklist specific devices, you should use
## a wwid line.  Since there is no guarantee that a specific device will
## not change names on reboot (from /dev/sda to /dev/sdb for example)
## devnode lines are not recommended for blacklisting specific devices.
##
#blacklist {
#       wwid 26353900f02796769
#  devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
#  devnode "^hd[a-z]"
#}
#multipaths {
#  multipath {
#      wwid            3600508b4000156d700012000000b0000
#      alias           yellow
#      path_grouping_policy    multibus
#      path_selector       "round-robin 0"
#      failback        manual
#      rr_weight       priorities
#      no_path_retry       5
#  }
#  multipath {
#      wwid            1DEC_____321816758474
#      alias           red
#  }
#}
#devices {
#  device {
#      vendor          "COMPAQ  "
#      product         "HSV110 (C)COMPAQ"
#      path_grouping_policy    multibus
#      path_checker        readsector0
#      path_selector       "round-robin 0"
#      hardware_handler    "0"
#      failback        15
#      rr_weight       priorities
#      no_path_retry       queue
#  }
#  device {
#      vendor          "COMPAQ  "
#      product         "MSA1000         "
#      path_grouping_policy    multibus
#  }
#}

multipaths {
        multipath {
                wwid    23237636464633731
                alias   vda
                path_grouping_policy    multibus
                path_selector           "round-robin 0"
                failback                manual
                rr_weight               priorities
                no_path_retry           5
        }
}

blacklist {
        devnode "sda"
}

这是centos7 多路径设备支持官方文档

https://qiniu.wsfnk.com/Red_Hat_Enterprise_Linux-7-DM_Multipath-zh-CN.pdf

你可能感兴趣的:(服务器,运维)