ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux下配置iscsi target

linux下配置iscsi target

原创 Linux操作系统 作者:wenxue_813 时间:2011-09-22 23:17:21 0 删除 编辑

为了给在windows 2008 server R2上安装oracle10g rac的实验提供共享存储,用一台普通的linux 系统的PC机,安装iscsi target软件作为存储服务器。
我使用的redhat linux 4.8的系统,内核版本是2.6.9,这个版本只能使用比较老的iscsi target 0.4.0版本,现在最新版本已经到1.4.2了,下载路径为:http://sourceforge.net/projects/iscsitarget/files/iscsitarget/

这是我系统的分区情况:
[root@yy ~]# fdisk -l
Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3200 25599577+ 8e Linux LVM
/dev/sda3 3201 3983 6289447+ 82 Linux swap
/dev/sda4 3984 9726 46130647+ 5 Extended
/dev/sda5 3984 5808 14659281 83 Linux
/dev/sda6 5809 7633 14659281 83 Linux
sda5和sda6是我准备共享的分区。不过我在测试的时候只用到了sda5

安装配置步骤很简单,主要有如下几步:
上传安装文件到服务器的/tmp目录
[root@yy tmp]#gunzip iscsitarget-0.4.0.tar.gz
[root@yy tmp]#tar -xvf iscsitarget-0.4.0.tar
[root@yy tmp]#cd iscsitarget-0.4.0

下面开始正式安装。
在执行make和make install时需要指定kernel modules的目录,可以直接指定KERNELSRC环境变量,也可以在每个命令后面直接指定路径

[root@yy iscsitarget-0.4.0]# export KERNELSRC=/usr/src/kernels/2.6.9-89.EL-smp-i686
[root@yy iscsitarget-0.4.0]# make
make -C usr
make[1]: Entering directory `/tmp/iscsitarget-0.4.0/usr’
make[1]: Nothing to be done for `all’.
make[1]: Leaving directory `/tmp/iscsitarget-0.4.0/usr’
make modules -C /usr/src/kernels/2.6.9-89.EL-smp-i686 SUBDIRS=/tmp/iscsitarget-0.4.0/kernel
make[1]: Entering directory `/usr/src/kernels/2.6.9-89.EL-smp-i686′
CC [M] /tmp/iscsitarget-0.4.0/kernel/target_cmnd.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/iscsi.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/workerthread.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/config.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/digest.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/conn.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/session.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/target.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/volume.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/iotype.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/daemon.o
CC [M] /tmp/iscsitarget-0.4.0/kernel/file-io.o
LD [M] /tmp/iscsitarget-0.4.0/kernel/iscsi_trgt.o
Building modules, stage 2.
MODPOST
CC /tmp/iscsitarget-0.4.0/kernel/iscsi_trgt.mod.o
LD [M] /tmp/iscsitarget-0.4.0/kernel/iscsi_trgt.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.9-89.EL-smp-i686′

[root@yy iscsitarget-0.4.0]# make install
`usr/ietd’ -> `/usr/sbin/ietd’
`usr/ietadm’ -> `/usr/sbin/ietadm’
if [ -f /etc/debian_version ]; then \
install -v -m 755 etc/initd/initd.debian /etc/init.d/iscsi-target; \
elif [ -f /etc/redhat-release ]; then \
install -v -m 755 etc/initd/initd.redhat /etc/init.d/iscsi-target; \
elif [ -f /etc/slackware-version ]; then \
install -v -m 755 etc/initd/initd /etc/rc.d/iscsi-target; \
else \
install -v -m 755 etc/initd/initd /etc/init.d/iscsi-target; \
fi
`etc/initd/initd.redhat’ -> `/etc/init.d/iscsi-target’
install: creating directory `/lib/modules/2.6.9-89.ELsmp/kernel/iscsi’
`kernel/iscsi_trgt.ko’ -> `/lib/modules/2.6.9-89.ELsmp/kernel/iscsi/iscsi_trgt.ko’
depmod -aq

安装完成,剩下的就是稍微配置一下。

[root@yy iscsitarget-0.4.0]# cp etc/ietd.conf /etc

现在是我测试用的iscsi target配置文件。

[root@yy iscsitarget-0.4.0]# vi /etc/ietd.conf
# Example iscsi target configuration
#
# Everything until the first target definition belongs
# to the global configuration.
# Right now this is only the user configuration used
# during discovery sessions:

#User joe secret

# Targets definitions start with “Target” and the target name.
# The target name must be a globally unique name, the iSCSI
# standard defines the “iSCSI Qualified Name” as follows:
#
# iqn.yyyy-mm.[:identifier]
#
# “yyyy-mm” is the date at which the domain is valid and the identifier
# is freely selectable. For further details please check the iSCSI spec.

Target iqn.2001-04.com.example:storage.disk2.sys1.xyz
# Users, who can access this target
# (no users means anyone can access the target)
#User joe secret
# Lun definition
# (right now only block devices are possible)
Lun 0 /dev/sda5 fileio
# Alias name for this target
Alias Test
# various iSCSI parameters
# (not all are used right now, see also iSCSI spec for details)
#MaxConnections 1
#InitialR2T yes
#ImmediateData no
#MaxRecvDataSegmentLength 8192
#MaxBurstLength 262144
#FirstBurstLength 65536
#DefaultTime2Wait 2
#DefaultTime2Retain 20
#MaxOutstandingR2T 8
#DataPDUInOrder yes
#DataSequenceInOrder yes
#ErrorRecoveryLevel 0
#Wthreads
8
第一次启动服务器
[root@yy iscsitarget-0.4.0]/etc/init.d/iscsi-target start
显示服务已经正常启动,但是日志却出现了点小意外,如此尝试很多次重新,重新配置都不能消除这个错误。
Aug 30 13:33:14 yy kernel: iet_target_free(221) Ready to remove target (0)
Aug 30 13:33:14 yy kernel: iSCSI Enterprise Target Software – version 0.4.0
Aug 30 13:33:14 yy kernel: iotype_init(97) register fileio
Aug 30 13:33:14 yy kernel: iet_target_param_set(128) d 1 8192 262144 65536 2 20 8 0
Aug 30 13:33:14 yy iscsid: failed to add volume/dev/sda5
Aug 30 13:33:14 yy iscsi-target: ietd startup succeeded
Aug 30 13:33:15 yy kernel: iet_session_param_set(152) d 1 8192 262144 65536 2 20 8 0
重新启动系统后一起却正常了,万能的重启又一次解决了我的问题。

最近就是在windows上验证我iscsi了,很简单,不再赘述。

更多的文档请访问老仵的站

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7620056/viewspace-708153/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-08-25

  • 博文量
    3
  • 访问量
    15128