NAS:网络附加存储服务器
SAN:存储局域网
让LinuxPC变成一台可通过Web管理的NAS:
FressNAS:http://sourceforge.net/projects/freenas/
SAN提供“磁盘”给主机用,可以格式化,分区等;
NAS提供的是“网络协议的文件系统(NFS、SMB等)
iSCSI:Internet SCSI
iSCSI target:相当于服务器
iSCSI initiator:相当于客户端
储存方式:
1.DAS:直接存储
2.NAS:提供文件系统
3.SAN:提供磁盘
使用到的软件:
#用来将Linux系统仿真成为iSCSI target的功能
[root@Centosszm ~]# yum install scsi-target-utils         
#用于挂载iSCSI
[root@Centosszm ~]# yum install iscsi-initiator-utils
主要文件:
/etc/tgt/targets.conf
/usr/sbin/tgt-admin
/usr/sbin/tgt-setup-lun
/usr/sbin/tgtadm
/usr/sbin/tgtd
/usr/sbin/tgtimg
可以使用作的target:
1.文件
2.分区
3.设备
1.建立所需要的磁盘设备。
[root@Centosszm ~]# dd if=/dev/zero of=/srv/iscsi/disk1.img bs=1M count=50
50+0 records in
50+0 records out
52428800 bytes (52 MB) copied, 5.28837 s, 9.9 MB/s
[root@Centosszm ~]# chcon -Rv -t tgtd_var_lib_t /srv/iscsi/
changing security context of `/srv/iscsi/disk1.img'
changing security context of `/srv/iscsi/'
[root@Centosszm ~]# fdisk /dev/sda
[root@Centosszm ~]# partprobe
#查看已挂载SWAP
[root@Centosszm ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda7                               partition       2047992 0       -1
[root@Centosszm ~]# pvcreate /dev/sda10
Physical volume "/dev/sda10" successfully created
[root@Centosszm ~]# vgextend vg_szm /dev/sda10
Volume group "vg_szm" successfully extended
[root@Centosszm ~]# lvcreate -L 50M -n iscsi01 vg_szm
Rounding up size to full physical extent 52.00 MiB
Logical volume "iscsi01" created
[root@Centosszm ~]# lvscan
ACTIVE            '/dev/vg_szm/LogVol00' [8.81 GiB] inherit
ACTIVE            '/dev/vg_szm/iscsi01' [52.00 MiB] inherit
2.规划共享的iSCSI target文件名:iqn(ISCSI Qualifed Name合格名称)
iqn.yyyy-mm.单位网络名的反转写法:这个共享的target名称
3.设置tgt
[root@Centosszm ~]# hostname
Centosszm.test.com
[root@Centosszm ~]# vi /etc/tgt/targets.conf
<target iqn.2013-04.com.Centosszm:szmdisk>
backing-store /srv/iscsi/disk1.img  #整块磁盘用direct-store
#backing-store /dev/sda8
backing-store /dev/vg_szm/iscsi01   #磁盘2
initiator-address 192.168.179.0/24  #用户地址
incominguser szmuser szmpassword    #账号与密码
write-cache off                     #关闭缓存
</target>
[root@Centosszm ~]# /etc/init.d/tgtd start
Starting SCSI target daemon:                               [  OK  ]
#用的是3260这个端口
[root@Centosszm ~]# netstat -tulnp | grep tgt
tcp        0      0 0.0.0.0:3260                0.0.0.0:*                   LISTEN      2766/tgtd
tcp        0      0 :::3260                     :::*                        LISTEN      2766/tgtd
[root@Centosszm ~]# tgt-admin --show
Target 1: iqn.2013-04.com.Centosszm:szmdisk
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller          #这个是控制器,不是可用的LUN
SCSI ID: IET     00010000
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: None
LUN: 1
Type: disk
SCSI ID: IET     00010001
SCSI SN: beaf11
Size: 55 MB            #磁盘大小
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /dev/vg_szm/iscsi01
LUN: 2
Type: disk
SCSI ID: IET     00010002
SCSI SN: beaf12
Size: 52 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /srv/iscsi/disk1.img
Account information:
szmuser          #用户账号
ACL information:
192.168.179.0/24  #可连接IP
#防火墙设置:
[root@Centosszm ~]# iptables -A INPUT -p tcp --dport 3260 -j ACCEPT
[root@Centosszm ~]# /etc/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
iSCSCI initiator的设置:
/etc/iscsi/iscsid.conf:
/sbin/iscsid
/sbin/iscsiadm
/etc/init.d/iscsid
/etc/init.d/iscsi  #这个会呼叫上面那个命令
1.客户端配置文件
[root@szm ~]# vim /etc/iscsi/iscsid.conf
node.session.auth.username = szmuser                #连接时用到的密码
node.session.auth.password = szmpassword
discovery.sendtargets.auth.username = szmuser
discovery.sendtargets.auth.password = szmpassword   #检测时用到的密码
[root@szm ~]# chkconfig iscsid on
[root@szm ~]# chkconfig iscsi on
2.检测192.168.179.7这台target的相关数据
-m discovvery:
-t sendtargets:
-p IP:prot :
[root@szm ~]# iscsiadm -m discovery -t sendtargets -p 192.168.179.7
Starting iscsid:                                           [  OK  ]
192.168.179.7:3260,1 iqn.2013-04.com.Centosszm:szmdisk
[root@szm ~]# ll -R /var/lib/iscsi/nodes/
/var/lib/iscsi/nodes/:
total 4
drw-------. 3 root root 4096 Apr  8 23:50 iqn.2013-04.com.Centosszm:szmdisk
/var/lib/iscsi/nodes/iqn.2013-04.com.Centosszm:szmdisk:
total 4
drw-------. 2 root root 4096 Apr  8 23:50 192.168.179.7,3260,1
/var/lib/iscsi/nodes/iqn.2013-04.com.Centosszm:szmdisk/192.168.179.7,3260,1:
total 4
-rw-------. 1 root root 1897 Apr  8 23:50 default
3.开始进行连接iSCSI target
#找出目前本机上面所有检测到的target信息,可能并未登录
[root@szm ~]# iscsiadm -m node
192.168.179.7:3260,1 iqn.2013-04.com.Centosszm:szmdisk
#登录某台target,不要重新启动iSCSI服务
[root@szm ~]# iscsiadm -m node -T iqn.2013-04.com.Centosszm:szmdisk --login
Logging in to [iface: default, target: iqn.2013-04.com.Centosszm:szmdisk, portal: 192.168.179.7,3260] (multiple)
Login to [iface: default, target: iqn.2013-04.com.Centosszm:szmdisk, portal: 192.168.179.7,3260] successful.
[root@szm ~]# fdisk -l
……
Disk /dev/sdc: 54 MB, 54525952 bytes
2 heads, 52 sectors/track, 1024 cylinders
Units = cylinders of 104 * 512 = 53248 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdd: 52 MB, 52428800 bytes
2 heads, 50 sectors/track, 1024 cylinders
Units = cylinders of 100 * 512 = 51200 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
4.更新/删除/添加target数据的方法
iscsiadm -m node -T targetname --logout
iscsiadm -m node -o [delete|new|update] -T targetname
[root@szm ~]# iscsiadm -m node -T iqn.2013-04.com.Centosszm:szmdisk --logout
Logging out of session [sid: 1, target: iqn.2013-04.com.Centosszm:szmdisk, portal: 192.168.179.7,3260]
Logout of [sid: 1, target: iqn.2013-04.com.Centosszm:szmdisk, portal: 192.168.179.7,3260] successful.
没有删除连接:
[root@szm ~]# iscsiadm -m node
192.168.179.7:3260,1 iqn.2013-04.com.Centosszm:szmdisk
[root@szm ~]# iscsiadm -m node -o delete -T iqn.2013-04.com.Centosszm:szmdisk
[root@szm ~]# iscsiadm -m node
iscsiadm: No records found
#例子:
[root@szm ~]# iscsiadm -m discovery -t sendtargets -p 192.168.179.7
192.168.179.7:3260,1 iqn.2013-04.com.Centosszm:szmdisk
[root@szm ~]# iscsiadm -m node
192.168.179.7:3260,1 iqn.2013-04.com.Centosszm:szmdisk
[root@szm ~]# /etc/init.d/iscsi restart
[root@szm ~]# fdisk -l
……
Disk /dev/sdc: 54 MB, 54525952 bytes
2 heads, 52 sectors/track, 1024 cylinders
Units = cylinders of 104 * 512 = 53248 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdd: 52 MB, 52428800 bytes
2 heads, 50 sectors/track, 1024 cylinders
Units = cylinders of 100 * 512 = 51200 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@szm ~]# pvcreate /dev/sd{c,d}
Physical volume "/dev/sdc" successfully created
Physical volume "/dev/sdd" successfully created
[root@szm ~]# vgcreate iscsi /dev/sd{c,d}
Volume group "iscsi" successfully created
[root@szm ~]# vgdisplay
--- Volume group ---
VG Name               iscsi
System ID
Format                lvm2
Metadata Areas        2
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                2
Act PV                2
VG Size               96.00 MiB
PE Size               4.00 MiB
Total PE              24            #一共24个PE
Alloc PE / Size       0 / 0
Free  PE / Size       24 / 96.00 MiB
VG UUID               nGlC74-pbo5-SrMO-29jd-xhaM-g5ds-A7lLFL
[root@szm ~]# lvcreate -l 24 -n disk iscsi
Logical volume "disk" created
[root@szm ~]# lvdisplay
--- Logical volume ---
LV Path                /dev/iscsi/disk
LV Name                disk
VG Name                iscsi
LV UUID                V8I8UH-9qrh-M671-Gph2-E36Y-jWQ5-vV0MAG
LV Write Access        read/write
LV Creation host, time szm, 2013-04-09 13:35:07 +0800
LV Status              available
# open                 0
LV Size                96.00 MiB
Current LE             24
Segments               2
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:3
[root@szm ~]# mkfs -t ext4 /dev/iscsi/disk
[root@szm ~]# mkdir -p /data/iscsi
#_netdev:需要网络开机启动完成后才会挂载
[root@szm ~]# vim /etc/fstab
/dev/iscsi/disk         /data/iscsi             ext4    defaults,_netdev 1 2
[root@szm ~]# mkdir /data/iscsi/testdir
[root@szm ~]# touch /data/iscsi/testdir/testfile
[root@szm ~]# ll /data/iscsi/
total 14
drwx------. 2 root root 12288 Apr  9 13:35 lost+found
drwxr-xr-x. 2 root root  1024 Apr  9 13:39 testdir
服务器端查看:
[root@Centosszm ~]# tgt-admin --show
Target 1: iqn.2013-04.com.Centosszm:szmdisk
System information:
Driver: iscsi
State: ready
I_T nexus information:
I_T nexus: 3
Initiator: iqn.1994-05.com.redhat:84971b47c598    #这个名字可以修改
Connection: 0
IP Address: 192.168.179.146             #连接进来的IP
LUN information:
LUN: 0
Type: controller
SCSI ID: IET     00010000
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: None
LUN: 1
Type: disk
SCSI ID: IET     00010001
SCSI SN: beaf11
Size: 55 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /dev/vg_szm/iscsi01
LUN: 2
Type: disk
SCSI ID: IET     00010002
SCSI SN: beaf12
Size: 52 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /srv/iscsi/disk1.img
Account information:
szmuser
ACL information:
192.168.179.0/24
#修改名字最好在使用前修改,否则会使得磁盘无法使用。
[root@szm ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.szm:84971b47c598
[root@szm ~]# /etc/init.d/iscsi restart
Stopping iscsi:                                            [  OK  ]
Starting iscsi:                                            [  OK  ]
#发生下面的改变了,郁闷,全得LV不能够使用了。
[root@szm ~]# fdisk -l
Disk /dev/sde: 54 MB, 54525952 bytes
2 heads, 52 sectors/track, 1024 cylinders
Units = cylinders of 104 * 512 = 53248 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdf: 52 MB, 52428800 bytes
2 heads, 50 sectors/track, 1024 cylinders
Units = cylinders of 100 * 512 = 51200 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

转载于:https://blog.51cto.com/2816056/1184397

鸟哥学习笔记---网络驱动器设备iSCSI相关推荐

  1. 鸟哥学习笔记---网络安全基础

    yum clean [packages|header|all] packages:将已下载的软件文件删除 headers:将下载的软件文件头删除 all:将所有容器数据都删除 添加镜像站点:mirro ...

  2. 鸟哥学习笔记六(基础篇第十一章)

    type:查看指令是否是bash内建指令 变量的设定规则 1.  变量与变量内容以一个等号『=』来连结,如下所示: 『myname=VBird』 2.  等号两边不能直接接空格符,如下所示为错误: 『 ...

  3. HALCON 21.11:深度学习笔记---网络和训练过程(4)

    HALCON 21.11:深度学习笔记---网络和训练过程(4) HALCON 21.11.0.0中,实现了深度学习方法.关于网络和训练过程如下: 在深度学习中,任务是通过网络发送输入图像来执行的.整 ...

  4. VBA 学习笔记 - 网络请求

    VBA 学习笔记 - 网络请求 Microsoft.XMLHTTP MSXML2.serverXMLHTTP.6.0 WinHttp.WinHttpRequest.5.1 参考资料 Microsoft ...

  5. 【学习笔记】硬件设备选型

    --学习笔记摘自阅读学习<IT基础架构:系统运维实践>章节 [序言] 硬件平台是支撑生产系统运行的基础设施.随着企业的不断发展,应用负载和数据量在日益增加,只有搭建一套性能优良.稳定可靠的 ...

  6. Python学习笔记:网络编程

    前言 最近在学习深度学习,已经跑出了几个模型,但Pyhton的基础不够扎实,因此,开始补习Python了,大家都推荐廖雪峰的课程,因此,开始了学习,但光学有没有用,还要和大家讨论一下,因此,写下这些帖 ...

  7. Java学习笔记-网络编程

    Java提供了网络编程,并且在实际中有着大量运用 网络编程 网络编程概述 网络模型 OSI参考模型 TCP/IP参考模型 网络通讯要素 IP地址 端口号 传输协议 网络参考模型 网络通讯要素 IP地址 ...

  8. linux运维需要哪些网络知识,Linux运维学习笔记-网络技术知识体系总结

    jTemplates部分语法介绍 1.{#if} {#if |COND|}..{#elseif |COND|}..{#else}..{#/if} Examples: {#if 2*8==16} goo ...

  9. java 学习笔记-网络编程(八)

    网络编程 标签:学习各种网络协议的桥梁 什么是计算机网络 计算机网络的作用:资源共享和信息传递. 计算机网络的组成: a) 计算机硬件:计算机(大中小型服务器,台式机.笔记本等).外部设备(路由器.交 ...

最新文章

  1. 多商家分销商城系统如何开发?
  2. first day
  3. Chrome检查更新总失败?安装细则讲解
  4. 用C/C++编写window服务
  5. git github的使用
  6. config设置源 使用pip_python pip源配置
  7. 理清逻辑,确保云原生时代应用开发的全生命周期安全
  8. linux安装yum的脚本,lnmp一键安装脚本yum方式快速安装
  9. 我的Android学习之路
  10. 19. 顺时针打印矩阵
  11. 锁php_基于 Redis 实现分布式锁及对应的 PHP 实现源码
  12. 北航计算机考研计算机组成原理,北航计算机组成原理讲义.pdf
  13. java新闻发布系统源代码_Java新闻发布系统源代码
  14. php扩展-ioncube组件的安装方法_最新Phpstudy 安装 Ioncube Loader扩展方法分享
  15. ue 清理缓存_浏览器缓存数据清理
  16. iOS之Swift实现二维码扫描
  17. photoshop抠图
  18. EI检索ISTP检索ICFMD 2011年制造与设计科学技术会议
  19. BUUCTF题目:easyre
  20. IT痴汉的工作现状12-叶志坚离职了

热门文章

  1. Jedis 设置key的超时时间
  2. 对于经常需要truncate的表进行固定统计信息
  3. android项目中单实例数据库类
  4. struts2中jsp页面上验证码的生成
  5. .NET设计模式(7):创建型模式专题总结(Creational Pattern)
  6. 环境在c盘_如何给女朋友解释为什么 Windows 上面的软件都把自己安装在 C 盘
  7. zabbix3监控ESXI主机
  8. git add * 提示warning: LF will be replaced by CRLF in 解决办法
  9. mac SecureCRT设置
  10. [ActionScript 3.0] 安全沙箱的类型sandboxType,判断当前程序是AIR还是web程序