1.什么是 iSCSI
iSCSI( internet Small Computer System Interface )是由IEETF开发的网络存储标准,目的是为了用IP协议将存储设备连接在一起。通过在IP网上传送SCSI命令和数据,iSCSI推动了数据在网际之间的传递,同时也促进了数据的远程管理。由于其出色的数据传输能力,iSCSI协议被认为是促进存储区域网(SAN)市场快速发展的关键因素之一。
SAN(Storage Area Network),专门用于传输磁盘数据块的网络,不同于一般的TCP/IP网络。一般SAN使用光纤(FC: Fibre Channel)设备,而iSCSI通常使用Gigabit Ethernet(一般是以太网线榄)作为传输介质。
1.1 Target 和 Initiator
SAN中通常有两个角色 Target 和 Initiator
Target一般指 存储设备 (Storage Device),在使用iSCSI的时候,会在Target上建立LUN(Logical Unit Number) 来提供给有iSCSIInitiator 功能的主机来访问iSCSITarget 设备。
Initiator主要功能是连接到Target,可以用硬件或软件实现
1.2 iSCSI 存储系统架构
从架构上可以分为4种类型的架构。
- 控制器架构
iSCSI的核心处理单元采用与FC光纤存储设备相同的结构。即采用专用的数据传输芯片、专用的RAID数据校验芯片、专用的高性能cache缓存和专用的嵌入式系统平台。打开设备机箱时可以看到iSCSI设备内部采用无线缆的背板结构,所有部件与背板之间通过标准或非标准的插槽链接在一起,而不是普通PC中的多种不同型号和规格的线缆链接。
iSCSI连接桥架构整个iSCSI存储分为两个部分,一个部分是前端协议转换设备,另一部分是后端存储。结构上类似NAS网关及其后端存储设备。前端协议转换部分一般为硬件设备,主机接口为千兆以太网接口,磁盘接口一般为SCSI接口或FC接口,可连接SCSI磁盘阵列和FC存储设备。通过千兆以太网主机接口对外提供ISCSI数据传输协议。后端存储一般采用SCSI磁盘阵列和FC存储设备,将SCSI磁盘阵列和FC存储设备的主机接口直接连接到iSCSI桥的磁盘接口上
PC架构那么何谓PC架构?按字面的意思可以理解为存储设备建立在PC服务器的基础上。即就是选择一个普通的、性能优良的、可支持多块磁盘的PC(一般为PC服务器和工控服务器),选择一款相对成熟稳定的iSCSI target软件,将iSCSI Target软件安装在PC服务器上,使普通的PC服务器转变成一台iSCSI存储设备,并通过PC服务器的以太网卡对外提供iSCSI数据传输协议。
PC+NIC架构PC+ISCSI TARGET软件方式是一种低价低效比的解决方案,另外还有一种基于PC+NIC的高阶高效性ISCSI 方案。
如果只是将高速ETHERNET用于存储网络化过于可惜,因此众多厂商发起了IWARP,不仅可实现存储网络化,也能实现I/O 的网络化。通过RDMA(REMOTE DIRECT MEMORY ACCESS)机制简化网络两端的内存数据交换程序,从而加速数据传输效率。
目前BROADCOM提出所谓的C-NIC(CONVERGED NIC)聚合型网卡理念,即是在一颗NETXTREME II 系列的GBE控制芯片内同时具备以太网络、存储网络化、I/O网络化等功效。传统以太网部分具有TOE运算,存储网络化则具备ISCSI运算、I/O网化则具备RDMA运算,大幅卸除CPU的辅助运算,使CPU占用率降至20%以下。
Broadcom 目前的代表性芯片为BCM5706(PCI/PCI-X 接口)与BCM5708S(PCIe 接口),其中BCM5706 为第一代,BCM5708S 为第二代,第二代传输率从1Gbps 提升至2.5Gbps。第三代传输率从2.5Gbps 提升至10Gbps。
1.3 iSCSI 存储连接方式
iSCSI设备的主机接口一般默认都是IP接口,可以直接与以太网络交换机和iSCSI交换机连接,形成一个存储区域网络。根据主机端HBA卡、网络交换机的不同,iSCSI设备与主机之间有三种连接方式
- 以太网卡+initiator软件方式
服务器、工作站等主机使用标准的以太网卡,通过以太网线直接与以太网交换机连接,iSCSI存储也通过以太网线连接到以太网交换机上,或直接连接到主机的以太网卡上。在主机上安装Initiator软件。安装Initiator软件后,Initiator软件可以将以太网卡虚拟为iSCSI卡,接受和发送iSCSI数据报文,从而实现主机和iSCSI设备之间的iSCSI协议和TCP/IP协议传输功能。
这种方式由于采用普通的标准以太网卡和以太网交换机,无需额外配置适配器,因此硬件成本最低。缺点是进行ISCSI包文和TCP/IP包文转换要点主机端的一部分资源。不过在低I/O和低带宽性能要求的应用环境中和完全满足数据访问要求。
目前很多最新版本的常用操作系统都提供免费的Initiator软件,建立一个存储系统除了存储设备本身外,基本上不需要投入更多的资金来,因此在三种系统连接方式中其建设成本是最低的。
- 硬件TOE网卡+initiator软件方式
第一种方式由于采用普通以太网卡和以太网交换机,无需额外配置适配器,或专用的网络设备,因此硬件成本最低。但由于进行ISCSI包文和TCP/IP包文的打包和解包全部需要主机主处理器CPU来进行运算,数据传输率直接受到主机当前运行状态和可用资源的影响和限制,因此一般无法提供高带宽和高IOPS性能。
具有TOE(TCP Offload Engine)功能的智能以太网卡可以将网络数据流量的处理工作全部转到网卡上的集成硬件中进行,把系统主处理器CPU从忙于协议处理的繁重的内核中断服务中解脱出来,主机只承担TCP/IP控制信息的处理任务。与第一种方式相比,采用TOE卡可以大幅度提高数据的传输速率。TCP/IP协议栈功能由TOE卡完成,而iSCSI层的功能仍旧由主机来完成。
由于TOE卡也采用TCP/IP协议,相当于一块高性能的以太网卡,所以第二种方式也可以看做是第一种连接方式的特殊情况。
- iSCSI HBA卡连接方式
在主机上安装专业的iSCSI HBA适配卡,从而实现主机与交换机之间、主机与存储之间的高效数据交换。与前两种方式相比,第三种连接方式中采用了iSCSI HBA卡,因此数据传输性能最好,价格也最高。
后两种方式都需要在主机上安装专门的硬件板卡,由于目前TOE网卡和iSCSI HBA的市场价格都比较贵。如果网络中主机数量比较多,那么网络总资金投入不见得会比FC-SAN存储系统低很多,网络的带宽和性能却相比FC-SAN存储系统差了很多。
2. Linux 应用 iSCSI 技术
2.1安装 iSCSI Target
[root@localhost iscsitarget-0.4.17]# pwd /root/iscsitarget-0.4.17 [root@localhost iscsitarget-0.4.17]# ls ChangeLog COPYING doc etc include kernel Makefile patches README README.vmware usr [root@localhost iscsitarget-0.4.17]# make ... [root@localhost iscsitarget-0.4.17]# make install ...
2.2 配置
- /etc/ietd.conf
默认所有项都用"#"注释掉了。我们只要使用两项就可以简单实现:
Target iqn.2008-12.turbolinux.com.cn:storage.disk2.sys1.xyz Lun 4 Path=/iscsi-test-file,Type=fileio
然后启动进程:
[root@dev3-140 iscsitarget-0.4.17]# /etc/init.d/iscsi-target start
Path=/iscsi-test-file 是一个文件,用dd创建:
dd if=/dev/zero of=/iscsi-test-file count=500000
我的 Target 机器的
IP是 172.16.70.140,在 Initiator 机器上启动 iscsi 进程就可以访问了。启动之前还要设置 InitiatroName,TurboLinux路径在/etc/iscsi目录下:
[root@dev3-140 ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.1994-05.com.redhat:684d156d907d
上面的InitiatorName可以使用 /sbin/iscsi-iname 创建:
[root@dev3-140 ~]# /sbin/iscsi-iname iqn.1994-05.com.redhat:d55ad3dba29b
现在可以访问了
# /etc/init.d/iscsi start <= 启动 iscsi 进程 注意,一般上面命令执行完就能自动连接上了,如果出现问题,在试试下面手动连接 # iscsiadm --mode discovery --type sendtargets -p 172.16.70.140 < = 需要先查看 Target # iscsiadm -m node -l -p 172.16.70.140 <= 连接上 Target ... # iscsiadm -m node -u -p 172.16.70.140 <= 退出连接 ...
可以加上
-d8参数,查看debug信息
网上一篇资料(使用rhel5的最新target)
CentOS 5.2+Raid 0+LVM+ISCSI配置详解
[本文结尾附PDF] 系统环境:CentOS 5.2 硬件配置:ASUS P5GC-MX +Intel E2160+Kinston 1GB 667*2+D-Link 530 1Gbps 硬盘1:Seagate 80GB/7200S/8MB/SATA 硬盘2:Seagate 1TB/7200S/32MB/SATA 硬盘3:Seagate 1TB/7200S/32MB/SATA
场景: 一台用于备份文件的服务器目前空间不足(使用Symantec Backup Exec 10d for Windows Servers备份软件,备份文件服务器的所有数据,保留15天,每周六完整备份,周一至周五增量备份,现有2TB的空间已用完),该服务器已安装8个(容量与规格不一,有SCSI/IDE/SATA)硬盘,机箱内已无空间再增加硬盘,经过考虑,决定重新安装一台LINUX服务器配置ISCSI服务(提供Target Server角色),在Windows Server 2003上安装Microsoft iSCSI Initiator驱动,添加ISCSI硬盘,解决目前的空间问题;
Target Server要求系统安装在ST 80GB的硬盘上,两块1TB的硬盘配置为Raid 0,然后在Raild 0硬盘上配置LVM,在LVM上创建两个逻辑卷,LV1(data1)为1.5TB,LV2(data2)为325GB;
Target server 建立两个target device,将LVM创建的两个逻辑卷分别加入两个target device,node1连接到target device 1(iqn.2008-12.cn.lanexpert:iscsi-data1),node2连接到target device 2(iqn.2008-12.cn.lanexpert:iscsi-data2)
功能 操作系统 主机名称 IP地址 Iscsi-target server CentOS 5.2 Fsbak2.lanexpert.cn 192.168.3.19 Iscsi-initiator(node1) Windows Server 2003 Std R2 with sp2 Fsbak1.lanexpert.cn 192.168.3.18 Iscsi-initiator(node2) Windows XP Pro With sp3 Client1.lanexpert.cn 192.168.11.108
Target Server系统安装在Seagate 80GB的硬盘上,在安装系统时,根据以下要求分区(仅为个人习惯,供参考),其它两个1TB的硬盘暂时不分区; /boot 100MB / 10GB /usr 20GB /home 10GB /var 30GB Swap 3GB
系统选择最小化安装,仅安装最基本的服务;
一、 配置Raid 0 -l (显示所有连接在主机上的硬盘) Disk /dev/sda: 80.0 GB, 80025280000 bytes 255 heads, 63 sectors/track, 9729 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 2624 20972857+ 83 Linux /dev/sda3 2625 3929 10482412+ 83 Linux /dev/sda4 3930 9729 46588500 5 Extended /dev/sda5 3930 5234 10482381 83 Linux /dev/sda6 5235 5708 3807373+ 82 Linux swap / Solaris /dev/sda7 5709 9729 32298651 83 Linux
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
从以上信息可以看到,/dev/sda连接的是我们的系统分区,其它两个硬盘(sdb and sdc)没有分区表;
现在,我们要为另外两个硬盘分别创建分区,参考如下:
/dev/sdb The number of cylinders for this disk is set to 121601. 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 t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): new Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-121601, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601): Using default value 121601
Command (m for help): type Selected partition 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): write The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
重复以上命令对sdc进行分区;
完毕后使用fdisk –l查看分区信息: -l isk /dev/sda: 80.0 GB, 80025280000 bytes 255 heads, 63 sectors/track, 9729 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 2624 20972857+ 83 Linux /dev/sda3 2625 3929 10482412+ 83 Linux /dev/sda4 3930 9729 46588500 5 Extended /dev/sda5 3930 5234 10482381 83 Linux /dev/sda6 5235 5708 3807373+ 82 Linux swap / Solaris /dev/sda7 5709 9729 32298651 83 Linux
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 1 121601 976760001 fd Linux raid autodetect
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdc1 1 121601 976760001 fd Linux raid autodetect
配置raid使用mdadm命令,有关该命令的具体参数参考man mdadm;
# mdadm —create /dev/md0 —level=0 —raid-devices=2 /dev/sdb1 /dev/sdc1 mdadm: array /dev/md0 started.
# cat /proc/mdstat #查看Raid信息 Personalities : [raid0] md0 : active raid0 sdc11 sdb1[0]
1953519872 blocks 64k chunks
unused devices: <none>
# fdisk -l
Disk /dev/sda: 80.0 GB, 80025280000 bytes 255 heads, 63 sectors/track, 9729 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 2624 20972857+ 83 Linux /dev/sda3 2625 3929 10482412+ 83 Linux /dev/sda4 3930 9729 46588500 5 Extended /dev/sda5 3930 5234 10482381 83 Linux /dev/sda6 5235 5708 3807373+ 82 Linux swap / Solaris /dev/sda7 5709 9729 32298651 83 Linux
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 1 121601 976760001 fd Linux raid autodetect
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdc1 1 121601 976760001 fd Linux raid autodetect
Disk /dev/md0: 2000.4 GB, 2000404348928 bytes 2 heads, 4 sectors/track, 488379968 cylinders Units = cylinders of 8 * 512 = 4096 bytes
Disk /dev/md0 doesn't contain a valid partition table
# mdadm —detail —scan ARRAY /dev/md0 level=raid0 num-devices=2 UUID=bf5eb6f7:da2e7196:dc2b05b5:fa5903c1
为了让系统开机启动时自动加载raid信息,可以使用以下命令将配置信息写入/etc/mdadm.conf文件,该文件默认没有,可自行创建;
DEVICE /dev/sdb1 /dev/sdc1 > /etc/mdadm.conf –detail –scan >> /etc/mdadm.conf (—为两个中短线)
# cat /etc/mdadm.conf DEVICE /dev/sdb1 /dev/sdc1 ARRAY /dev/md0 level=raid0 num-devices=2 UUID=bf5eb6f7:da2e7196:dc2b05b5:fa5903c1
二、 配置LVM;
要配置LVM,可以按以下步骤进行: 1. 创建和初始化物理卷(Physical Volume),通过pvcreate建立pv,即pv阶段; 2. 添加物理卷到卷组(Volume Group),使用vgcreate加入多个pv成为vg,即vg阶段; 3. 在卷组上创建逻辑卷(logical volume),使用lvcreate划分vg,成为一个或多个lv,即lv阶段;
# pvcreate /dev/md0 #创建PV
Physical volume "/dev/md0" successfully created
# pvscan
PV /dev/md0 VG LVM1 lvm2 [1.82 TB / 1.82 GB free] Total: 1 [1.82 TB] / in use: 1 [1.82 TB] / in no VG: 0 [0 ]
# vgcreate LVM1 /dev/md0 #创建VG
Volume group "LVM1" successfully created
# vgdisplay LVM1
— Volume group — VG Name LVM1 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 1.82 TB PE Size 4.00 MB Total PE 476933 Alloc PE / Size 0 / 0 Free PE / Size 476933 / 1.82 TB VG UUID 97Fecv-lBFP-oB19-dfrF-wJ7y-9KJ9-9sIKYG
# lvcreate -L 1.5TB -n data1 LVM1 #创建LV
/dev/cdrom: open failed: Read-only file system Logical volume "data1" created
# lvcreate -L 325GB -n data2 LVM1 #创建LV
/dev/cdrom: open failed: Read-only file system Logical volume "data2" created
# lvscan #查看LV信息
ACTIVE '/dev/LVM1/data1' [1.50 TB] inherit ACTIVE '/dev/LVM1/data2' [325.00 GB] inherit
# pvscan #再次查看PV信息
PV /dev/md0 VG LVM1 lvm2 [1.82 TB / 2.02 GB free] Total: 1 [1.82 TB] / in use: 1 [1.82 TB] / in no VG: 0 [0 ]
# vgdisplay LVM1 #再次查看VG信息
— Volume group — VG Name LVM1 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 1.82 TB PE Size 4.00 MB Total PE 476933 Alloc PE / Size 476416 / 1.82 TB Free PE / Size 517 / 2.02 GB VG UUID 97Fecv-lBFP-oB19-dfrF-wJ7y-9KJ9-9sIKYG
到这里,本实例的LVM配置完成; 注意:由于要将LV挂载到iscsi,所以,在这里不必格式化,也不必将LV挂载到系统中,以下是挂载方法,如应用于其它地方,可以参考;
格式化逻辑卷 -j /dev/LVM1/data1 -j /dev/LVM1/data2
参数说明: -j :本来mke2fs是ext2,加上-j后,会主动加入日志而成为ext3
挂载命令,本例不需要将以下两个LV挂载到系统中; /dev/LVM1/data1 /data1 /dev/LVM1/data2 /data2
设置开机自动挂载: 编辑/etc/fstab 0 and LVM1 /dev/LVM1/data1 /data1 ext3 defaults 2 2 /dev/LVM1/data2 /data2 ext3 defaults 2 2
★有关挂载参数说明,请参考鸟哥私房菜——基础学习篇
三、 配置ISCSI 1、 安装iscsi-target,iscsi-target可以从以下网址下载: ftp://ftp.muug.mb.ca/mirror/cent ... 20snap.el5.i386.rpm -ivh scsi-target-utils-0.0-0.20070620snap.el5.i386.rpm
# netstat -tunlp |grep tgtd tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 2295/tgtd tcp 0 0 :::3260 :::* LISTEN 2295/tgtd
可以看到,默认target server使用的服务端口是tcp 3260; 2、 建立target device Centos 5.0以上是利用tgtadm命令来设置而不是编写/etc/ietd.conf(据台湾朋友Alex Lin介绍,4.0是通过编写/etc/ietd.conf来配置的,本节也是参考Alex的文章测试的),个人认为tgtadm的命令相关参数真的较难记,幸好scsi-target-utils软件中包含如何利用tagadm命令建立target device的步骤,建议读者一定要把/usr/share/doc/scsi-target-utils-0.0/README.iscs打开阅读,里面有举例说明可参考;
现准备新增iqn名为iqn.2008-12.cn.lanexpert:iscsi-data1的target device [iscsi qualified name] (简称iqn),格式通常如下: 格 式 意 义 范 例 Yyyy-mm 年-月 2008-12 Reversed domain name 把域名反过来写 Cn.lanexpert identifier 识别字,通常描述这个储存空间的用途 Iscsi-data1
新增target device 命令如下:
—lld iscsi —op new —mode target —tid 1 -T iqn.2008-12.cn.lanexpert:iscsi-data1
执行后,可以利用以下命令查看target device: # tgtadm —lld iscsi —op show —mode target Target 1: iqn.2008-12. cn.lanexpert:iscsi-data1
System information: Driver: iscsi Status: running LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf1:0 SCSI SN: beaf10 Size: 0 Backing store: No backing store Account information: ACL information: 3、 将target server 新建的LV1(/dev/LVM1/data1)加入target device —lld iscsi —op new —mode logicalunit —tid 1 —lun 1 -b /dev/LVM1/data1 将逻辑卷加入target device后,利用下列命令查看target device的信息: # tgtadm —lld iscsi —op show —mode target Target 1: iqn.2008-12. cn.lanexpert:iscsi-data1 System information: Driver: iscsi Status: running I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf1:0 SCSI SN: beaf10 Size: 0 Backing store: No backing store LUN: 1 Type: disk SCSI ID: deadbeaf1:1 SCSI SN: beaf11 Size: 1T Backing store: /dev/LVM1/data1 Account information: ACL information:
4、 允许initiator主机node1(192.168.3.1可以存取此target device —lld iscsi —op bind —mode target —tid 1 -I 192.168.3.18
将逻辑卷加入target device后,利用下面的命令查看target device的信息: # tgtadm —lld iscsi —op show —mode target Target 1: iqn.2008-12.local.superlgroup.xt:iscsi-data1
System information: Driver: iscsi Status: running I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf1:0 SCSI SN: beaf10 Size: 0 Backing store: No backing store LUN: 1 Type: disk SCSI ID: deadbeaf1:1 SCSI SN: beaf11 Size: 1T Backing store: /dev/LVM1/data1 Account information: ACL information:
- 168.3.18
再使用以下命令创建另一个target device: tgtadm —lld iscsi —op new —mode target —tid 2 -T iqn.2008-12.cn.lanexpert:iscsi-data2 tgtadm —lld iscsi —op new —mode logicalunit —tid 2 —lun 1 -b /dev/LVM1/data2 tgtadm —lld iscsi —op bind —mode target —tid 2 -I 192.168.11.108
创建完毕后,再利用下面的命令查看target device: # tgtadm —lld iscsi —op show —mode target Target 1: iqn.2008-12.cn.lanexpert:iscsi-data1
System information: Driver: iscsi Status: running I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf1:0 SCSI SN: beaf10 Size: 0 Backing store: No backing store LUN: 1 Type: disk SCSI ID: deadbeaf1:1 SCSI SN: beaf11 Size: 1T Backing store: /dev/LVM1/data1 Account information: ACL information:
- 168.3.18
Target 2: iqn.2008-12.cn.lanexpert:iscsi-data2
System information: Driver: iscsi Status: running I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf2:0 SCSI SN: beaf20 Size: 0 Backing store: No backing store LUN: 1 Type: disk SCSI ID: deadbeaf2:1 SCSI SN: beaf21 Size: 325G Backing store: /dev/LVM1/data2 Account information: ACL information:
- 168.11.108
5、 修改/etc/rc.local,设置开机自动加载target device配置 因为以上命令的配置结果,重新开机后便会消失,而且现版本的target server,Redhat尚未修改成System V服务,如果需要系统重新启动后上述配置仍然有效,只能将以上配置写入/etc/rc.local,让系统每次开机都自动执行一次:
# ISCSI target device setting -LingPing 2008/12/06 1 (Space 1.5TB) tgtadm —lld iscsi —op new —mode target —tid 1 -T iqn.2008-12.cn.lanexpert:iscsi-data1 tgtadm —lld iscsi —op new —mode logicalunit —tid 1 —lun 1 -b /dev/LVM1/data1 tgtadm —lld iscsi —op bind —mode target —tid 1 -I 192.168.3.18
2 (Space 325GB) tgtadm —lld iscsi —op new —mode target —tid 2 -T iqn.2008-12.cn.lanexpert:iscsi-data2 tgtadm —lld iscsi —op new —mode logicalunit —tid 2 —lun 1 -b /dev/LVM1/data2 tgtadm —lld iscsi —op bind —mode target —tid 2 -I 192.168.11.108
由于tgtdm的参数短时间内难于记忆,建议多参考man或以下提及的文章; 本节主要参考台湾朋友林彦明的大作,在鸟哥的网站可下载到,原文还详细介绍了iscsi initiator on rhel 5.1的配置,值得一读;
四、 配置Windows(Initiator)系统连接到ISCSI
Initiator主要是负责电脑连接到target作磁盘读取功能,如果是Windows系统,可以到Microsoft的官方网站下载最新版本的initiator,可在以下网址选择适合自己的版本: http://www.microsoft.com/downloa ... &DisplayLang=en
1、安装initiator 双击iator-2.08-build3825-x86fre.exe依提示进行安装,安装完毕后,会在桌面上产生一个Microsoft iSCSI Initiator图标;
2、配置initiator 双击Microsoft iSCSI Initiator图标,在discovery选项的target portals框中,选择add,填写target portals的地址,例如192.168.3.19,端口保持默认;如图:
数秒钟后,可以在targets选项中看到刚才在target server建立的iqn名称(是经过授权的,未经授权的将不会显示出来),本例中的截图是node2,所以显示的是iqn.2008-12.cn.lanexpert:iscsi-data2
在上图中,点击log on,出现如下所示对话框,建议勾选第一个选项,让系统重启后自动加载;
然后打开我的电脑-属性-管理-磁盘管理,会弹出一个初始化磁盘的向导,依向导提示即可如操作本机中的硬盘一样进行分区、格式化等工作;
主要参考资料:Linux系统管理手册(第二版)、鸟哥私房菜、林彦明朋友的专题文章(rhel5-iscsi.pdf) LingPing 2008/12/06 http://blog.sina.com.cn/zenglingping http://blog.chinaunix.net/u2/71174/showart_1683305.html
