linux iSCSI target配置全過程

tonykorn97發表於2007-10-25

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=
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可以看到新增加的裝置。

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

相關文章