RHEL7.0 配置 ISCSI 详解

iSCSI远程块存储
简介
本博客涵盖的主题:
        iSCSI概念
        提供iSCSI目标
        访问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限定名称”。每个发起端和目标需要唯一名称进行标识,最好的做法是使用一个在Internet上可能独一无二的名称。

RHEL7.0 配置 ISCSI 详解

RHEL7.0 配置 ISCSI 详解

 2.iSCSI目标配置

安装iSCSI目标软件包:
# yum install -y targetcli
启动服务:
# systemctl enable target; systemctl start target
进入iSCSI目标交互式配置模式:
# targetcli

8Demo
/> 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 create server0.disk1 /dev/iSCSI_vg/disk1_lv
Created block storage object server0.disk1 using /dev/iSCSI_vg/disk1_lv.
/> /iscsi create iqn.2016-09.com.example:server0
Created target iqn.2016-09com.example:server0.
Created TPG 1.

9/> /iscsi/iqn.2016-09.com.example:server0/tpg1/acls create iqn.2016-09.com.example:desktop0
Created Node ACL for iqn.2016-09.com.example:desktop0
/> /iscsi/iqn.2016-09.com.example:server0/tpg1/luns create /backstores/block/server0.disk1
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2016-09.com.example:desktop0
/> /iscsi/iqn.2016-09.com.example:server0/tpg1/portals create 172.25.0.11
Using default IP port 3260
Created network portal 172.25.0.11:3260.
/> exit   

 3.访问iSCSI存储

安装iSCSI发起端软件包:
# yum install -y iscsi-initiator-utils
在/etc/iscsi/initiatorname.iscsi中设置发起端的IQN:
InitiatorName=iqn.2016-09.com.example:desktop0
查找iSCSI服务器所提供的iSCSI目标(目标门户)
# iscsiadm -m discovery -t st -p 172.25.0.11
登录服务器上的一个或多个iscsi目标
# iscsiadm -m node -T iqn.2016-09.com.example:server0 -p
172.25.0.11 -l

此时,可以使用iSCSI磁盘,就好像它是本地连接硬盘驱动器。
可以挂载现有文件系统。如果磁盘未格式化,可以通过fdisk进行分区,例如,通过
文件系统格式化分区或作为LVM物理卷。
在/etc/fstab中永久挂载文件系统
1. 使用blkid确定文件系统UUID并使用UUID挂载,而不是/dev/sd*设备名称。(每次
引导时显示的设备名称都不同,具体取决于iSCSI设备通过网络进行响应的顺序。
如果按设备名称挂载,这会导致使用错误的设备。)
2. 在/etc/fstab中使用_netdev作为挂载选项。(这将确保客户端不会尝试挂载文件系
统,直至启用联网。否则,在引导时系统将出错。)
3. 确保iscsi服务在引导时启动。

中断使用iSCSI目标
确保没有使用目标所提供的任何设备。
确保从/etc/fstab等位置中删除使用目标的所有永久挂载。
登出iSCSI目标,以暂时断开连接。
# iscsiadm -m node -T iqn.2016-09.com.example:rdisks.demo -p 172.25.0.11 -u
删除iSCSI目标的本地记录,以永久断开连接。
# iscsiadm -m node -T iqn.2016-09.com.example:rdisks.demo -p 172.25.0.11 -o delete

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12900.html