1、安装iscsi客户端
首先将linux安装盘挂载在系统上
# mount /dev/cdrom
/media
# ls /media
# cd
/media/Packages(linux下iscsi安装包所在位置,6.0之前的可能在Server文件里面)
# ls | grep iscsi #找到iscsi-initiator程序安装包
安装iscsi客户端
# rpm -ivh
iscsi-initiator-utils-6.2.0.871-0.10.e15.i386.rpm
2、发现存储阵列
使用iscsiadm –m 指令来查看是否能发现阵列
# iscsiadm -m discovery -t
sendtargets -p 192.168.100.102(此为阵列存储设备IP)
结果:192.168.100.102:3260,1
iqn.1986-03.com.hp:storage.p2000g3.114513bbf6
在磁盘阵列设置好逻辑盘。
# fdisk -l
查看
发现并登陆
# iscsiadm -m discovery -t
sendtargets -p 192.168.100.102
# iscsiadm -m node -T
iqn.1986-03.com.hp:storage.p2000g3.114513bbf6 -p
192.168.100.102:3260 –l
此时可能会出现错误,需要进行下面的操作:
# rm-rf
/var/lib/iscsi/nodes/
可能是由于你的存储需要CHAP验证,因此还需要修改文件
# vim
/etc/iscsi/iscsid.conf
修改文件:
# *************
# CHAP Settings
# *************
# To enable CHAP
authentication set node.session.auth.authmethod
# to CHAP. The default is
None.
node.session.auth.authmethod =
CHAP
//去掉#
# To set a CHAP username and
password for initiator
# authentication by the
target(s), uncomment the following lines:
node.session.auth.username =
xxxxx
//挂载的存储名称(在存储端设置)
node.session.auth.password =
xxxxxx
//CHAP密码(在存储端设置)
接着重复3步骤,当提示有successful,说明已经挂载成功
3、查看挂载的存储
# fdisk –l //查看磁盘信息
WARNING: GPT (GUID Partition
Table) detected on '/dev/sda'! The util
fdisk
doesn't support GPT. Use GNU
Parted.
WARNING: The size of
this disk is 3.2 TB (3221225472000 bytes).
DOS partition table
format can not be used on drives for volumes
larger than 2.2 TB
(2199023255040 bytes). Use parted(1) and GUID
partition table format
(GPT).
Disk /dev/sdb: 3221.2
GB, 3221225472000 bytes
255 heads, 63 sectors/track,
391625 cylinders
Units = cylinders of 16065 *
512 = 8225280 bytes
Device
Boot Start End Blocks Id System
Disk /dev/cciss/c0d0: 293.5
GB, 293563949056 bytes
255 heads, 63 sectors/track,
35690 cylinders
Units = cylinders of 16065 *
512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/cciss/c0d0p1 * 1 13 104391 83 Linux
/dev/cciss/c0d0p2 14 35690 286575502+ 8e Linux LVM
在这段信息里面出现警告了,并且没有识别出存储,,因为fdisk不能识别超过2T的磁盘空间,因此需要使用以下命令,给挂载的存储一个新的标识
4、挂载存储
# parted
/dev/sdb //用parted命令分区
GNU Parted 1.8.1
使用 /dev/sdb
Welcome to GNU Parted! Type
'help' to view a list of commands.
(parted) mklabel
GPT // 建立磁盘label
警告: The
existing disk label on /dev/sda will be destroyed and all data
on
this
disk will be lost. Do you want
to continue?
parted: invalid token:
GPT是/Yes/否/No?
y
新的磁盘标签类型?[gpt]? (直接回车)
(parted) mkpart
//创建分区
分区名称?[]?
sdb1文件系统类型?[ext2]? ext3//如果你想要文件系统使用ext3或ext4的时候,你可以直接在后面输入ext3或ext4然后回车,如果不是可以直接回车,我这里使用的是ext3
起始点? 0
结束点? 3221.2G //根据分配给你的存储大小设置
(parted) p //查看刚创建的分区是否已经成功
Model: HP HSV450 (scsi)
Disk /dev/sda: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name 标志
1 17.4kB 3221.2GB 3221.2GB ext3 sdb1
(parted)
quit
信息:
如果必要,不要忘记更新 /etc/fstab。//系统显示内容
# mkfs.ext3
/dev/sdb1 //创建文件系统,格式化文件系统(如果之前是ext3即你想要的文件格式,可以不必进行这一步骤)
mke2fs 1.39
(29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
390627328 inodes, 781249995 blocks
39062499 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
23842 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200,
884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872,
71663616, 78675968,
102400000, 214990848, 512000000, 550731776,
644972544
Writing inode tables: done Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 20 mounts
or
180 days, whichever comes first. Use tune2fs -c
or -i to override.
# mkdir /test //创建挂载点
# mount /dev/sdb1
/test //挂载存储磁盘
成功后输入:df
-lh即可查看挂载结果了
5、自动挂载
为了在每次系统启动时自动挂载新分区,需要修改/etc/fstab文件来进行自动挂载。在文件的末位加入如下一行:
LABEL=/
/
ext3
defaults
1 1
LABEL=/boot
/boot ext3
defaults
1 2
tmpfs
/dev/shm
tmpfs
defaults
0 0
/dev/sdb1
/test
ext3
_netdev
0 0
注:挂载的存储在编辑/etc/fstab文件时,一定要将倒数第二项写成_netdev和后面的数字一定要是0
0,切记不要写成defaults和1
1。否则系统重启时会报错,无法进入系统,会提示让你输入root密码然后修复,此时输入root密码,使用,之后重新编译/etc/fstab,将之前添加的存储那一行去掉。