测试系统为Redhat 5.4,内核版本为2.6.18,iSCSI Server已经配置好,此处不再说明。

 

1、  安装iSCSI Initiator

 

a) 使用命令mount /dev/cdrom /media挂载Redhat5.4安装光盘到/media下。

 

b) 使用命令rpm --ivh /media/Server/iscsi-initiator-utils-6.2.0.871-0.7.el5.i386.rpm安装iscsi Initiator。

162611234.jpg

 

c) 使用命令rpm --qa | grep iscsi确认系统中已经成功安装了iscsi Initiator。并且在/etc下会产生iscsi文件夹,该文件夹下同时生成两个文件initiatorname.iscsi、iscsid.conf。

 

d) 使用命令chkconfig --list查看iscsi、iscsid服务在运行级别3、5中是否属于自动启动状态。(注意:如果不是可以使用chkconfig --level将其设置为自动启动。162732903.jpg

 

如果iscsid和iscsi没有随系统的启动而启动,则用chkconfig设置这两个服务在系统运行级别为3和5时随系统启动而启动

# chkconfig iscsi --level 345 on
# chkconfig iscsid --level 345 on

 

 

2、  执行Target发现。

 

a) 首先使用命令/etc/init.d/iscsid start启动iscsi守护进程。

163209436.jpg

 

b) 用命令iscsiadm –m discovery –t sendtargets –p 192.168.1.92发现192.168.1.92上的iscsi资源。

163251538.jpg

 

c) 使用命令iscsiadm –m node查看已发现的所有iscsi资源(该步骤可选)

163319139.jpg

 

 

3、  设置Initiator Name。

 

a) 编辑/etc/iscsi/initiatorname.iscsi文件,将“InitiatorName=”后的内容改为之前发现的iscsi资源名,如图:

 

b) 编辑/etc/iscsi/iscsid.conf文件,将“# isns.address = 192.168.0.1”前的“#”去掉,并将IP地址改为ISCSI Server的IP地址192.168.1.92。将“isns.port = 3205”前的“#”去掉并将端口号改为3260如图:

163452843.jpg

 

4、  启动iscsi服务,将通过iscsi挂载的磁盘分区格式化。

 

a) 使用命令/etc/init.d/iscsi start启动iscsi服务,此时将会挂载iscsi设备,如图。

163523760.jpg

 

b) 使用fdisk –l可以查看到系统中多了一块硬盘/dev/sdb,这便是通过iscsi挂载而来。

 

如果显示 disk /dev/sdb doesn’t contain a vilid partition table

需要运行以下命令进行挂载

# fdisk /dev/sdf
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1009, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1009, default 1009):
Using default value 1009
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.