说明: 对于有两个或多个控制器的iscsi存储设备,或采用openfiler有两块网卡提供服务器的系统。需要配置多路径功能提高可用性。
本文采用openfiler来实现iscsi设备的安装与测试。
本文NAS采用openfiler 2.99.1 X64做为实验环境,为近期的一个备份环境部署做准备。
1. 并安装iSCSI启动器软件包
rpm -ivh iscsi-initiator-utils-6.2.0.871-0.10.el5.i386.rpm
chkconfig --level 2345 iscsi on
chkconfig --level 2345 iscsid on
service iscsi start
service iscsid start
2. 多路径软件安装准备
# rpm -qa |grep mapper
device-mapper-event-1.02.55-2.el5
device-mapper-1.02.55-2.el5
device-mapper-multipath-0.4.7-42.el5
#
设置成开机自启动multipathd
# chkconfig --level 2345 multipathd on
来检查安装是否正常
# lsmod |grep dm_multipath
dm_multipath 25421 0
scsi_dh 12097 1 dm_multipath
dm_mod 63097 11 dm_multipath,dm_raid45,dm_snapshot,dm_zero,dm_mirror,dm_log
3. 发现存储设备
# iscsiadm -m discovery -t st -p 192.168.100.238
192.168.100.238:3260,1 iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c
192.168.100.239:3260,1 iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c
4. 连接两个节点,通过两个IP分别进行连接
(1) 连接登陆第一个IP
# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c -p 192.168.100.238 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c, portal: 192.168.100.238,3260]
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c, portal: 192.168.100.238,3260] successful.
(2) 连接登录第二个IP
# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c -p 192.168.100.239 -l
Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c, portal: 192.168.100.239,3260]
Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c, portal: 192.168.100.239,3260] successful.
5. 查看连接状态
(1) 查看连接状态1
# iscsiadm -m session
tcp: [1] 192.168.14.180:3260,1 iqn.2006-01.com.openfiler:tsn.355d1613342d
tcp: [2] 192.168.14.181:3260,1 iqn.2006-01.com.openfiler:tsn.355d1613342d
(2) 查看iSCSI连接设备
# ls -l /dev/disk/by-path/
lrwxrwxrwx 1 root root 9 Jan 7 10:52 ip-192.168.100.238:3260-iscsi-iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c-lun-0 -> ../../sda
lrwxrwxrwx 1 root root 9 Jan 7 10:54 ip-192.168.100.239:3260-iscsi-iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c-lun-0 -> ../../sdb
lrwxrwxrwx 1 root root 9 Jan 7 10:28 pci-0000:00:07.1-ide-0:0 -> ../../hda
lrwxrwxrwx 1 root root 10 Jan 7 10:28 pci-0000:00:07.1-ide-0:0-part1 -> ../../hda1
lrwxrwxrwx 1 root root 10 Jan 7 10:28 pci-0000:00:07.1-ide-0:0-part2 -> ../../hda2
lrwxrwxrwx 1 root root 9 Jan 7 10:28 pci-0000:00:07.1-ide-1:0 -> ../../hdc
(3) 查看详细连接状态
# iscsiadm -m session -P 3
iSCSI Transport Class version 2.0-871
version 2.0-872
Target: iqn.2006-01.com.openfiler:tsn.f9d59aaffe9c
Current Portal: 192.168.100.238:3260,1
Persistent Portal: 192.168.100.238:3260,1
**********
Interface:
**********
Iface Name: default
Iface Transport: tcp
Iface Initiatorname: iqn.1994-05.com.RedHat:e2b7fdf48ccd
Iface IPaddress: 192.168.100.175
Iface HWaddress: <empty>
Iface Netdev: <empty>
SID: 1
iSCSI Connection State: LOGGED IN
iSCSI Session State: LOGGED_IN
Internal iscsid Session State: NO CHANGE
************************
Negotiated iSCSI params:
************************
HeaderDigest: None
DataDigest: None
MaxRecvDataSegmentLength: 262144
MaxXmitDataSegmentLength: 131072
FirstBurstLength: 262144
MaxBurstLength: 262144
ImmediateData: No
InitialR2T: Yes
MaxOutstandingR2T: 1
************************
Attached SCSI devices:
************************
Host Number: 0 State: running
scsi0 Channel 00 Id 0 Lun: 0
Attached scsi disk sda State: running
Current Portal: 192.168.100.239:3260,1
Persistent Portal: 192.168.100.239:3260,1
**********
Interface:
**********
Iface Name: default
Iface Transport: tcp
Iface Initiatorname: iqn.1994-05.com.redhat:e2b7fdf48ccd
Iface IPaddress: 192.168.100.175
Iface HWaddress: <empty>
Iface Netdev: <empty>
SID: 2
iSCSI Connection State: LOGGED IN
iSCSI Session State: LOGGED_IN
Internal iscsid Session State: NO CHANGE
************************
Negotiated iSCSI params:
************************
HeaderDigest: None
DataDigest: None
MaxRecvDataSegmentLength: 262144
MaxXmitDataSegmentLength: 131072
FirstBurstLength: 262144
MaxBurstLength: 262144
ImmediateData: No
InitialR2T: Yes
MaxOutstandingR2T: 1
************************
Attached SCSI devices:
************************
Host Number: 1 State: running
scsi1 Channel 00 Id 0 Lun: 0
Attached scsi disk sdb State: running
两个设备sda,sdb分别由两个IP进行提供服务,也可查看状态都是LOGGED IN状态。