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

环境:
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.验证可用性
略.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/77fe6ff3b91ab5ec0750c2c49cfd58cc.html