共享存储之ISCSI 以及使用

1 简介
2 磁盘分区
3 ISCSITARGET安装和配置
4 ISCSI-INITIATOR安装

1.简介

iSCSI 技术

 多年以来,光纤通道存储区域网 (FC SAN) 是构建基于网络的存储解决方案所使用的唯一技术。基于以前的一组 ANSI 协议(称为光纤分布式数据接口 (FDDI)),开发了光纤通道以在存储网络上移动SCSI命令。


 随着千兆位以太网的普及以及对降低成本的需要,基于 iSCSI 的存储系统逐渐成为光纤通道的有力竞争对手。现在,iSCSI SAN 仍然是 FC SAN 的最大竞争者。


 尽管iSCSI拥有光明的前景,但早期的批评很快指出了其在性能方面的内在不足。iSCSI 的优势是能够利用大家熟悉的 IP 网络作为传输机制。但是,TCP/IP 协议非常复杂并且占用过多的 CPU 资源。而使用iSCSI,大部分对数据进行的处理(TCP 和 iSCSI)都由软件执行,比完全通过硬件处理的光纤通道慢得多。将每个 SCSI 命令映射到等价 iSCSI 事务所带来的开销过大。对许多公司来说,解决方案是取消 iSCSI 软件启动器,投资能够从服务器 CPU 中卸载 TCP/IP 和 iSCSI 处理的专用卡。这些专用卡有时称为 iSCSI 主机总线适配器 (HBA)或 TCP 卸载引擎 (TOE) 卡。还要考虑到目前 10 Gb 以太网是主流!

与其他新技术一样,iSCSI 具有一组自己的缩略语和术语。对于本文来说,用户只需要了解 iSCSI 启动器与 iSCSI 目标之间的区别即可。

iSCSI 启动器

从本质上说,iSCSI 启动器是一个客户端设备,它连接到服务器(在本例中是 iSCSI 目标)提供的某一服务,并发起对该服务的请求。iSCSI 启动器软件需要安装在每个 Oracle RAC 节点(racnode1 和 racnode2)上。

iSCSI 启动器可以用软件实现,也可以用硬件实现。软件 iSCSI 启动器可用于大部分主要操作系统平台。对于本文,我们将使用 iscsi-initiator-utils RPM 中提供的免费 Linux Open-iSCSI 软件驱动程序。iSCSI 软件启动器通常与标准网络接口卡 (NIC)(大多数情况下是千兆位以太网卡)配合使用。硬件启动器是一个 iSCSI HBA(或 TCP 卸载引擎 (TOE) 卡),它本质上只是一个专用以太网卡,其上的 SCSI ASIC 可以从系统 CPU 内卸载所有工作(TCP 和 SCSI 命令)。iSCSI HBA 可以从许多供应商处购买,包括 Adaptec、Alacritech、Intel 和 QLogic。

iSCSI 目标

iSCSI 目标是 iSCSI 网络的“服务器”组件。它通常是一个存储设备,包含您所需的信息并响应来自(一个或多个)启动器的请求。对于本文,节点 openfiler1 将是 iSCSI 目标。
因此,根据有关 iSCSI 的所有这些讨论,是否意味着光纤通道很快就会消失?可能不会。多年以来,光纤通道凭借其极快的速度、灵活性和强健的可靠性,为自己的能力提供了有力的证明。对高性能存储、大型复杂连接以及任务关键可靠性有严格要求的客户将毫不犹豫地继续选择光纤通道。

2 磁盘分区

准备一个空磁盘,我这里是一台双硬盘的机器,IP地址为192.168.3.84,两块硬盘都是300GB,其中一块装OS,另一块作共享磁盘使用。

[root@sharestorage_priv ~]# fdisk -l

Disk /dev/sda: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 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 36472 292856917+ 8e Linux LVM

Disk /dev/sdb: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 cylinders Units = cylinders of 16065 * 512 =
8225280 bytes

Device Boot Start End Blocks Id System

从fdisk显示可以看出sdb是没有使用的磁盘,我就在该磁盘上划分分区

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

The number of cylinders for this disk is set to 36472. 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: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 cylinders Units = cylinders of 16065 * 512 =
8225280 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-36472,
default 1): Using default value 1 Last cylinder or +size or +sizeM or
+sizeK (1-36472, default 36472): +500M

Command (m for help): p

Disk /dev/sdb: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 cylinders Units = cylinders of 16065 * 512 =
8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 62 497983+ 83 Linux Command
(m for help): n Command action e extended p primary
partition (1-4) p Partition number (1-4): 2 First cylinder (63-36472,
default 63): Using default value 63 Last cylinder or +size or +sizeM
or +sizeK (63-36472, default 36472): +50000M

Command (m for help): p

Disk /dev/sdb: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 cylinders Units = cylinders of 16065 * 512 =
8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 62 497983+ 83 Linux
/dev/sdb2 63 6142 48837600 83 Linux

Command (m for help): n Command action e extended p primary
partition (1-4) p Partition number (1-4): 3 First cylinder
(6143-36472, default 6143): Using default value 6143 Last cylinder or
+size or +sizeM or +sizeK (6143-36472, default 36472): +50000M

Command (m for help): p

Disk /dev/sdb: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 cylinders Units = cylinders of 16065 * 512 =
8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 62 497983+ 83 Linux
/dev/sdb2 63 6142 48837600 83 Linux
/dev/sdb3 6143 12222 48837600 83 Linux

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.

再次fdisk看一下

[root@sharestorage_priv ~]# fdisk -l

Disk /dev/sda: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 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 36472 292856917+ 8e Linux LVM

Disk /dev/sdb: 300.0 GB, 300000000000 bytes 255 heads, 63
sectors/track, 36472 cylinders Units = cylinders of 16065 * 512 =
8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 62 497983+ 83 Linux
/dev/sdb2 63 6142 48837600 83 Linux
/dev/sdb3 6143 12222 48837600 83 Linux

显示创建了三个分区,分别是sdb1 500MB,sdb2 50GB,sdb3 50GB。

3 iscsitarget安装和配置(server)

  1. 所需软件
    iscsitarget-1.4.20.1.tar.gz
  2. 软件下载
    在开源软件网站上可以下载到iscsitarget源码包
    wget http://sourceforge.net/projects/iscsitarget/files/latest/download?source=directory
  3. 安装
tar zxvf iscsitarget-1.4.20.1.tar.gz
cd iscsitarget-1.4.20.1
make
make install

安装后会在/etc下生成iet目录,iscsitarget的主要配置文件就在该目录下

[root@sharestorage_priv iet]# tree /etc/iet/

/etc/iet/

|– ietd.conf

|– ietd.conf.original

|– initiators.allow

|– targets.allow

|– targets.allow.origianl

0 directories, 5 files

ietd.conf里有很多注释项,我将ietd.conf copy一份取名为ietd.conf.original,targets.allow copy一份取名为targets.allow.original以备参考。

4. 配置

[root@sharestorage_priv iet]# cat /etc/iet/ietd.conf

Target iqn.2001-04.com.sharestorage:racdb.crs1 Lun 0
Path=/dev/sdb1,Type=blockio

Target iqn.2001-04.com.sharestorage:racdb.data1 Lun 0
Path=/dev/sdb2,Type=blockio

Target iqn.2001-04.com.sharestorage:racdb.fra1 Lun 0
Path=/dev/sdb3,Type=blockio

只允许192.168.3.0网段的客户发现登录iscsi服务

[root@sharestorage_priv iet]# cat /etc/iet/targets.allow

ALL 192.168.3.0/24

启动iscsi-target

[root@sharestorage_priv iet]# /etc/init.d/iscsi-target start

Starting iSCSI Target: [ OK ]

到此为止,iscsi-target就配置完毕,现在iscsi-initiator就可以发现并登陆到iscsi-target。

iscsi-initiator安装(client)

iscsi-initiator的软件包在REDHAT安装光盘中,确定iscsi-initiator-utils是否已经安装

rpm -qa|grep iscsi-initiator-utils

如果iscsi-initiator-utils软件包没安装,用下面的命令安装

rpm -Uvh iscsi-initiator-utils-*

启动iscsid服务,并使其在系统引导时自动启动,还将配置iscsi服务在系统引导时自动启动。

service iscsid start
chkconfig iscsid on
chkconfig iscsi on

发现网络存储服务器上的所有可用目标,存储服务器的ip在本文开头提到192.168.3.84。

[root@rac1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.3.84

192.168.3.84:3260,1 iqn.2001-04.com.sharestorage:racdb.fra1
192.168.3.84:3260,1 iqn.2001-04.com.sharestorage:racdb.data1
192.168.3.84:3260,1 iqn.2001-04.com.sharestorage:racdb.crs1

手动登录到iscsi目标

[root@rac1 ~]# iscsiadm -m node -T iqn.2001-04.com.sharestorage:racdb.fra1 -p 192.168.3.84 -l

Logging in to [iface: default, target:iqn.2001-04.com.sharestorage:racdb.fra1, portal:192.168.3.84,3260]
Login to [iface: default, target:
iqn.2001-04.com.sharestorage:racdb.fra1, portal: 192.168.3.84,3260] successful.

[root@rac1 ~]# iscsiadm -m node -T iqn.2001-04.com.sharestorage:racdb.data1 -p 192.168.3.84 -l

Logging in to [iface: default, target: iqn.2001-04.com.sharestorage:racdb.data1, portal: 192.168.3.84,3260]
Login to [iface: default, target: iqn.2001-04.com.sharestorage:racdb.data1, portal: 192.168.3.84,3260] successful.

[root@rac1 ~]# iscsiadm -m node -T iqn.2001-04.com.sharestorage:racdb.crs1 -p 192.168.3.84 -l

Logging in to [iface: default, target: iqn.2001-04.com.sharestorage:racdb.crs1, portal: 192.168.3.84,3260]
Login to [iface: default, target: iqn.2001-04.com.sharestorage:racdb.crs1, portal: 192.168.3.84,3260] successful.

配置自动登录

[root@rac1 ~]# iscsiadm -m node -T iqn.2001-04.com.sharestorage:racdb.crs1 -p 192.168.3.84 --op update -n node.startup -v automatic
[root@rac1 ~]# iscsiadm -m node -T iqn.2001-04.com.sharestorage:racdb.data1 -p 192.168.3.84 --op update -n node.startup -v automatic
[root@rac1 ~]# iscsiadm -m node -T iqn.2001-04.com.sharestorage:racdb.fra1 -p 192.168.3.84 --op update -n node.startup -v automatic

转载源地址:http://blog.sina.com.cn/s/blog_972d99960101muu0.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值