《Linux iSCSI target配置全过程》

onlykg 2010-03-17

一:Install iSCSI target for Linux

1,操作系统:

[root@rac2~]#cat/etc/issue

EnterpriseLinuxEnterpriseLinuxASrelease4(OctoberUpdate4)

Kernelronanm

[root@rac2/]#uname-a

Linuxrac2.mycorpdomain.com2.6.9-42.0.0.0.1.ELsmp#1SMPSunOct1514:02:40PDT2006i686i686i386GNU/Linux

[root@rac2/]#

2,解压文件

[root@rac2~]#tar-xzvfiscsitarget-0.4.15.tar.gz

3,编译

[root@rac2~]#cdiscsitarget-0.4.15

[[email protected]]#ls

ChangeLogCOPYINGdocetcincludekernelMakefilepatchesREADMEREADME.vmwareusr

[[email protected]]#make

[root@rac2 iscsitarget-0.4.15]# make install

4,配置

[[email protected]]#vi/etc/ietd.conf

Useruseridsuperpassword

Targetiqn.2001-04.com.example:storage.disk2.sys1.xyz

Lun0/dev/sdb1fileio

Aliaslun0

5,启动服务

[root@rac2etc]#cd/etc/init.d

[root@rac2 init.d]# ls

6,察看验证dmesg -c

7,修改配置文件为:

Targetiqn.2001-04.com.example:storage.disk2.sys1.idisk

Lun4Path=/dev/sdb1,Type=fileio

Aliassdb

然后启动的时候dmesg信息为:

iSCSIEnterpriseTargetSoftware-version0.4.15

iotype_init(92)registerfileio

iotype_init(92)registerblockio

iotype_init(92)registernullio

日志信息:

Oct2516:31:35testkernel:iSCSIEnterpriseTargetSoftware-version0.4.15

Oct2516:31:35testkernel:iotype_init(92)registerfileio

Oct2516:31:35testkernel:iotype_init(92)registerblockio

Oct2516:31:35testkernel:iotype_init(92)registernullio

在这个地方我搞了好久,看大家的文章一直配置文件都是可以如下配置的:

Targetiqn.2001-04.com.example:storage.disk2.sys1.xyz

Lun0/dev/sdb1fileio

AliasTest

但是我的一直不行,我原来是虚拟机,然后重新安装了redhat4u4,还是不行,后来有安装了redhat5,还是不行.

中间我也试过用如下配置文件:

Useruseridsuperpassword

Targetiqn.2001-04.com.example:storage.disk2.sys1.xyz

Lun0Path=/dev/sdb1,type=fileio

AliasTest

可是还不行,最后发现type开头字母我把它写成小写了.

二,RedHatlinuxiSCSIinitiatorconfiguration

1,操作系统:

[root@rac1~]#cat/etc/issue

EnterpriseLinuxEnterpriseLinuxASrelease4(OctoberUpdate4)

Kernelronanm

[root@rac1~]#

2,安装initiator

[root@rac1~]#rpm-ivhiscsi-initiator-utils-4.0.3.0-4.i386.rpm

warning:iscsi-initiator-utils-4.0.3.0-4.i386.rpm:V3DSAsignature:NOKEY,keyIDdb42a60e

Preparing...###########################################[100%]

1:iscsi-initiator-utils###########################################[100%]

[root@rac1~]#

3,修改/etc/iscsid.conf文件

vi/etc/iscsid.conf

修改下面3项:

DiscoveryAddress=<IPAddress>

ThisneedstobesettotheGroupIPAddressofyourUITArray.

SendAsyncText=yes

FortheinitiatortoreceiveVendorSpecificasynceventsfromthetarget.

Continuous=yes

Togloballyspecifythatalldiscoverysessionsbekeptopen.

4,启动服务

[root@rac1etc]#serviceiscsistart

Checkingiscsiconfig:[OK]

Loadingiscsidriver:[OK]

mknod:`/dev/iscsictl':Fileexists

Startingiscsid:[OK]

[root@rac1etc]#

5,设置iscsi服务

[root@rac1etc]#chkconfig--listiscsi

[root@rac1etc]#chkconfig--addiscsi

[root@rac1etc]#chkconfig--addiscsi

[root@rac1etc]#chkconfigiscsion

[root@rac1etc]#chkconfig--listiscsi

iscsi0:off1:off2:on3:on4:on5:on6:off

6,察看scsi设备

[root@rac1etc]#iscsi-ls

*******************************************************************************

SFNetiSCSIDriverVersion...4:0.1.11-3(02-May-2006)

*******************************************************************************

[root@rac1etc]#

7,正常情况下应该是:

[root@rac1~]#iscsi-ls

*******************************************************************************

SFNetiSCSIDriverVersion...4:0.1.11-3(02-May-2006)

*******************************************************************************

TARGETNAME:iqn.2001-04.com.example:storage.disk2.sys1.idisk

TARGETALIAS:

HOSTID:6

BUSID:0

TARGETID:0

TARGETADDRESS:172.25.1.100:3260,1

SESSIONSTATUS:ESTABLISHEDATThuOct2500:46:13CST2007

SESSIONID:ISID00023d000001TSIH200

*******************************************************************************

[root@rac1~]#

8,通过dmesg可以看到新增加的设备。

相关推荐