1.配置iscsi-initiator-utils包

[root@ora10g Server]# rpm -ivh iscsi-initiator-utils-6.2.0.868-0.7.el5.i386.rpm 
warning: iscsi-initiator-utils-6.2.0.868-0.7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:iscsi-initiator-utils  ########################################### [100%]
[root@ora10g Server]# 

2.扫描设备,发现还需要安装iscsi-target

[root@ora10g Server]# iscsiadm -m discovery -t sendtargets -p 192.168.20.128:3260
iscsiadm: can not connect to iSCSI daemon (111)!
iscsiadm: can not connect to iSCSI daemon (111)!
iscsiadm: Cannot perform discovery. Initiatorname required.
iscsiadm: Discovery process to 192.168.20.128:3260 failed to create a discovery session.
[root@ora10g Server]# 

3.去sf.net下载iscsitarget包进行编译

[root@ora10g Server]# 
[root@ora10g Server]# cd /softdb/
[root@ora10g softdb]# ls
10201_database_linux32.zip  iscsitarget-1.4.20.2.tar.gz    p6810189_10204_Linux-x86.zip  README.html
database                    OPatch                         p6880880_102000_LINUX.zip     vmware-tools-distrib
Disk1                       p12879929_10204_Linux-x86.zip  p9352164_10204_Linux-x86.zip
[root@ora10g softdb]# chmod +x iscsitarget-1.4.20.2.tar.gz 
[root@ora10g softdb]# tar -xzvf iscsitarget-1.4.20.2.tar.gz 
iscsitarget-1.4.20.2/
iscsitarget-1.4.20.2/README.mcs
iscsitarget-1.4.20.2/ChangeLog
iscsitarget-1.4.20.2/RELEASE_NOTES
iscsitarget-1.4.20.2/COPYING
iscsitarget-1.4.20.2/Makefile
iscsitarget-1.4.20.2/etc/
iscsitarget-1.4.20.2/etc/initd/
iscsitarget-1.4.20.2/etc/initd/initd
iscsitarget-1.4.20.2/etc/initd/initd.debian
iscsitarget-1.4.20.2/etc/initd/initd.redhat
iscsitarget-1.4.20.2/etc/initd/initd.gentoo
iscsitarget-1.4.20.2/etc/ietd.conf
iscsitarget-1.4.20.2/etc/initiators.allow
iscsitarget-1.4.20.2/etc/initiators.deny
iscsitarget-1.4.20.2/etc/targets.allow
iscsitarget-1.4.20.2/kernel/
iscsitarget-1.4.20.2/kernel/file-io.c
iscsitarget-1.4.20.2/kernel/null-io.c
iscsitarget-1.4.20.2/kernel/session.c
iscsitarget-1.4.20.2/kernel/iscsi_hdr.h
iscsitarget-1.4.20.2/kernel/iscsi.h
iscsitarget-1.4.20.2/kernel/conn.c
iscsitarget-1.4.20.2/kernel/block-io.c
iscsitarget-1.4.20.2/kernel/tio.c
iscsitarget-1.4.20.2/kernel/compat.h
iscsitarget-1.4.20.2/kernel/Makefile
iscsitarget-1.4.20.2/kernel/digest.c
iscsitarget-1.4.20.2/kernel/event.c
iscsitarget-1.4.20.2/kernel/iscsi_dbg.h
iscsitarget-1.4.20.2/kernel/digest.h
iscsitarget-1.4.20.2/kernel/config.c
iscsitarget-1.4.20.2/kernel/nthread.c
iscsitarget-1.4.20.2/kernel/ua.c
iscsitarget-1.4.20.2/kernel/target.c
iscsitarget-1.4.20.2/kernel/iotype.c
iscsitarget-1.4.20.2/kernel/iotype.h
iscsitarget-1.4.20.2/kernel/iscsi.c
iscsitarget-1.4.20.2/kernel/wthread.c
iscsitarget-1.4.20.2/kernel/target_disk.c
iscsitarget-1.4.20.2/kernel/volume.c
iscsitarget-1.4.20.2/kernel/param.c
iscsitarget-1.4.20.2/dkms.conf
iscsitarget-1.4.20.2/README.vmware
iscsitarget-1.4.20.2/usr/
iscsitarget-1.4.20.2/usr/ietadm.h
iscsitarget-1.4.20.2/usr/session.c
iscsitarget-1.4.20.2/usr/ietadm.c
iscsitarget-1.4.20.2/usr/chap.c
iscsitarget-1.4.20.2/usr/message.c
iscsitarget-1.4.20.2/usr/iscsi_hdr.h
iscsitarget-1.4.20.2/usr/log.c
iscsitarget-1.4.20.2/usr/plain.c
iscsitarget-1.4.20.2/usr/md5.c
iscsitarget-1.4.20.2/usr/conn.c
iscsitarget-1.4.20.2/usr/iscsid.c
iscsitarget-1.4.20.2/usr/param.h
iscsitarget-1.4.20.2/usr/Makefile
iscsitarget-1.4.20.2/usr/isns_proto.h
iscsitarget-1.4.20.2/usr/md5.h
iscsitarget-1.4.20.2/usr/event.c
iscsitarget-1.4.20.2/usr/ietd.c
iscsitarget-1.4.20.2/usr/sha1.h
iscsitarget-1.4.20.2/usr/target.c
iscsitarget-1.4.20.2/usr/config.h
iscsitarget-1.4.20.2/usr/types.h
iscsitarget-1.4.20.2/usr/isns.c
iscsitarget-1.4.20.2/usr/iscsid.h
iscsitarget-1.4.20.2/usr/sha1.c
iscsitarget-1.4.20.2/usr/ctldev.c
iscsitarget-1.4.20.2/usr/param.c
iscsitarget-1.4.20.2/usr/misc.h
iscsitarget-1.4.20.2/iscsitarget.spec
iscsitarget-1.4.20.2/include/
iscsitarget-1.4.20.2/include/iet_u.h
iscsitarget-1.4.20.2/README.initiators
iscsitarget-1.4.20.2/doc/
iscsitarget-1.4.20.2/doc/manpages/
iscsitarget-1.4.20.2/doc/manpages/ietd.8
iscsitarget-1.4.20.2/doc/manpages/ietd.conf.5
iscsitarget-1.4.20.2/doc/manpages/ietadm.8
iscsitarget-1.4.20.2/patches/
iscsitarget-1.4.20.2/patches/compat-2.6.29.patch
iscsitarget-1.4.20.2/patches/compat-2.6.24.patch
iscsitarget-1.4.20.2/patches/compat-2.6.32.patch
iscsitarget-1.4.20.2/patches/compat-2.6.25-2.6.27.patch
iscsitarget-1.4.20.2/patches/compat-2.6.30.patch
iscsitarget-1.4.20.2/patches/compat-2.6.23.patch
iscsitarget-1.4.20.2/patches/compat-2.6.28.patch
iscsitarget-1.4.20.2/patches/compat-2.6.19-2.6.21.patch
iscsitarget-1.4.20.2/patches/compat-rhel4.patch
iscsitarget-1.4.20.2/patches/compat-2.6.14-2.6.18.patch
iscsitarget-1.4.20.2/patches/compat-sles10sp2.patch
iscsitarget-1.4.20.2/patches/compat-2.6.22.patch
iscsitarget-1.4.20.2/patches/compat-2.6.31.patch
iscsitarget-1.4.20.2/README

4.make kernel

[root@ora10g softdb]# cd iscsitarget-1.4.20.2
[root@ora10g iscsitarget-1.4.20.2]# make kernel
Applying Patch compat-2.6.32.patch
patching file kernel/conn.c
Applying Patch compat-2.6.31.patch
patching file kernel/file-io.c
Applying Patch compat-2.6.30.patch
patching file kernel/block-io.c
Hunk #1 succeeded at 280 with fuzz 2.
Applying Patch compat-2.6.29.patch
patching file kernel/config.c
Applying Patch compat-2.6.28.patch
patching file kernel/conn.c
Applying Patch compat-2.6.25-2.6.27.patch
patching file kernel/block-io.c
Applying Patch compat-2.6.24.patch
patching file kernel/event.c
Applying Patch compat-2.6.23.patch
patching file kernel/block-io.c
patching file kernel/config.c
patching file kernel/digest.c
patching file kernel/event.c
patching file kernel/volume.c
Hunk #1 succeeded at 91 (offset -1 lines).
Applying Patch compat-2.6.22.patch
patching file kernel/volume.c
Hunk #1 succeeded at 10 (offset -1 lines).
patching file kernel/seq_list.c
patching file kernel/target.c
patching file kernel/seq_list.h
patching file kernel/Makefile
Applying Patch compat-2.6.19-2.6.21.patch
patching file kernel/event.c
patching file kernel/iscsi.c
patching file kernel/tio.c
patching file kernel/ua.c
Applying Patch compat-2.6.14-2.6.18.patch
patching file kernel/iscsi.h
Hunk #1 succeeded at 262 (offset 1 line).
patching file kernel/digest.c
patching file kernel/iscsi.c
patching file kernel/tio.c
patching file kernel/wthread.c
patching file kernel/volume.c
Hunk #1 succeeded at 83 (offset -1 lines).
make -C /lib/modules/2.6.18-92.el5/build SUBDIRS=/softdb/iscsitarget-1.4.20.2/kernel modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-92.el5-i686'
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/tio.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/iscsi.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/nthread.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/wthread.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/config.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/digest.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/conn.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/session.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/target.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/volume.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/iotype.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/file-io.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/null-io.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/target_disk.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/event.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/param.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/block-io.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/ua.o
  CC [M]  /softdb/iscsitarget-1.4.20.2/kernel/seq_list.o
  LD [M]  /softdb/iscsitarget-1.4.20.2/kernel/iscsi_trgt.o
  Building modules, stage 2.
  MODPOST
  CC      /softdb/iscsitarget-1.4.20.2/kernel/iscsi_trgt.mod.o
  LD [M]  /softdb/iscsitarget-1.4.20.2/kernel/iscsi_trgt.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.18-92.el5-i686'
[root@ora10g iscsitarget-1.4.20.2]# 

5.make usr

[root@ora10g iscsitarget-1.4.20.2]# make usr
make -C usr
make[1]: Entering directory `/softdb/iscsitarget-1.4.20.2/usr'
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o ietd.o ietd.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o iscsid.o iscsid.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o conn.o conn.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o session.o session.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o target.o target.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o message.o message.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o ctldev.o ctldev.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o log.o log.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o chap.o chap.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o event.o event.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o param.o param.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o plain.o plain.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o isns.o isns.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o md5.o md5.c
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o sha1.o sha1.c
cc ietd.o iscsid.o conn.o session.o target.o message.o ctldev.o log.o chap.o event.o param.o plain.o isns.o md5.o sha1.o -o ietd 
cc -O2 -fno-inline -Wall -Wstrict-prototypes -g -I../include -D_GNU_SOURCE    -c -o ietadm.o ietadm.c
cc ietadm.o param.o -o ietadm
make[1]: Leaving directory `/softdb/iscsitarget-1.4.20.2/usr'

6.make install

[root@ora10g iscsitarget-1.4.20.2]# make install
`usr/ietd' -> `/usr/sbin/ietd'
`usr/ietadm' -> `/usr/sbin/ietadm'
`etc/initd/initd.redhat' -> `/etc/rc.d/init.d/iscsi-target'
install: creating directory `/etc/iet'
`etc/ietd.conf' -> `/etc/iet/ietd.conf'
`etc/initiators.allow' -> `/etc/iet/initiators.allow'
`etc/targets.allow' -> `/etc/iet/targets.allow'
`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'
`RELEASE_NOTES' -> `/usr/share/doc/iscsitarget/RELEASE_NOTES'
`README' -> `/usr/share/doc/iscsitarget/README'
`README.vmware' -> `/usr/share/doc/iscsitarget/README.vmware'
`README.initiators' -> `/usr/share/doc/iscsitarget/README.initiators'
install: creating directory `/lib/modules/2.6.18-92.el5/extra/iscsi'
`kernel/iscsi_trgt.ko' -> `/lib/modules/2.6.18-92.el5/extra/iscsi/iscsi_trgt.ko'
Running depmod

7.再次探测设备,发现仍不能探测到,需要重启iscsi的服务

[root@ora10g iscsitarget-1.4.20.2]# ls /etc/init.d/iscsi
iscsi         iscsid        iscsi-target  
[root@ora10g iscsitarget-1.4.20.2]# iscsiadm -m discovery -t sendtargets -p 192.168.20.128:3260
iscsiadm: can not connect to iSCSI daemon (111)!
iscsiadm: can not connect to iSCSI daemon (111)!
iscsiadm: Cannot perform discovery. Initiatorname required.
iscsiadm: Discovery process to 192.168.20.128:3260 failed to create a discovery session.
[root@ora10g iscsitarget-1.4.20.2]# cd /etc/init.d/
[root@ora10g init.d]# ./iscsi-target restart
Stopping iSCSI Target:                                     [  OK  ]
Starting iSCSI Target:                                     [  OK  ]
[root@ora10g init.d]# ./iscsid status
iscsid is stopped
[root@ora10g init.d]# ./iscsid start
Turning off network shutdown. Starting iSCSI daemon:       [  OK  ]
                                                           [  OK  ]
[root@ora10g init.d]# ./iscsi restart
Stopping iSCSI daemon: ./iscsi: line 33: 23584 Killed                  /etc/init.d/iscsid stop
iscsid dead but pid file exists                            [  OK  ]
Turning off network shutdown. Starting iSCSI daemon:       [  OK  ]
                                                           [  OK  ]
Setting up iSCSI targets: iscsiadm: No records found!
                                                           [  OK  ]

8.再次探测设备,成功

[root@ora10g init.d]# 
[root@ora10g init.d]# iscsiadm -m discovery -t sendtargets -p 192.168.20.128:3260
192.168.20.128:3260,1 iqn.2006-01.com.openfiler:tsn.ca933298cde3
[root@ora10g init.d]#