Chinaunix首页 | 论坛 | 博客
  • 博客访问: 424637
  • 博文数量: 75
  • 博客积分: 2780
  • 博客等级: 少校
  • 技术积分: 789
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-23 20:38
文章分类

全部博文(75)

文章存档

2012年(1)

2011年(11)

2010年(12)

2009年(39)

2008年(12)

我的朋友

分类: 服务器与存储

2008-12-28 09:36:17


环境:

1OS RedHat AS4  (内核版本:2.6.9-22.ELsmp)

2Initiator软件:linux-iscsi-40.1.11

具体步骤

1.         在客户端安装RedHat AS4.2  (内核版本:2.6.9-22.ELsmp)光盘。安装时选择启动激活网卡的端口,并且安装模式选择“个人定制安装”,选择软件包时,在网络配置选项中选中iscsi选项。

2.         安装完毕后,通过ifconfig命令,确保Linux系统的IPIX1000业务口IP在同一网段。

3.         设置iscsi服务。

4.       使用 /etc/init.d/iscsi start命令先启动iscsi服务。

5.         /etc/iscsi.conf这个配置文件下,有3项内容需要配置:DiscoveryAddress OutgoingUsername OutgoingPassword

其中“DiscoveryAddress”是业务口IP地址,这个地址是在NeoStor上为Target所分配的IP地址。

 

&       注意:

如果在NeoStor上没有设置CHAP认证,只需要设置DiscoveryAddress一项内容。

 

OutgoingUsername”和“OutgoingPassword”,指的是在NeoStor上创建iSCSI协议下的Client的过程中,或者是ClientiSCSI协议的属性里,已设置CHAP认证的用户名和密码。这是针对在NeoStor上设置CHAP认证的情况进行的设置。

/etc/iscsi.conf这个文件配置如下

DiscoveryAddress=10.1.5.2:3260

相关的CHAP认证的设置,如:

     OutgoingUsername=huawei-3com
     OutgoingPassword=123456789123

&       注意:

输入用户名和密码时注意区分大小写!

 
6.       /etc/initiatorname.iscsi件下设置Initiator的名字,格式如下:
 
Initiatorname=iqn.xxx.xxx:xxx
 
Initiator是创建时为Client分配的Initiator

&       注意:

实际上由用户创建的任意合法(不能以test命名开头)的initiator都可以进行连接,即使不符合iqn.xxx.xxx.xxx规范,但是最终希望用户还是采用规范的命名!

 
 
7.       如果在同一个Target下如果挂载了多个资源,则要修改Target属性中lun的编号,使得编号从1开始;否则只能看到Lun编号为0的资源。

&  注意:

这由于操作系统RedHat AS4本身的原因,如果不修改LUN的编号,只能看到Lun编号为0的资源! 

8.       设置完成后,重新启动iscsi driver的命令:
        /etc/init.d/iscsi  restart

该操作可以加载iSCSI driver,并且可以使用iscsi-ls -l命令来查看连接上的target的详细信息:

[root@localhost ~]# iscsi-ls -l

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

SFNet iSCSI Driver Version ...4:0.1.11(12-Jan-2005)

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

TARGET NAME             : iqn.2000-03.com.huawei-3com:.h3c-2.IX1000-1-26

TARGET ALIAS            :

HOST ID                 : 2

BUS ID                  : 0

TARGET ID               : 0

TARGET ADDRESS          : 10.1.5.2:3260,0

SESSION STATUS          : ESTABLISHED AT   2  8 14:27:51 CST 2006

SESSION ID              : ISID 00023d000001 TSIH 44a0

 

DEVICE DETAILS:

---------------

LUN ID : 0

  Vendor: H3C      Model: H3C              Model: DISK           Rev: v1.0

  Type:                                    ANSI SCSI revision: 03

 

LUN ID : 1

  Vendor: H3C      Model: H3C              Model: ISCSI            Model: DISK            Rev: v1.0

  Type:   Direct-Access                    ANSI SCSI revision: 02

  page83 type3: 6000d7704d4536533947544632395438

  page80: 49534353490a

  Device: /dev/sdb

LUN ID : 2

  Vendor: H3C      Model: H3C              Model: ISCSI            Model: DISK            Rev: v1.0

  Type:   Direct-Access                    ANSI SCSI revision: 02

  page83 type3: 6000d77038584e4353343258514c464c

  page80: 49534353490a

  Device: /dev/sdc

LUN ID : 3

  Vendor: H3C      Model: H3C              Model: ISCSI            Model: DISK            Rev: v1.0

  Type:   Direct-Access                    ANSI SCSI revision: 02

  page83 type3: 6000d77036345a415252353537504358

  page80: 49534353490a

  Device: /dev/sdd

LUN ID : 4

  Vendor: H3C      Model: H3C              Model: ISCSI            Model: DISK            Rev: v1.0

  Type:   Direct-Access                    ANSI SCSI revision: 02

  page83 type3: 6000d77048415a4d3137343636554350

  page80: 49534353490a

  Device: /dev/sde

LUN ID : 5

  Vendor: H3C      Model: H3C              Model: ISCSI            Model: DISK            Rev: v1.0

  Type:   Direct-Access                    ANSI SCSI revision: 02

  page83 type3: 6000d7704e324741394b455054435651

  page80: 49534353490a

  Device: /dev/sdf

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

9.        可以使用fdisk –l来查看系统所连接的磁盘设备。举例说明:

[root@localhost ~]# fdisk -l

 

Disk /dev/sda: 400.0 GB, 400088457216 bytes

255 heads, 63 sectors/track, 48641 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       48641   390604410   8e  Linux LVM

 

Disk /dev/sdb: 10.4 GB, 10485760000 bytes

64 heads, 32 sectors/track, 10000 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

 

   Device Boot      Start         End      Blocks   Id  System

 

Disk /dev/sdc: 314 MB, 314572800 bytes

10 heads, 60 sectors/track, 1024 cylinders

Units = cylinders of 600 * 512 = 307200 bytes

 

   Device Boot      Start         End      Blocks   Id  System

 

Disk /dev/sdd: 419 MB, 419430400 bytes

13 heads, 62 sectors/track, 1016 cylinders

Units = cylinders of 806 * 512 = 412672 bytes

 

   Device Boot      Start         End      Blocks   Id  System

 

Disk /dev/sde: 524 MB, 524288000 bytes

17 heads, 59 sectors/track, 1020 cylinders

Units = cylinders of 1003 * 512 = 513536 bytes

 

   Device Boot      Start         End      Blocks   Id  System

 

Disk /dev/sdf: 629 MB, 629145600 bytes

20 heads, 60 sectors/track, 1024 cylinders

Units = cylinders of 1200 * 512 = 614400 bytes

 

&  注意:

创建iSCSI Target以及为该Target绑定相应的资源都应该在NeoStor上设置完成。

 
10.    使用fdisk devname命令对所连接的磁盘设备进行分区。其中devname可以由fdisk l命令得知。举例说明,输入命令 fdisk  /dev/sdb指定/dev/sdb为一个分区/dev/sdb1,在执行的过程中有如下详细的帮助。可以按照相应的提示进行操作。
[root@localhost ~]# fdisk /dev/sdb
 
The number of cylinders for this disk is set to 10000.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
 

11.    在刚刚建立的分区上创建文件系统命令如下:

mkfs t  fstype  partitionname

其中partitionname表示分区的名字,fstype表示文件系统的类型(ext2ext3),如,mkfs t  ext2  /dev/sdb1

12.     使用mount partitionname dir命令挂载分区partitionname到特定的节点dir,如果节点是/mnt/iSCSI ,则命令如下:mount  /dev/sdb1  /mnt/iSCSI

13.    mount操作成功后,就可以对设备进行读写操作。

14.     使用 umount partitionname 或者umount /mnt/dir ,都可以卸载分区;停止driver的命令是/etc/init.d/iscsi stop重新启动iSCSI driver的命令是/etc/init.d/iscsi restart 重新连接的命令/etc/init.d/iscsi reload查看iSCSI driver状态的命令:/etc/init.d/iscsi status .

 

&  注意:

如果需要连接新的iSCSI 设备,并且不断开现有的连接,可以使用重新连接的命令/etc/init.d/iscsi  reload

15.     Linux下自动挂载卷:

linux系统的iSCSI运行机制中,当iSCSI服务启动以后,会自动连接所有能够连接的卷,所以其本身已经实现persistence target功能,即重启后都会自动连接上卷,并开启对话。

Linux环境下,使用硬盘有两种方式,一种方式是不格式化硬盘,直接使用裸盘;另一种方式是使用文件分区。

在第一种使用裸盘的环境下,不需要对卷进行自动挂载,但是需要提供硬盘设备的UUID,可以使用devlabel printid –d device命令在查询硬盘设备的UUID。例如:

[root@localhost root]# devlabel printid -d /dev/sda

S83.2:69716e2e323030352d31312e6833632e636f6d3a696e7472616e73613a707074742e7465737431H3CIX5000

在第二种使用文件分区的环境下,设置相对要复杂一些。iSCSI服务重启后并不会将重启之前手动挂载的卷分区自动mount上来,但是可以通过在/etc/fstab文件中按如下格式添加命令来实现自动挂载:

 #device to mount   mount point  FS type  mount options  backup frequency  fsck pass

/dev/sda1        /mnt/t0      ext2       defaults        0              0     

即系统启动时将设备/dev/sda1自动挂载在/mnt/t0上。

另外一种更可靠的方法是使用卷分区的UUID来挂载卷,此时/etc/fstab.iscsi文件的格式如下:

 #device to mount   mount point  FS type  mount options  backup frequency  fsck pass

UUID=fb032900-9113-1213-fc09-086734fac1c1   /mnt/t0   ext2    defaults     0     0

iSCSI服务重启后,会按照分区的UUID将设备挂载到指定的节点上。

 

 

阅读(4402) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~