天天看点

iscsi

***********************************

**********  iscsi   ***************

 ** iSCSI(Internet SCSI)支持从客户端(发起端)通过IP向远程服务器上的SCSI存储设备(目标)发送SCSI命令。iSCSI限定名称用于确定发起端和目标,并采用iqn.yyyy-mm.{reverse domain}:label的格式。默认情况下,网络通信是至iSCSI目标上的端口3260/tcp的明文。

  ** iSCSI发起端:需要访问原始SAN存储的客户端。

  ** iSCSI目标:从iSCSI服务器提供的远程硬盘磁盘,或“目标门户”

  ** iSCSI目标门户:通过网络向发起端提供目标的服务器。

  ** IQN:“iSCSI限定名称”。每个发起端和目标需要唯一名称进行标识,最好的做法是使用一个在i在Internet上可能独一无二的名称。

   ##实验前在服务端建立lvm设备

<a href="https://s3.51cto.com/wyfs02/M01/98/0E/wKiom1k2uWPR3gHrAAA0WbZ-qr4254.png" target="_blank"></a>

   1.服务的安装和开启

   yum install targetcli -y

   systemctl enable target.service 

<a href="https://s4.51cto.com/wyfs02/M00/98/0F/wKioL1k2uh7yYmNoAABS86ilc_c848.png" target="_blank"></a>

   2.服务端的配置

    targetcil

<a href="https://s3.51cto.com/wyfs02/M00/98/0F/wKioL1k2uoiiGhnPAADGPKTjP9c231.png" target="_blank"></a>

/&gt; backstores/block create sever1storage /dev/vg0/iscsi_storage  ##创建一个设备

Created block storage object sever1storage using /dev/vg0/iscsi_storage.

/&gt; /iscsi create iqn.2017-06.com.example:strage1     ##创建一个target

Created target iqn.2017-06.com.example:strage1.

Created TPG 1.

/&gt; /iscsi/iqn.2017-06.com.example:strage1/tpg1/luns create /backstores/block/sever1storage

Created LUN 0.   ##创建逻辑单元号

/&gt; /iscsi/iqn.2017-06.com.example:strage1/tpg1/acls create iqn.2017-06.com.example:sever1storagekey

Created Node ACL for iqn.2017-06.com.example:sever1storagekey  ##创建访问控制列表

Created mapped LUN 0

/&gt; /iscsi/iqn.2017-06.com.example:strage1/tpg1/portals create 172.25.254.174   ##使用174主                                                     机的3260端口

Useing defaults IP port 3260

Creata network portal 172.25.254.174:3260

<a href="https://s1.51cto.com/wyfs02/M02/98/0F/wKioL1k2vFPzHsXrAAEhwBJnx2c209.png" target="_blank"></a>

<a href="https://s3.51cto.com/wyfs02/M01/98/0F/wKioL1k2vmrhXr8GAAFBAqaIeaY735.png" target="_blank"></a>

   3.客户端的连接

   iscsiadm -m discovery -t st -p 172.25.254.174  ##查找iSCSI服务器所提供的iSCSI目标

<a href="https://s1.51cto.com/wyfs02/M01/98/10/wKioL1k2vzLAb7xRAAApNI7dUeE633.png" target="_blank"></a>

   iscsiadm -m node -T iqn.2024-12.com.example:server0 -p 172.25.254.174 -l  ##登录服务器上的iscsi目标  

<a href="https://s2.51cto.com/wyfs02/M01/98/0F/wKiom1k2v9OC0SKTAABoLwkfbAI345.png" target="_blank"></a>

  **测试

  客户端上出现一个新硬盘设备

<a href="https://s1.51cto.com/wyfs02/M01/98/10/wKioL1k2wCmSGi4YAABhsSJykkY474.png" target="_blank"></a>

   vim /etc/fstab    ##设置开机自动挂载

<a href="https://s2.51cto.com/wyfs02/M01/98/0F/wKiom1k2wI2BUSDjAAA-ogtuNsg801.png" target="_blank"></a>

   ##_netdev表示开机挂载之前先启动网络服务

   4.删除服务

   客户端

   iscsiadm -m node -T iqn.2017-06.com.example:strage1 -p 172.25.254.174 -u

   ## 登出iSCSI目标,以暂时断开连接

   iscsiadm -m node -T iqn.2010-09.com.example:strage1 -p 172.25.254.174 -o delete

   ## 删除iSCSI目标的本地记录,以永久断开连接

<a href="https://s2.51cto.com/wyfs02/M02/98/10/wKioL1k2wgOCsiZ3AACqPt7pUKY146.png" target="_blank"></a>

   服务端

   在targetcli服务里执行

   clearconfig confirm=True

<a href="https://s5.51cto.com/wyfs02/M01/98/10/wKioL1k2wlCBaJdvAADPyv-7cg8324.png" target="_blank"></a>

本文转自  夏梨巴人  51CTO博客,原文链接:http://blog.51cto.com/12774035/1933744

继续阅读