阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Linux iSCSI Multipath多路径及名称持久化配置

124次阅读
没有评论

共计 7036 个字符,预计需要花费 18 分钟才能阅读完成。

环境:
iscsi server : openfiler eth0/eth1 bind->192.108.26.100
                   iqn.2006-01.com.openfiler:tsn.b45ae024d498
                   iqn.2006-01.com.openfiler:tsn.67571ed98f10
iscsi client : CentOS 6.6 eth1->192.108.26.117    eth2->192.108.26.118

1. 安装 iscsi-initiator
[root@ct6601 ~]# yum install -y iscsi-initiator-utils

2. 安装 device-mapper-multipath
[root@ct6601 ~]# yum install -y device-mapper-multipath

3. 设定 multipathd 服务开机自启动
[root@ct6601 etc]# chkconfig multipathd on

4. 测试网卡 eth1,eth2 能否 ping 通 iscsi server
[root@ct6601 ~]# ping -I eth1 192.108.26.100
[root@ct6601 ~]# ping -I eth2 192.108.26.100

5. 在 /etc/sysctl.conf 添加以下, 否则在第 8 步可能一直 timeout
[root@ct6601 ~]# cat >> /etc/sysctl.conf << EOF
net.ipv4.conf.eth1.rp_filter=2
net.ipv4.conf.eth2.rp_filter=2
EOF

[root@ct6601 ~]# sysctl -p

6. 修改 /etc/iscsi/iscsid.conf 中的 timeout 时间
[root@ct6601 ~]# cat /etc/iscsi/iscsid.conf |grep timeout|grep -v ^#
node.session.timeo.replacement_timeout = 2
node.conn[0].timeo.login_timeout = 2
node.conn[0].timeo.logout_timeout = 2
node.conn[0].timeo.noop_out_timeout = 2
node.session.err_timeo.abort_timeout = 2
node.session.err_timeo.lu_reset_timeout = 2
node.session.err_timeo.tgt_reset_timeout = 2

7. 建 iscsi iface
[root@ct6601 ~]# iscsiadm -m iface -I iface1 -o new

[root@ct6601 ~]# iscsiadm -m iface -I iface2 -o new

# 查看 /var/lib/iscsi/ 下的文件
[root@ct6601 ~]# cd /var/lib/iscsi/
[root@ct6601 iscsi]# du -sh *
12K    ifaces
4.0K    isns
4.0K    nodes
4.0K    send_targets
4.0K    slp
4.0K    static
# 绑定 iscsi iface 到网卡
[root@ct6601 iscsi]# iscsiadm -m iface -I iface1 -o update -n iface.net_ifacename -v eth1

[root@ct6601 iscsi]# iscsiadm -m iface -I iface2 -o update -n iface.net_ifacename -v eth2

8. 发现 iscsi target
[root@ct6601 iscsi]# iscsiadm -m discovery -t st -p 192.108.26.100  -I iface1 -I iface2
Starting iscsid:                                          [OK]
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.b45ae024d498
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.67571ed98f10
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.b45ae024d498
192.108.26.100:3260,1 iqn.2006-01.com.openfiler:tsn.67571ed98f10

# 发现后相关文件已经生成
[root@ct6601 iscsi]# du -sh *
12K    ifaces
4.0K    isns
36K    nodes
28K    send_targets
4.0K    slp
4.0K    static

9. 启动 iscsi 服务, 建立连接
[root@ct6601 iscsi]# service iscsi start

10. 查看连接信息及 iscsi 盘
[root@ct6601 ~]# iscsiadm -m session -P 1
Target: iqn.2006-01.com.openfiler:tsn.b45ae024d498 (non-flash)
        Current Portal: 192.108.26.100:3260,1
        Persistent Portal: 192.108.26.100:3260,1
                **********
                Interface:
                **********
                Iface Name: iface1
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.RedHat:bfec8c6a9151
                Iface IPaddress: 192.108.26.117
                Iface HWaddress: <empty>
                Iface Netdev: eth1
                SID: 5
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE

                **********
                Interface:
                **********
                Iface Name: iface2
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.redhat:bfec8c6a9151
                Iface IPaddress: 192.108.26.118
                Iface HWaddress: <empty>
                Iface Netdev: eth2
                SID: 6
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE
Target: iqn.2006-01.com.openfiler:tsn.67571ed98f10 (non-flash)
        Current Portal: 192.108.26.100:3260,1
        Persistent Portal: 192.108.26.100:3260,1
                **********
                Interface:
                **********
                Iface Name: iface1
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.redhat:bfec8c6a9151
                Iface IPaddress: 192.108.26.117
                Iface HWaddress: <empty>
                Iface Netdev: eth1
                SID: 7
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE

                **********
                Interface:
                **********
                Iface Name: iface2
                Iface Transport: tcp
                Iface Initiatorname: iqn.1994-05.com.redhat:bfec8c6a9151
                Iface IPaddress: 192.108.26.118
                Iface HWaddress: <empty>
                Iface Netdev: eth2
                SID: 8
                iSCSI Connection State: LOGGED IN
                iSCSI Session State: LOGGED_IN
                Internal iscsid Session State: NO CHANGE

# 查看 iscsi 盘               
[root@ct6601 iscsi]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001e517

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1        523    4194304  82  Linux swap / Solaris
Partition 1 does not end on cylinder boundary.
/dev/sda2  *        523        3917    27261952  83  Linux

Disk /dev/sdb: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfef2bf25

Disk /dev/sdc: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfef2bf25

Disk /dev/sdd: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xab210de1

Disk /dev/sde: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xab210de1

11. 查看 wwid
[root@ct6601 ~]# scsi_id -gu /dev/sdb
14f504e46494c45527646546462502d716247302d7a61554b
[root@ct6601 ~]# scsi_id -gu /dev/sdc
14f504e46494c45527646546462502d716247302d7a61554b
[root@ct6601 ~]# scsi_id -gu /dev/sdd
14f504e46494c45524b61654859532d47436c612d30625046
[root@ct6601 ~]# scsi_id -gu /dev/sde
14f504e46494c45524b61654859532d47436c612d30625046   

12. 配置 /etc/multipath.conf
[root@ct6601 etc]# cat  /etc/multipath.conf
defaults {
        user_friendly_names yes
}
multipaths {
        multipath {
                wwid                    14f504e46494c45527646546462502d716247302d7a61554b
                alias                  dm1
                path_grouping_policy    multibus
                failback                manual
                rr_weight              priorities
                no_path_retry          5
        }
                multipath {
                wwid                    14f504e46494c45524b61654859532d47436c612d30625046
                alias                  dm2
                path_grouping_policy    multibus
                failback                manual
                rr_weight              priorities
                no_path_retry          5
        }
}

13. 启动 multipathd
[root@ct6601 etc]# service multipathd restart   

14. 查看 multipath 信息及 mapper 盘
[root@ct6601 ~]# multipath -ll
dm2 (14f504e46494c45524b61654859532d47436c612d30625046) dm-1 OPNFILER,VIRTUAL-DISK
size=40G features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
`-+- policy=’round-robin 0′ prio=1 status=active
  |- 6:0:0:0 sdd 8:48 active ready running
  `- 5:0:0:0 sde 8:64 active ready running
dm1 (14f504e46494c45527646546462502d716247302d7a61554b) dm-0 OPNFILER,VIRTUAL-DISK
size=40G features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
`-+- policy=’round-robin 0′ prio=1 status=active
  |- 3:0:0:0 sdb 8:16 active ready running
  `- 4:0:0:0 sdc 8:32 active ready running

[root@ct6601 etc]# ll /dev/mapper/
total 0
crw-rw—- 1 root root 10, 58 May 11 08:28 control
lrwxrwxrwx 1 root root      7 May 11 09:27 dm1 -> ../dm-0
lrwxrwxrwx 1 root root      7 May 11 09:27 dm2 -> ../dm-1

15. 验证可用性
略.

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-05/131479.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计7036字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中