Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1110225
  • 博文数量: 309
  • 博客积分: 6093
  • 博客等级: 准将
  • 技术积分: 3038
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-03 17:14
个人简介

linux学习记录

文章分类

全部博文(309)

文章存档

2014年(2)

2012年(37)

2011年(41)

2010年(87)

2009年(54)

2008年(88)

分类:

2009-06-30 16:37:44

Iscsi包:  iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm

rpm包

将iscsi包cp到本地盘,并在该包所在的目录下运行命令

[root@linux ~]# rpm –ivh iscsi-initiator-utils-6.2.0.742-0.5.el5.i386.rpm

运行此命令后,会生成一个目录/etc/iscsi,该目录下有两个文件:

Initiatorname.iscsi和iscsid.conf

ISCSI服务

安装完iscsi服务默认是关闭的,需要手工启动

[root@linux ~]# cd /etc/init.d

[root@linux ~]# ./iscsi start

运行以下命令搜寻target,即目标端:7612i存储

[root@linux ~]#iscsiadm --mode discovery --type sendtargets --portal 192.168.1.221

以上IP即是7612i的iscsi口的IP,其它固定。

显示存储端target name

[root@linux ~]# iscsiadm --mode node

显示结果与在7612i串口 iscsi management→iscsi node名字相同

target登陆

[root@linux ~]#iscsiadm --mode node --targetname targetname --portal 192.168.1.221:3260 --login

    其中targetname即是步骤4中结果。(注:横杆是中杠)

(注:3,4,5实施中是在/etc/iscsi下运行,是否可以在别的路径执行,可自行测试。以上3个命令格式是从man iscsiadm查出)

经过以上几步,fdisk –l就可以看到所挂接分区了,为确保重启后也能看到,再修改一下/etc/iscsi/iscsid.conf,将第5步的命令iscsiadm --mode node --targetname targetname --portal 192.168.1.221:3260 --login

[root@linux ~]# vi /etc/iscsi/iscsid.conf

iscsiadm --mode node --targetname targetname --portal 192.168.1.221:3260 –login

添加到该文件中的开始部分

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

# Startup settings

#*****************   这个栏下面即可。

其实这个文件大多数内容处于被注释状态,该命令添加位置应该影响不大.然后重启电脑后直接fdisk –l 依然可以看到所挂接的分区。至此iscsi所有操作完成,但挂载的分区不是linux所识别,必须使用FDISK进行磁盘分区。

fdisk命令进行磁盘分区

fdisk是各种Linux发行版本中最常用的分区工具,是被定义为Expert级别的分区工具。我们可以通过fdisk来分区使用iscsi设备。它还包括一个二级选单,首先输入命令,然后出现问答式界面,用户通过在这个界面中输入命令参数来操作fdisk。

# fdisk /dev/hdb

运行后出现fdiak的命令提示符:

Command (m for help):

使用n命令创建一个分区,会出现选择主分区(p primary partition)还是扩展分区(l logical)的提示,通常选用主分区。然后按照提示输入分区号(Partion number(1-4):)、新分区起始的磁盘块数(First Cylinder)和分区的大小,可以是以MB为单位的数字(Last cylindet or +siza or +sizeM or +sizeK:)。例如:

[root@linux ~]#fdisk /dev/sdb

查看分区,如果是第一次操作时,显示为无。

Command (m for help):p

 

Disk /dev/sdb:255 heads, 63 sectors, 4427 cylinders

Units = cylinders of 16065 * 512 bytes

 

Device Boot    Start       End    Blocks   Id  System

建立分区

Command (m for help):n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-4427, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-4427, default 4427):

Using default value 4427

保存分区信息

Command (m for help):w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING:If you have created or modified any DOS 6.x

partitions, please see the fdisk manual page for additional

information.

Syncing disks.

[root@linux ~]# fdisk /dev/sdb

 

The number of cylinders for this disk is set to 4427.

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):p

 

Disk /dev/sdb:255 heads, 63 sectors, 4427 cylinders

Units = cylinders of 16065 * 512 bytes

 

Device Boot    Start       End    Blocks   Id  System

/dev/sdb1             1      4427  35559846   83  Linux

 

Command (m for help):q

[root@localhost ~]# mkfs -t ext3 /dev/sdb1

mke2fs 1.39 (29-May-2006)

Filesystem label=OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

214761472 inodes, 429495759 blocks

21474787 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=0

13108 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

 

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 31 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

文件系统必须有一个挂载点,它只是一个空的目录,新文件系统在这里与系统目录树“相连”。经过以上的操作,我的 Linux服务器已经连接到 iSCSI 储存设备, 并且如同Linux 本机上面的一个 SCSI 硬盘一样。 使用的方式几乎一模一样。

假设iSCSI 主机挂载到 /cluster/raid 目录下:

[root@linux ~]# mkdir /cluster/raid

[root@linux ~]# mount  /dev/sda1 /cluster/raid

[root@linux ~]# df

Filesystem       1K-blocks          Used    Available  Use%  Mounted on

/dev/hda1         10080488       2950408     6618012   31%   /

tmpfs              5036316         81172     4699312   0%    /dev/shm

/dev/sda1       1914788196      27040372  1790482212   2%    /cluster/raid

在机器重新启动后自动加载分区,你必须在/etc/fstab中加入相应分区,但分区类型必须市"_netdev".例如加载的分区sdb1:

 

[root@linux ~]# vi /etc/fstab

/dev/sdb1   /cluster/raid   ext3    ­_netdev     0   0

/dev/sdc1   /data/sdc1      ext3    _netdev     0   0

/dev/sdd1   /data/sdd1      ext3    _netdev     0   0

[root@localhost ~]# df -h

文件系统              容量    已用     可用     已用%      挂载点

/dev/sda1              64G    5.6G      55G     10%         /

tmpfs                 1.7G       0     1.7G      0%         /dev/shm

/dev/sdb1             1.6T    197M     1.5T      1%         /data/sdb1

/dev/sdc1             1.6T    197M     1.5T      1%         /data/sdc1



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