首页 > 产品资讯 > linux iSCSI target 配置全过程

产品资讯 公司新闻
linux iSCSI target 配置全过程
点击数:     更新时间:2017-07-11
linux iSCSI target配置全过程
⼀:Install iSCSI target for Linux
1,操作系统:
[root@rac2 ~]# cat /etc/issue
Enterprise Linux Enterprise Linux AS release 4 (October Update 4)
Kernel r on an m
[root@rac2 /]# uname -a
Linux rac2.mycorpdomain.com 2.6.9-42.0.0.0.1.ELsmp #1 SMP Sun Oct 15 14:02:40 PDT 2006
i686 i686 i386 GNU/Linux
[root@rac2 /]#
2,解压文件
[root@rac2 ~]# tar -xzvf iscsitarget-0.4.15.tar.gz
3,编译
[root@rac2 ~]# cd iscsitarget-0.4.15
[root@rac2 iscsitarget-0.4.15]# ls
ChangeLog COPYING doc etc include kernel Makefile patches README README.vmware usr
[root@rac2 iscsitarget-0.4.15]# make
Applying Patch compat-2.6.14-2.6.18.patch
patching file kernel/iscsi.h
patching file kernel/digest.c
patching file kernel/file-io.c
。。。
[root@rac2 iscsitarget-0.4.15]# make install
install: creating directory `/lib/modules/2.6.9-42.0.0.0.1.ELsmp/kernel/iscsi'
`kernel/iscsi_trgt.ko' -> `/lib/modules/2.6.9-42.0.0.0.1.ELsmp/kernel/iscsi/iscsi_trgt.ko'
depmod -aq
`usr/ietd' -> `/usr/sbin/ietd'
`usr/ietadm' -> `/usr/sbin/ietadm'
`etc/initd/initd.redhat' -> `/etc/init.d/iscsi-target'
`etc/ietd.conf' -> `/etc/ietd.conf'
`etc/initiators.allow' -> `/etc/initiators.allow'
`etc/initiators.deny' -> `/etc/initiators.deny'
`doc/manpages/ietadm.8' -> `/usr/share/man/man8/ietadm.8'
`doc/manpages/ietd.8' -> `/usr/share/man/man8/ietd.8'
`doc/manpages/ietd.conf.5' -> `/usr/share/man/man5/ietd.conf.5'
install: creating directory `/usr/share/doc/iscsitarget'
`ChangeLog' -> `/usr/share/doc/iscsitarget/ChangeLog'
`COPYING' -> `/usr/share/doc/iscsitarget/COPYING'
`README' -> `/usr/share/doc/iscsitarget/README'
`README.vmware' -> `/usr/share/doc/iscsitarget/README.vmware'
[root@rac2 iscsitarget-0.4.15]#
4,配置
[root@rac2 iscsitarget-0.4.15]# vi /etc/ietd.conf
User userid superpassword
Target iqn.2001-04.com.example:storage.disk2.sys1.xyz
Lun 0 /dev/sdb1 fileio
Alias lun0
5,启动服务
[root@rac2 etc]# cd /etc/init.d
[root@rac2 init.d]# ls
acpid crond halt killall netplugd openibd rhnsd snmpd xfs
anacron cups hidd kudzu network oracleasm rpcgssd snmptrapd xinetd
apmd cups-config-daemon ibmasm lm_sensors NetworkManager pand rpcidmapd spamassassin
ypbind
arptables_jf diskdump ipmi mdmonitor nfs pcmcia rpcsvcgssd sshd yum
atd dund iptables mdmpd nfslock portmap rwhod syslog
auditd firstboot irda messagebus nscd psacct saslauthd sysstat
autofs functions irqbalance microcode_ctl ntpd rawdevices sendmail tog-pegasus
bluetooth gpm iscsi-target netdump o2cb readahead single vncserver
cpuspeed haldaemon isdn netfs ocfs2 readahead_early smartd winbind
[root@rac2 init.d]# /etc/init.d/iscsi-target start
Starting iSCSI target service: [ OK ]
[root@rac2 init.d]#
6,察看验证
dmesg
iSCSI Enterprise Target Software - version 0.4.15
iotype_init(92) register fileio
iotype_init(92) register blockio
iotype_init(92) register nullio
parse_fileio_params(230) Unknown /dev/sdb1 fileio
fileio_attach(268) -22
[root@rac2 init.d]#
[root@rac2 init.d]# tailf /var/log/messages
Oct 24 09:22:13 rac2 ntpd[2995]: kernel time sync disabled 0041
Oct 24 09:23:16 rac2 ntpd[2995]: kernel time sync enabled 0001
Oct 24 09:24:15 rac2 kernel: iSCSI Enterprise Target Software - version 0.4.15
Oct 24 09:24:15 rac2 kernel: iotype_init(92) register fileio
Oct 24 09:24:15 rac2 kernel: iotype_init(92) register blockio
Oct 24 09:24:15 rac2 kernel: iotype_init(92) register nullio
Oct 24 09:24:15 rac2 iscsi-target: ietd startup succeeded
Oct 24 09:24:15 rac2 kernel: parse_fileio_params(230) Unknown /dev/sdb1 fileio
Oct 24 09:24:15 rac2 kernel: fileio_attach(268) -22
Oct 24 09:24:15 rac2 ietd: Can't create a logical unit 22 1 0 /dev/sdb1 fileio
7,修改配置文件为:
Target iqn.2001-04.com.example:storage.disk2.sys1.idisk
Lun 4 Path=/dev/sdb1,Type=fileio
Alias sdb
然后启动的时候dmesg信息为:
iSCSI Enterprise Target Software - version 0.4.15
iotype_init(92) register fileio
iotype_init(92) register blockio
iotype_init(92) register nullio
日志信息:
Oct 25 16:31:35 test kernel: iSCSI Enterprise Target Software - version 0.4.15
Oct 25 16:31:35 test kernel: iotype_init(92) register fileio
Oct 25 16:31:35 test kernel: iotype_init(92) register blockio
Oct 25 16:31:35 test kernel: iotype_init(92) register nullio
在这个地方我搞了好久,看大家的文章⼀直配置文件都是可以如下配置的:
Target iqn.2001-04.com.example:storage.disk2.sys1.xyz
Lun 0 /dev/sdb1 fileio
Alias Test
但是我的⼀直不行,我原来是虚拟机,然后重新安装了redhat4u4,还是不行,后来有安装了redhat5,还
是不行.
中间我也试过用如下配置文件:
User userid superpassword
Target iqn.2001-04.com.example:storage.disk2.sys1.xyz
Lun 0 Path=/dev/sdb1, type=fileio
Alias Test
可是还不行,最后发现type开头字母我把它写成小写了.
二,Red Hat linux iSCSI initiator configuration
1,操作系统:
[root@rac1 ~]# cat /etc/issue
Enterprise Linux Enterprise Linux AS release 4 (October Update 4)
Kernel r on an m
[root@rac1 ~]#
2,安装initiator
[root@rac1 ~]# rpm -ivh iscsi-initiator-utils-4.0.3.0-4.i386.rpm
warning: iscsi-initiator-utils-4.0.3.0-4.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:iscsi-initiator-utils ########################################### [100%]
[root@rac1 ~]#
3,修改/etc/iscsid.conf 文件
vi /etc/iscsid.conf
修改下面3项:
DiscoveryAddress=<IP Address>
This needs to be set to the Group IP Address of your UIT Array.
SendAsyncText=yes
For the initiator to receive Vendor Specific async events from the target.
Continuous=yes
To globally specify that all discovery sessions be kept open.
4,启动服务
[root@rac1 etc]# service iscsi start
Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
mknod: `/dev/iscsictl': File exists
Starting iscsid: [ OK ]
[root@rac1 etc]#
5,设置iscsi服务
[root@rac1 etc]# chkconfig --list iscsi
iscsi 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@rac1 etc]# chkconfig --add iscsi
[root@rac1 etc]# chkconfig --add iscsi
[root@rac1 etc]# chkconfig iscsi on
[root@rac1 etc]# chkconfig --list iscsi
iscsi 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6,察看scsi设备
[root@rac1 etc]# iscsi-ls
*******************************************************************************
SFNet iSCSI Driver Version ...4:0.1.11-3(02-May-2006)
*******************************************************************************
[root@rac1 etc]#
7, 正常情况下应该是:
[root@rac1 ~]# iscsi-ls
*******************************************************************************
SFNet iSCSI Driver Version ...4:0.1.11-3(02-May-2006)
*******************************************************************************
TARGET NAME : iqn.2001-04.com.example:storage.disk2.sys1.idisk
TARGET ALIAS :
HOST ID : 6
BUS ID : 0
TARGET ID : 0
TARGET ADDRESS : 172.25.1.100:3260,1
SESSION STATUS : ESTABLISHED AT Thu Oct 25 00:46:13 CST 2007
SESSION ID : ISID 00023d000001 TSIH 200
*******************************************************************************
[root@rac1 ~]#
8,通过dmesg可以看到新增加的设备。
from:http://tonykorn97.itpub.net/post/6414/407919