IP SAN 的实现

Storage

企业存储往集中式管理必定是未来的方向,这可以很好的规避单机故障而导致数据丢失或出错。虽然到目前为止,iscsi存储应该在什么环境下使用,但是iscsi前途应该是光明的,他为中小企业以低廉的构建成本构建出优秀存储性能的存储提供了可行的解决方案。

在存储的世界中,有这各色各样的名词和术语,常见的SCSI,FC,NAS,DAS,SAN等。

  1. SCSI
    SCSI是小型计算机系统接口(Small Computer System Interface)的简称,SCSI作为输入输出接口,主要用于硬盘、光盘、磁带机、扫描仪等设备
  2. FC
    FC是光纤通道(Fibre Channel)的简称,是一种适合于千兆数据传输的、成熟而安全的解决方案。与传统的SCSI技术相比,FC提供更高的数据传输速率,更远的传输距离,更多的设备连接支持,更稳定的性能,更简易的安装。
  3. NAS
    网络接入存储(Network-Attached Storage), 它通过网络连接存储系统,建立专门的数据存储的私有网络,用户通过TCP/IP协议访问数据,业界常见的共享协议有NFS,CIFS来实现文件级别数据共享。但是NAS也有一定的局限性,它会受到网络带宽和网络拥堵的影响,在一定程度上限制了NAS的网络传输能力
  4. DAS
    直连式存储(Direct-Attached Storage),是指将存储设备通过SCSI接口或光纤通道直接连接到一台计算机上。当服务器在地理上比较分散,很难通过远程进行互连时,DAS是比较好的解决方案。但是这种式存储只能通过与之连接的主机进行访问,不能实现数据与其他主机的共享,同时,DAS会占用服务器操作系统资源,例如CPU资源、IO资源等,并且数据量越大,占用操作系统资源就越严重。
  5. SAN
    存储区域网络(Storage Area Network),SAN由3个部分组成,分别是连接设备(如路由器、光纤交换机和Hub)、接口(如SCSI、FC)、通信协议(如IP和SCSI)。这3个部分再加上存储设备和服务器就构成了一个SAN系统。SAN捉供了一个灵活的、高性能的和高扩展性的存储网络环境,它可以更加有效地传输海量的数据块。由于采用了光纤接口,因此SAN还具有更高的带宽,同时,SAN也使统一管理和集中控制实现简化。

ISCSI

iSCSI,即Internet SCSI,是IETF制订的一项标准,用于将SCSI数据块映射为以太网数据包。从根本上说,它是一种基于IP Storage理论的新型存储技术,该技术将存储行业广泛应用的SCSI接口技术与IP网络技术相结合,可以在IP网络上构建SAN。简单地说,iSCSI就是在IP网络上运行SCSI协议的一种网络存储技术。

iSCSI的优势主要表现为:首先,iSCSI沿用TCP/IP协议,而TCP/IP是在网络方面最通用、最成熟的协议,且IP网络的基础建设非常完善,同时,SCSI技术是被磁盘和磁带等设备广泛采用的存储标准,这两点使iSCSI的建设费用和维护成本非常低廉;其次,iSCSI支持一般的以太网交换机而不是特殊的光纤通道交换机,从而减少了异构网络带来的麻烦;还有,iSCSI是通过IP封包传输存储命令,因此可以在整个Internet上传输数据,没有距离的限制。

在iSCSI技术出现后,通过IP技术搭建的存储网络也应运而生,SAN技术也就出现了两种不同的实现方式,即FC SAN与IP SAN。简单来说,以光纤搭建的存储网络就是FC SAN.以iSCSI技术搭建的存储网络叫做IP SAN。

IP SAN

Linux提供了一整套的ISCSI的解决方法,下面我们来尝试构建一个IP SAN。
iSCSI 的主要功能是在TCP/IP 网络上的主机系统(启动器 initiator)和存储设备(目标器 target)之间进行大量数据的封装和可靠传输过程。

  • Target Server

1.准备磁盘设备
2、安装程序包、启动服务
3、创建target
4、创建lun
5、授权

      
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
      
      
~]# yum install -y scsi-target-utils
~}# systemctl start tgtd
~]# tgtadm --lld iscsi --mode target --op show
~]# tgtadm --lld iscsi --mode target --op new --tid 1 --targetname iqn.2017-05.com.jusene:t1
~]# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2017-05.com.jusene:t1
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
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
Account information:
ACL information:
~]# tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store /dev/sdb
~]# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2017-05.com.jusene:t1
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
SWP: No
Thin-provisioning: 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
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/sdb
Backing store flags:
Account information:
ACL information:
~]# tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address 10.211.55.0/24
~]# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2017-05.com.jusene:t1
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
SWP: No
▽ Thin-provisioning: 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
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/sdb
Backing store flags:
Account information:
ACL information:
10.211.55.0/24

这样一个target server就已经部署好了,接下来我们需要使用initiator来使用target。

  • Initiator

1.安装程序包,配置initiator的名字,并启动服务
2.使用iscsiadm实现target的发现和注册

      
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
      
      
~]# yum install -y iscsi-initiator-utils
~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-05.com.jusene:6ea0c4f895
~]# for i in iscsi iscsid;do systemctl start $i ;done
~]# iscsiadm -m discovery -t st -p 10.211.55.39:3260
10.211.55.39:3260,1 iqn.2017-05.com.jusene:t1
~]# ls /var/lib/iscsi/send_targets/10.211.55.39,3260/
iqn.2017-05.com.jusene:t1,10.211.55.39,3260,1,default/ st_config
~]# iscsiadm -m node -T iqn.2017-05.com.jusene:t1 -p 10.211.55.39:3260 -l
Logging in to [iface: default, target: iqn.2017-05.com.jusene:t1, portal: 10.211.55.39,3260] (multiple)
Login to [iface: default, target: iqn.2017-05.com.jusene:t1, portal: 10.211.55.39,3260] successful.
~]# fdisk /dev/sdb
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

我们可以看到在initiator上看见了在target上设备,虽然initiator可以持久保持这个连接,但是target是通过tgtadm来配置的,它并不持久,我们需要通过写配置文件来实现target server。

先删除initialtor上的相关配置:

      
      
1
2
3
4
5
6
      
      
~]# iscsiadm -m node -T iqn.2017-05.com.jusene:t1 -p 10.211.55.39:3260 -u
Logging out of session [sid: 2, target: iqn.2017-05.com.jusene:t1, portal: 10.211.55.39,3260]
Logout of [sid: 2, target: iqn.2017-05.com.jusene:t1, portal: 10.211.55.39,3260] successful.
~]# iscsiadm -m node -T iqn.2017-05.com.jusene:t1 -p 10.211.55.39:3260 -o delete
~]# ls /var/lib/iscsi/send_targets/10.211.55.39,3260/
st_config

  • Target Server
            
            
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
            
            
    ~]# tgtadm -L iscsi -m logicalunit -o delete -t 1 -l 1
    ~]# tgtadm -L iscsi -m target -o delete -t 1
    ~]# tgtadm -L iscsi -m target -o show
    ~]# cd /etc/tgt/
    ~]# vim targets.conf
    <target iqn.2017-05.com.jusene:t2>
    backing-store /dev/sdb
    initiator-address 10.211.55.0/24
    </target>
    ~]# systemctl restart tgtd
    ~]# tgtadm -L iscsi -m target -o show
    Target 1: iqn.2017-05.com.jusene:t2
    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
    SWP: No
    Thin-provisioning: 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
    SWP: No
    Thin-provisioning: No
    Backing store type: rdwr
    Backing store path: /dev/sdb
    Backing store flags:
    Account information:
    ACL information:
    10.211.55.0/24

上面我们做了基于ip的访问认证,接下来我们做下基于用户的认证:

  • Target Server

            
            
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
            
            
    ~]# vim /etc/tgt/targets.conf
    <target iqn.2017-05.com.jusene:t2>
    backing-store /dev/sdb
    backing-store /dev/sdc
    initiator-address 10.211.55.0/24
    incominguser jusene jusene
    </target>
    ~]# tgtadm -L iscsi -m target -o show
    Target 1: iqn.2017-05.com.jusene:t2
    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
    SWP: No
    Thin-provisioning: 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
    SWP: No
    Thin-provisioning: No
    Backing store type: rdwr
    Backing store path: /dev/sdb
    Backing store flags:
    Account information:
    jusene
    ACL information:
    10.211.55.0/24
  • initatior

            
            
    1
    2
    3
    4
    5
    6
            
            
    ~]# vim /etc/iscsi/iscsi.conf
    node.session.auth.username = jusene
    node.session.auth.password = jusene
    discovery.sendtargets.auth.username = jusene
    discovery.sendtargets.auth.password = jusene

原文:大专栏  IP SAN 的实现


猜你喜欢

转载自www.cnblogs.com/petewell/p/11607289.html
SAN