网络存储服务器

    目前计算机领域的存储解决方案主要有直连存储(DAS),存储区域网络(SAN)以及网络附加存储(NAS)三种,其中DAS(Direct-Attached Storage)指的是主机总线直接通过SCSI接口与存储设备相连,这种连接方式主要应用在家庭个人电脑环境中;SAN(Storage Area Network)指的是一整套存储网络的解决方案,SAN采用的是光纤通道技术,SAN就是通过光纤交换机将服务器与存储设备连接在一起的网络整体环境,SAN的优势在于其先进的光纤通信技术,为当今爆炸式的数据增长环境提供了快速高效的存储方案;NAS(network-Attached Storage)可以使用普通的网络环境,通过以太网交换机等设备连接服务器与存储设备,NAS的优势在于无须对网络环境进行改造,NAS可以使用现有的网络环境,而且不同厂家的设备只要采用TCP/IP协议,就可以满足设备之间对兼容性的要求,NFS与CIFS就属于网络附加存储的解决方案,他们都提供了对文件系统的共享。不管是NAS还是SAN,他们都可以实现企业环境中服务器与存储设备相分离的要求。这样服务器就可以专注于服务器业务,而存储设备则专注于数据存储的速度与安全,并且由于服务器与存储设备是分离的,这样多台服务器就可以加载同一台存储设备中的数据,实现数据的集中,统一管理。由于传统的SAN需要昂贵的光纤设备作为基础,所以现在又有了基于IP技术的SAN,可以通过IP网络进行数据存储,服务器在不进行任何改造的情况下使用现有的以太网卡就可以访问IP SAN(ISCSI就是这样的技术)。NSA与SAN的主要区别在于:NAS共享的是文件系统,而SAN共享的是快设备;

1》iSCSI网络存储;

    iSCSI是典型的IP-SAN技术,是基于因特网的SAN存储技术,该技术使得我们可以在基于IP协议的网络上传输SCSI命令,在iSCSI环境中,客户端发送SCSI命令给远程的SCSI存储设备,实现数据的存储与备份功能;iSCSI使用TCP的860与3260端口进行通信;iSCSI与SCSI最大的区别在于iSCSI摆脱了存储设备的距离限制,使得任何主机都可以通过局域网或广域网访问我们的存储设备,而对于数据中心而言,这是至关重要的;
相关环境:
  服务器IP地址:192.168.1.106
  客户端IP地址:192.168.1.109

2》部署iSCSI服务:
  LUN(Logical Unit Number):是设备的逻辑单元号,一般为一个数字,我们使用LUN来标识存储设备;
  IQN ( iSCSI Qualified Name):为iSCSI合格名称,一般格式为iqn.yyy-mm.<reversed domain name>:identifier,其中,yyy表示年,mm表示月,reversed domain                name 是域名的反写,identifier为标识名称;如:iSCSI服务器域名为www.example.com,则IQN全称为                                                                                                      iqn.201210.com.example.www:disk1;这种写法不是必须遵守的,但是推荐这种写法;

  部署ISCSI服务器时,需要安装scsi-target-utils软件,为了给其他服务器提供储,服务器上必须有足够的存储设备;我们可以通过命令或者修改配置文件来部署iSCSI服务,如果需要使用命令来配置服务,可以参考tgtadm 命令的man手册;修改服务器的配置文件,默认的服务器配置文件为/etc/tgt/targets.conf,我们需要在配置文件中添加共享设备,为共享设备创建LUN和IQN,最后启动服务进程;
  1>安装相关软件:
    yum install scsi-target-utils                          

         

           2>修改配置文件:

             

             配置文件详解:
      第一个target定义了两个LUN,LUN编号会自动按顺序分配给LUN1,LUN2,LUN0一般会分配给SCSI控制器,默认允许所有人访问该target;/dev/sdb                              与/dev/sdc2是我们准备共享的设备,通过backing-store 指定设备路径,backing-store支持文件或块设备,此外,也可以使用direct-store指定设备路径,                        但direct-store仅支持本地SCSI设备;
                      第二个target定义了一个LUN,LUN编号为手动配置的10,共享设备是/dev/sdd,手动修改设备的厂家信息为Jacob Inc,此外,通过incominguser选项将                         该target设置为仅允许tom账户访问,密码为tompass12;
         第三个target定义了一个LUN,LUN编号为20,共享设备为/dev/sdc3,仅允许tom账户通过192.168.1.109主机访问该target;

    当服务器启动tgtd服务后,我们随时可以通过tgtadm命令来查看iSCSI的详细信息,以下为输出内容:
    service tgtd start 

   [root@chw ~]# tgtadm --lld iscsi --op show --mode target
Target 1: iqn.2017-8.com.chw.www:disk1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 21475 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb
Backing store flags:
LUN: 2
Type: disk
SCSI ID: IET 00010002
SCSI SN: beaf12
Size: 5379 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdc2
Backing store flags:
Account information:
ACL information:
ALL
Target 2: iqn.2017-8.com.chw.www:disk2
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00020000
SCSI SN: beaf20
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 10
Type: disk
SCSI ID: IET 0002000a
SCSI SN: beaf210
Size: 21475 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdd
Backing store flags:
Account information:
tom
ACL information:
ALL
Target 3: iqn.2017-8.com.chw.www:disk3
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00030000
SCSI SN: beaf30
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 20
Type: disk
SCSI ID: IET 00030014
SCSI SN: beaf320
Size: 5379 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdc3
Backing store flags:
Account information:
tom
ACL information:
192.168.1.109

相关防火墙设置:
  iptables -I INPUT -p tcp --dport 3260 -j ACCEPT
  service iptables save

3》客户端访问:
  Linux客户端访问iSCSI服务器需要安装iscsi-initiator-utils软件包;第一步通过iscsiadm命令的discoverydb选项可以发现服务器端的iSCSI的IQN;第二步,通过login选项加载服务器的IQN;之后便可以通过fdisk -cul命令发现计算机中多了三块磁盘;第三步就可以对磁盘进行分区格式化后即可使用该ISCSI磁盘存储设备了;

相关命令:
  iscsiadm --mode discoverydb --type sendtargets --portal 192.168.1.106 --discover
查看服务器的ISCSI IQN信息;

     

   iscsiadm --mode node --targetname iqn.2017-8.com.chw.www:disk1 --portal 192.168.1.106:3260 --login
  用来挂载服务器上的IQN;

      

      

原文地址:https://www.cnblogs.com/xiaocheche/p/7592751.html