rhel5.4搭建iscis-target服务器

RHEL5.4搭建iscsi-target服务器,

拓扑结构如下:

 

1.安装iscsitarget软件包,这里用源代码包编译安装,也可以使用rpm安装,rhel5系统光盘自带

[root@server1 src]# ls

iscsitarget- 1.4.20 .2.tar.gz

[root@server1 src]# tar -xzf iscsitarget- 1.4.20 .2.tar.gz 

[root@server1 src]# cd iscsitarget- 1.4.20 .2

[root@server1 iscsitarget- 1.4.20 .2]# make

Applying Patch compat- 2.6.32 .patch

…………………………

LD [M]  /usr/local/src/iscsitarget- 1.4.20 .2/kernel/iscsi_trgt.o

  Building modules, stage 2.

  MODPOST

  CC      /usr/local/src/iscsitarget- 1.4.20 .2/kernel/iscsi_trgt.mod.o

  LD [M]  /usr/local/src/iscsitarget- 1.4.20 .2/kernel/iscsi_trgt.ko

make[1]: Leaving directory `/usr/src/kernels/ 2.6.18 -155.el5-i686'

[root@server1 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'

2.修改配置文件,位置为:/etc/iet/ietd.conf

第一行:设备的完全标识,命名方法为iqn.yyyy-dd.domain_nameidiqn是保留名称,必须用iqn开头,yyyy-dd表示年和日期,表示此SAN设备建立时间。后边的域名和冒号自行起名即可。

第二行:IncomingUser是授权的用户名和密码,用空格隔开,注意:由于微软的Windows iSCSI-initiator要求密码长度需要在612位之间,否则会报错,windows 7需要12位长,因此这里设置密码长度12

第三行:表示提供给客户端访问的设备,设备可以是lvm逻辑卷(/dev/vg_ser/lv_opt)raid阵列(/dev/md0),一整块磁盘(dev/sdb),或者一个分区(/dev/sdb1);如果有多个设备,可以写多行

Lunid: Lun的编号从0开始,最大2^14-1

Path=<设备>:指定块设备。可以使用dd命令生成一个文件

Type=fileio|blockio: 块设备类型,分区及dd命令生成的文件使用fileio类型;LVM卷、RAID卷使用blockio类型。

IOMode=(wb|ro): iSCSI initiator允许的操作,wb表示可读写;ro表示只读。

[root@server1 ~]# vim /etc/iet/ietd.conf

# "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.2011-05.com.example:storage.lun0  设备的完全标识

第二行:IncomingUser lzy nihao123456!              IncomingUser是授权的用户名和密码第三行:Lun 0 Path=/dev/sdb,Type=fileio,IOMode=wb  表示SAN要提供访问的设备

第四行:Alias lun0                               别名

#Target iqn.2001-04.com.example:storage.disk2.sys1.xyz

        # CHAP Users

        #

"/etc/iet/ietd.conf" 119L , 4151C written      

 

3.重新启动服务,如下图:              

[root@server1 ~]# /etc/init.d/iscsi-target restart

Stopping iSCSI Target: Connection refused.

ietd: no process killed

                                                           [FAILED]

Starting iSCSI Target:                                     [  OK  ]

 

 

Linux Iscsi客户端的配置

1.从光盘安装iscsi-initiator-utils软件包如下图

[root@localhost ~]# rpm -ivh /mnt/Server/iscsi-initiator-utils- 6.2.0 .871-0.10.el5.i386.rpm

warning: /mnt/Server/iscsi-initiator-utils- 6.2.0 .871-0.10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

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

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

[root@localhost ~]# /etc/init.d/iscsi restart

Stopping iSCSI daemon:

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  ]

2.保证配置文件/ etc/iscsi/initiatorname.iscsi文件有定义InitiatorName值,如下图

[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi

InitiatorName=iqn.1994-05.com.redhat:c31adc4733ed

[root@localhost ~]#

3.修改主配置文件/etc/iscsi/iscsid.conf

[root@station7 ~]# grep -v "#" /etc/iscsi/iscsid.conf |grep -v "^$"

node.startup = automatic                        随系统启动而启动该服务

node.session.auth.authmethod = CHAP            启用CHAP验证

#为启动程序的 CHAP 身份验证设置用户名和密码(由目标验证),

node.session.auth.username = lzy                

node.session.auth.password = nihao123!     

discovery.sendtargets.auth.authmethod = CHAP     设置搜索会话 CHAP 身份验证

#为启动程序的搜索会话 CHAP 身份验证设置用户名和密码(由目标验证):

discovery.sendtargets.auth.username = lzy

discovery.sendtargets.auth.password = nihao123!

node.session.timeo.replacement_timeout = 120

node.conn[0].timeo.login_timeout = 15

node.conn[0].timeo.logout_timeout = 15

node.conn[0].timeo.noop_out_interval = 5

node.conn[0].timeo.noop_out_timeout = 5

node.session.err_timeo.abort_timeout = 15

node.session.err_timeo.lu_reset_timeout = 20

node.session.initial_login_retry_max = 8

node.session.cmds_max = 128

node.session.queue_depth = 32

node.session.iscsi.InitialR2T = No

node.session.iscsi.ImmediateData = Yes

node.session.iscsi.FirstBurstLength = 262144

node.session.iscsi.MaxBurstLength = 16776192

node.conn[0].iscsi.MaxRecvDataSegmentLength = 262144

discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768

node.conn[0].iscsi.HeaderDigest = None

node.session.iscsi.FastAbort = Yes

 

4.通过命令搜索目标服务器的存储对象,

[root@station7 ~]# iscsiadm -m discovery -t st -p 192.168.1.8

192.168.1.8:3260,1 iqn.2011-05.com.example:storage.lun0

5.重启iscsi服务,可以登录到对方的iscsi存储对象。如下图:

[root@station7 ~]# /etc/init.d/iscsi restart

Stopping iSCSI daemon:

iscsid dead but pid file exists                            [  OK  ]

Turning off network shutdown. Starting iSCSI daemon:       [  OK  ]

                                                           [  OK  ]

Setting up iSCSI targets: Logging in to [iface: default, target: iqn.2011-05.com.example:storage.lun0, portal: 192.168.1.8,3260]

Login to [iface: default, target: iqn.2011-05.com.example:storage.lun0, portal: 192.168.1.8,3260]: successful

                                                           [  OK  ]

5.fdisk可以查看到已经登录到iscsi服务器的存储对象上,可以在此基础上分区挂载,如下图

[root@station7 ~]# fdisk -l

 

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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        1925    15358140   8e  Linux LVM

/dev/sda3            1926        1990      522112+  82  Linux swap / Solaris

/dev/sda4            1991        2610     4980150    5  Extended

/dev/sda5            1991        2052      497983+  83  Linux

/dev/sda6            2053        2138      690763+  8e  Linux LVM

/dev/sda7            2139        2236      787153+  8e  Linux LVM

/dev/sda8            2237        2280      353398+  fd  Linux raid autodetect

/dev/sda9            2281        2324      353398+  fd  Linux raid autodetect

 

Disk /dev/md0: 723 MB, 723517440 bytes

2 heads, 4 sectors/track, 176640 cylinders

Units = cylinders of 8 * 512 = 4096 bytes

 

Disk /dev/md0 doesn't contain a valid partition table

 

Disk /dev/sdb: 21.4 GB, 21474836480 bytes                 此设备

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

 

Windows 7登录linuxiscsi

1.打开管理工具-à.ISCSI发起程序,如下图:

 

2.在发起程序中,目录中写人iscsi-target服务器的IP,点击快速连接,如下图:

 

 

3.可以搜索到iscsi-target服务器上提供的存储对象目标,如下图:

 

 

4.选中目录名称,然后点击“属性”或“连接”

 

 

5.在属性中点击“添加会话”,弹出窗口,点击“高级”

 

 

6.在高级中选择链接方式,也可以按照默认,选中启用“chap登录”,然后写上正确的用户名和密码,如下图:

 

 

7.再点击“连接“,对象已经连接好,如下图:

 

 

8,通过“计算机管理“à.”磁盘管理“可以看到存储对象,如下图:

 

 

 

你可能感兴趣的:(linux,服务器,iSCSI,休闲,iscsi-target)