iscsi实现设备共享

一:简介
iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的、可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择。iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料。

 iSCSI是一种基于TCP/IP 的协议,用来建立和管理IP存储设备、主机和客户机等之间的相互连接,并创建存储区域网络(SAN)。SAN 使得SCSI 协议应用于高速数据传输网络成为可能,这种传输以数据块级别(block-level)在多个数据存储网络间进行。SCSI 结构基于C/S模式,其通常应用环境是:设备互相靠近,并且这些设备由SCSI 总线连接。

 iSCSI 的主要功能是在TCP/IP 网络上的主机系统(启动器 initiator)和存储设备(目标器 target)之间进行大量数据的封装和可靠传输过程。

二:实验环境
服务器:
镜像7.0
ip 172.25.254.120
hostname iscsi-server
客户端:
镜像7.0
ip 172.25.254.220
关闭火墙和selinux
三:实验步骤
<1>:化出实验所需要的分区

[root@iscsi-server ~]# 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 0x297fa942.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 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: 0x297fa942

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     4196351     2097152   83  Linux

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@iscsi-server ~]# partprobe 
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@iscsi-client ~]# cat /proc/partitions 
major minor  #blocks  name

 253        0   10485760 vda
 253        1   10484142 vda1
 253       16   10485760 vdb
 253       17    2097152 vdb1
  11        0    3948544 sr0
   8       16    1048576 sdb
[root@iscsi-server ~]# 

服务端安装服务:
[root@iscsi-server ~]# yum install -y targetcli ##安装客户端软件
[root@iscsi-server ~]# systemctl start target ##开启服务

[root@iscsi-server ~]# targetcli   ##使用targetcli工具创建一个块设备

/> ls
o- / ............................................................................... [...]
  o- backstores .................................................................... [...]
  | o- block ........................................................ [Storage Objects: 0]
  | o- fileio ....................................................... [Storage Objects: 0]
  | o- pscsi ........................................................ [Storage Objects: 0]
  | o- ramdisk ...................................................... [Storage Objects: 0]
  o- iscsi .................................................................. [Targets: 0]
  o- loopback ............................................................... [Targets: 0]
/> /backstores/block 
/> /backstores/block create zpy:sto /dev/vdb1   ##创建一个backstores块设备名为zpy:sto
Created block storage object zpy:sto using /dev/vdb1.
/> /iscsi create iqn.2017-08.com.example:sto
Created target iqn.2017-08.com.example:sto.
Created TPG 1.
/> /iscsi/iqn.2017-08.com.example:sto/tpg1/luns create /backstores/block/zpy:sto   ##将/backstores/block/zpy:sto加到快设备中
Created LUN 0.
/iscsi/iqn.2017-08.com.example:sto/tpg1/acls create iqn.2017-08.com.example:stokey    ##新建加密
/> /iscsi/iqn.2017-08.com.example:sto/tpg1/portals create 172.25.254.220   ##开端口为本机
Using default IP port 3260
Created network portal 172.25.254.220:3260.

客户端:

root@iscsi-clicent ~]# yum install -y iscsi-initiator-utils  ##安装客户端
[root@iscsi-clicent ~]# vim /etc/iscsi/initiatorname.iscsi 
##将钥匙写入文件
InitiatorName=iqn.2017-08.com.example:stokey
[root@iscsi-clicent ~]# iscsiadm -m discovery -t st -p 172.25.254.220  ##查看是否可以连接到
172.25.254.220:3260,1 iqn.2017-08.com.example:sto

[root@iscsi-clicent ~]# iscsiadm -m node -T iqn.2017-08.com.example:sto -p 172.25.254.220 -l ##连接块设备

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值