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

**********  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设备

iscsi

  

   1.服务的安装和开启

   yum install targetcli -y

iscsi

  

   systemctl enable target.service 

iscsi

   2.服务端的配置

    targetcil

iscsi


/> backstores/block create sever1storage /dev/vg0/iscsi_storage  ##创建一个设备

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


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

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

Created TPG 1.


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

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


/> /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


/> /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

iscsi

iscsi

  

   3.客户端的连接

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

iscsi

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

iscsi

  **测试

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

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

iscsi

   ##_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目标的本地记录,以永久断开连接

iscsi

   

   服务端

   在targetcli服务里执行

   clearconfig confirm=True

iscsi