linux iscsi multipath多路徑及名稱持久化配置

selectshen發表於2016-05-11

環境:
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.驗證可用性
略.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28539951/viewspace-2098051/,如需轉載,請註明出處,否則將追究法律責任。

相關文章