标签:iscsi服务网络存储
ISCSI网络存储
简介:
网络存储的概述:
Storage Area Network,存储区域网络
1.多采用高速光纤通道,对速率、冗余性要求高
2.使用iSCSI存储协议,块级传输
Network Attachment Storage,网络附加存储
1.采用普通以太网,对速率、冗余无特别要求
2.使用NFS、CIFS共享协议,文件级传输
一.实验环境:
1.两台Linux虚拟机;版本为RedHat6.5
2.一台为服务器,另一台为客户机;
iSCSI的工作方式
服务(设备)端 —— target
客户(应用)端 —— initiator
服务端配置:
1.为服务器准备好三块磁盘:使用fdisk -l,进行查看: [root@server yum.repos.d]# fdisk -l Disk /dev/sda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000a238b Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 2576 20480000 82 Linux swap / Solaris /dev/sda3 2576 5125 20480000 83 Linux /dev/sda4 5125 7833 21748736 5 Extended /dev/sda5 5126 7038 15360000 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdc: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdd: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 2.创建RAID 5: [root@server yum.repos.d]# mdadm -Cv /dev/md0 -a yes -n3 -l5 /dev/sd[bcd] mdadm: layout defaults to left-symmetric mdadm: layout defaults to left-symmetric mdadm: chunk size defaults to 512K mdadm: size set to 20954624K mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. 使用mdadm工具可创建软RAID阵列设备 -C,--create创建新的RAID设备 -n,--raid-devices=阵列所使用的磁盘数量 -l,--level=RAID级别 -Q,--query查询设备的RAID信息 -D,--detail查询RAID设备的详细信息 -S,--stop解散、停止/删 3.查看已创建好的md0 的RAID 5: [root@server yum.repos.d]# mdadm -Q /dev/md0 /dev/md0: 39.97GiB raid5 3 devices, 1 spare. Use mdadm --detail for more detail. 4.RAID阵列的UUID号: [root@server yum.repos.d]# mdadm -D /dev/md0 | grep UUID UUID : 76606a39:4992905e:818210f8:e39ec76c 5.安装iscsi创建工具: .软件包:scsi-target-utils,安装过程略 [root@server yum.repos.d]# yum -y install scsi-target-utils 6.重启服务,查看端口号:为3260 [root@server yum.repos.d]# service tgtd start 正在启动 SCSI target daemon: [确定] [root@server yum.repos.d]# netstat -anpt | grep tgtd tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 7189/tgtd tcp 0 0 :::3260 :::* LISTEN 7189/tgtd 创建iSCSI对象(target) 2.使用tgtdm工具创建target -L、--lld指定驱动类型,如“-L iscsi” -o、--op指定操作类型,如“-o new” -m、--mode指定管理目标,如“-m target” -t、--tid指定对象ID号,如“-t 1” -T、--targetname指定iSCSI对 7.---创建新的iscsi磁盘标识---------- 1)名称规范:iqn.YYY-MM 反向域名:识别标记 [root@server yum.repos.d]# tgtadm -L iscsi -o new -m target -t 1 -T iqn.2015-08.com.benet.store:raid [root@erver yum.repos.d]# tgtadm -L iscsi -o show -m target Target 1: iqn.2011-10.com.benet.store:lvm …… Target 2: iqn.2011-10.com.benet.store:raid System information: Driver: iscsi State: ready I_T nexus information: LUN information: LUN: 0 默认控制LUN,ID为0 Type: controller SCSI ID: IET 00020000 8.为标识创建物理磁盘关联 [root@server yum.repos.d]# tgtadm --lld iscsi -o new -m logicalunit -t 1 -l 1 -b /dev/md0 9.发布设备并指定访问权限: [root@server yum.repos.d]# tgtadm --lld iscsi -o bind -m target -t 1 -I 192.168.100.20 [root@server yum.repos.d]# tgtadm -L iscsi -o show -m target Target 2: iqn.2011-10.com.benet.store:raid …… LUN: 1 Type: disk SCSI ID: IET 00020001 SCSI SN: beaf21 Size: 42947 MB, Block size: 512 Online: Yes Removable media: No Readonly: No Backing store type: rdwr Backing store path: /dev/md0 …… ACL information: 192.168.100.20 10.保存target和LUN设置 1)配置文件 /etc/tgt/targets.conf 2)确保tgtd服务能自动运行 3)在配置文件的末尾,添加一下配置。 [root@server yum.repos.d]# vi /etc/tgt/targets.conf …… </target> <target iqn.2015-08.com.benet.store:raid> backing-store /dev/md0 initiator-address 192.168.100.20 </target> 11.重启服务,并添加开机自启动。 [root@server yum.repos.d]# service tgtd restart 停止 SCSI target daemon: [确定] 正在启动 SCSI target daemon: [确定] [root@server yum.repos.d]# chkconfig --level 35 tgtd on
客户端配置:
1.安装iscsi设备发现客户端软件 2.安装过程略 [root@server yum.repos.d]# yum -y install iscsi-initiator-utils 2.重启服务 [root@server yum.repos.d]# service iscsi start 3.查找指定的设备,这里会提示没找到, 1)因为服务器的防火墙和SELinux没有关闭 [root@server yum.repos.d]# iscsiadm -m discovery -t sendtargets -p 192.168.100.10 正在启动 iscsid: [确定] iscsiadm: cannot make connection to 192.168.100.10: No route to host iscsiadm: cannot make connection to 192.168.100.10: No route to host iscsiadm: cannot make connection to 192.168.100.10: No route to host iscsiadm: cannot make connection to 192.168.100.10: No route to host iscsiadm: cannot make connection to 192.168.100.10: No route to host iscsiadm: cannot make connection to 192.168.100.10: No route to host iscsiadm: connection login retries (reopen_max) 5 exceeded iscsiadm: Could not perform SendTargets discovery: encountered connection failure 2)在服务器上关闭了之后,在继续执行此命令。 [root@server yum.repos.d]# iscsiadm -m discovery -t sendtargets -p 192.168.100.10 192.168.100.10:3260,1 iqn.2015-07.com.benet.store:raid 4.挂载设备 [root@server yum.repos.d]# iscsiadm -m node -T iqn.2015-08.com.benet.store:raid --login lsscsi 5.进行查看dev下的设备 1)这里多出了sdb设备,说明已从服务器上链接。 2)这里磁盘不是本地添加上的,而是远端的服务器提供的 [root@server yum.repos.d]# ls /dev agpgart log pts sda3 tty19 tty43 ttyS1 autofs loop0 ram0 sda4 tty2 tty44 ttyS2 block loop1 ram1 sda5 tty20 tty45 ttyS3 bsg loop2 ram10 sdb tty21 tty46 uinput 5.格式化及挂载访问 fdisk、mkfs、mount操作,与普通设备无异 若iSCSI设备已包含文件系统,则无需再格式化 [root@server ~]# fdisk -l /dev/sdb [root@server yum.repos.d]# mkfs -t ext4 /dev/sdb1 …… Device Boot Start End Blocks Id System /dev/sdb1 1 40927 41909232 83 Linux 6.将设备进行挂载。mount [root@server dev]# mount /dev/sdb1 /opt/ [root@server dev]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 20G 3.1G 16G 17% / tmpfs 936M 224K 936M 1% /dev/shm /dev/sda1 194M 34M 151M 19% /boot /dev/sda5 15G 165M 14G 2% /home /dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1 /dev/sr0 3.6G 3.6G 0 100% /mnt /dev/sdb1 40G 176M 38G 1% /opt 7,iSCSI设备的挂载配置 写入/etc/fstab文件,添加参数 _netdev [root@server ~]# vim /etc/fstab 网络链接以后才会挂载 /dev/sdb1 /opt ext4 defaults,_netdev 0 0 [root@server ~]# blkid /dev/sdb1 /dev/sdb1: UUID="da127d36-cb05-427d-85b3-bce5bccecd68" TYPE="ext4" [root@localhost ~]# vi /etc/fstab 通过UUID挂载更为可靠 …… UUID="da127d36-cb05-427d-85b3-bce5bccecd68 /opt/ ext4 defaults,_netdev 0 0
8.这里已基本完成,挂载完成后,可以往磁盘里面写文件了,
本文出自 “书香名邸” 博客,请务必保留此出处http://duo1314.blog.51cto.com/9961268/1684886
标签:iscsi服务网络存储
原文地址:http://duo1314.blog.51cto.com/9961268/1684886