Linux之网络磁盘共享(iscsi)

iscsi网络磁盘

iSCSI(Internet Small Computer System Interface,发音为/ˈаɪskʌzi/),Internet小型计算机系统接口,又称为IP-SAN,是一种基于因特网及SCSI-3协议下的存储技术,由IETF提出,并于2003年2月11日成为正式的标准。与传统的SCSI技术比较起来,iSCSI技术有以下三个革命性的变化:
把原来只用于本机的SCSI协议透过TCP/IP网络发送,使连接距离可作无限的地域延伸;
连接的服务器数量无限(原来的SCSI-3的上限是15);
由于是服务器架构,因此也可以实现在线扩容以至动态部署。

ISCSI技术的核心是在TCP/IP网络上传输SCSI协议,是指用TCP/IP报文、和ISCSI报文封装SCSI报文,使得SCSI命令和数据可以在普通以太网络上进行传输。
iSCSI 协议定义了在 TCP/IP 网络发送、接收 block(数据块)级的存储数据的规则和方 法。发送端将SCSI命令和数据封装到 TCP/IP 包中再通过网络转发,接收端收到 TCP/IP 包 之后,将其还原为SCSI命令和数据并执行,完成之后将返回的SCSI命令和数据再封装到 TCP/IP 包中再传送回发送端。而整个过程在用户看来,使用远端的存储设备就象访问本地的 SCSI设备一样简单。
SCSI设备的主机接口一般默认都是IP接口,可以直接与以太网络交换机和iSCSI交换机连接,形成一个存储区域网络。根据主机端HBA卡、网络交换机的不同,iSCSI设备与主机之间有三种连接方式。

第一种:以太网卡+initiator软件方式。
第二种:硬件TOE网卡+initiator软件方式。
第三种:iSCSI HBA卡连接方式。

配置iSCSI服务端

iSCSI技术在工作形式上分为服务端(target)与客户端(initiator),iSCSI服务端即用于存放硬盘存储资源的服务器
配置iSCSI服务端共享资源,targetcli是用于管理iSCSI服务端存储资源的专用配置命令,它能够提供类似于前面学习过的fdisk命令的交互式配置功能,将iSCSI共享资源的配置内容抽象成了“目录”的形式,只需要把各类配置信息写入到对应“目录”中即可
第一步:安装targetcli安装包
[root@iscis_server ~]# yum install targetcli -y
##登陆服务,查看是否安装完成
[root@localhost ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help’.
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
在这里插入图片描述

第二步:创建被分享的磁盘分区

[root@iscis ~]# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x0020a8d7.

Command (m for help): n #创建分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free) #主分区
   e   extended #扩展分区
Select (default p): p  #此时选择p,所以创建的是主分区
Partition number (1-4, default 1): 1 #选择哪个分区
First sector (2048-20971519, default 2048):  
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G  #设置分区的内存容量
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): p #显示磁盘信息

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x0020a8d7

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     1026047      512000   8e  Linux LVM
/dev/vdb2         1026048     5220351     2097152   83  Linux


Command (m for help): wq #保存并退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
##同步分区表
[root@iscis ~]# partprobe

第三步:配置iSCSI服务端
[root@iscis ~]# systemctl start target
[root@iscis ~]# systemctl enable target
ln -s ‘/usr/lib/systemd/system/target.serv

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值