** 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_iscsi

  

   1.服务的安装和开启

   yum install targetcli -y

iscsi_iscsi_02

  

   systemctl enable target.service 

iscsi_iscsi_03

   2.服务端的配置

    targetcil

iscsi_iscsi_04


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

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


/> /iscsi create .example:strage1     ##创建一个target

Created target .example:strage1.

Created TPG 1.


/> /iscsi/.example:strage1/tpg1/luns create /backstores/block/sever1storage

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


/> /iscsi/.example:strage1/tpg1/acls create .example:sever1storagekey

Created Node ACL for .example:sever1storagekey  ##创建访问控制列表

Created mapped LUN 0


/> /iscsi/.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_05

iscsi_iscsi_06

  

   3.客户端的连接

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

iscsi_iscsi_07

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

iscsi_iscsi_08

  **测试

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

iscsi_iscsi_09

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

iscsi_iscsi_10

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

 

   4.删除服务

   客户端

   iscsiadm -m node -T .example:strage1 -p 172.25.254.174 -u

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

   iscsiadm -m node -T .example:strage1 -p 172.25.254.174 -o delete

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

iscsi_iscsi_11

   

   服务端

   在targetcli服务里执行

   clearconfig confirm=True

iscsi_iscsi_12