前言:
iSCSI(Internet Small Computer System Interface)诞生于21世纪初,由IBM、Cisco等企业联合推动,旨在解决传统存储架构的扩展性与成本瓶颈。作为一种基于IP网络的块级存储协议,iSCSI将SCSI命令封装于TCP/IP数据包中,通过标准以太网(端口3260)实现远程存储设备的本地化映射。在数据爆炸性增长的时代背景下,企业面临光纤通道(FC SAN)的高成本壁垒与直连存储(DAS)的扩展性局限。iSCSI以“存储网络平民化” 为核心突破,利用现有IP基础设施构建低成本存储区域网络(IP SAN),支持虚拟机集群、无盘系统、分布式备份等场景,成为中小企业及云环境实现存储集中化、弹性化的关键技术桥梁。
目录
一、概述
iSCSI协议(Internet Small Computer System Interface,iSCSI)是一种新的存储技术,它是将SCSI接口与以太网(Ethernet)技术结合起来工作的,简单的说iSCSI协议是将用户的请求转换成SCSI规则编码,然后再将这些数据封装在IP包中以便在以太网中进行传输的协议。
iSCSI技术是基于IP的存储区域网,又称IP-SAN,它是一种基于因特网及SCSI-3协议的存储技术,由IETF提出,并于2003年2月11日成为正式的标准。
iSCSI协议的功能
-
供硬件设备使用的可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行 SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择。
-
基于TCP/IP协议的,用来建立和管理IP存储设备、主机和客户机之间的相互连接,并创建SAN。
-
使得SAN利用SCSI协议应用在高速数据传输网络成为可能。这种传输是以块级别的方式在各个存储设备上进行的。
iSCSI的结构
由于SCSI协议是一个C/S架构,因此iSCSI协议也是一个C/S结构,其中client是initiator,server端为target。iSCSI协议的主要功能是利用TCP/IP网络,在主机系统(可称为initiator)和目标存储设备(称为target)之间进行大量的数据封装和可靠传输过程。此外,iSCSI协议还将SCSI协议封装在IP网络上,并且运行在TCP上。 ISCSI协议的协议栈图示:
iSCSI协议的工作原理
当iSCSI主机发起数据读写操作后,操作系统会生成一个SCSI指令集,然后该SCSI指令集在iSCSI initiator端被封装成iSCSI消息包,并通过TCP/IP网络传输到存储区域,当存储区域的iSCSI target收到iSCSI消息包时会将其解开,读取其中的SCSI指令,然后再将其SCSI指令传送给SCSI设备执行其指令。当SCSI指令被执行后,返回的数据经过SCSI设备传送给iSCSI target时被封装为iSCSI的响应PDU,然后再通过TCP/IP网络传输给iSCSI initiator端,iSCSI initiator解开其iSCSI PDU包,读取其中的SCSI响应内容,并将其提交给操作系统进行处理,然后操作系统在将其处理后的内容返回给应用程序。
iSCSI的优点
iSCSI最大的优点就是节约成本,利用iSCSI协议构建一个存储网络,除了需要存储设备,交换机、线缆还有以太网接口以外,基本就不需要其他的设备了,只需要在现有的网络上安装iSCSI就可以实现构建一个比较大的存储网络了。
iSCSI基本概念
iSCSI客户端 (iSCSI Initiator)
iSCSI客户端为iSCSI initiator,这是I/O操作的发起者。在RedHat Linux系统中可以通过软件来模拟,需要安装iSCSI设备驱动。如iscsi-initiator-utils.rpm iSCSI initiator具有的特性:
-
既然是I/O操作的发起者,需要通过发现过程请求远端块设备。
-
它可以与target进行持久连接
-
Linux中可以通过软件方式来实现
iSCSI服务器端 (iSCSI Target)
iSCSI服务器端为iSCSI target,这是I/O操作的执行者。在RedHat Enterprise Linux中可以使用scsi-target-utils软件包来模拟实现。 iSCSI target端具有的特性:
-
需要导出一个或多个块设备供启动者(initiator)使用
-
可以通过硬件和软件的方式来实现
iSCSI target设备名称
iSCSI target名称必须是全球唯一的,其格式为:
iqn.<yyyy-mm>.<tld.domain.some.host>[:<identifier>]
# iqn:iSCSI target名称必须是以iqn开头的
# yyyy-mm:表示的是时间
# tld.domain.some.host:这个表示的是一个反过来写的域名
# identifier:这个可以是任意字符串
# 如:iqn.2015-03.com.xsl.www:storge.disk1
逻辑单元号LUN
LUN ID由iSCSI目标设备(Target)分配。iSCSI 启动端(Initiator)设备当前支持在每个目标设备(Target)中导出最多256个LUN。即最大支持16个target。对于LUN,比较通俗的理解就是磁盘分区、LVM卷组、RAID等等。
Target 即“储存设备”(Storage Device),也就是存放数据的硬盘(以磁盘阵列居多)。在使用iSCSI时,会在 iSCSI 储存设备上去建立 LUN(Logical Unit Number)来提供给具备 iSCSI Initiator 功能的主机来存取数据的。LUN 好比是个“逻辑单位磁碟”,物理上通常是由数个实体磁碟( RAID 或 LVM 技术的技术实现)所组成。
iSCSI的发现机制
iSCSI发起端为了和iSCSI目标端建立iSCSI会话,initiator需要知道target的 IP地址,TCP端口号和名字 三个信息。iSCSI发现的目的是为了让iSCSI发起端获取一条到iSCSI目标端的通路。iSCSI有三种发现机制:
静态配置
在iSCSI发起端已经知道iSCSI目标端的IP地址TCP端口号和名字信息时,iSCSI发起端不需要执行发现。iSCSI发起端直接通过IP地址和TCP端口来建立TCP连接,使用iSCSI目标端的名字来建立iSCSI会话。这种发现机制比较适合比较小的iSCSI体系结构
SendTarget发现
在iSCSI发起端知道iSCSI目标端的IP地址和TCP端口的情况下,iSCSI使用IP地址和TCP端口号建立TCP连接后建立发现对话。iSCSI发起端发送SendTarget命令查询网络中的存在的iSCSI信息。这种方法主要用于网关设备,iSCSI发起端被静态配置连接到指定的iSCSI设备。iSCSI发起端和iSCSI网关设备建立对话并发送SendTarget请求给iSCSI网关设备。iSCSI网关设备返回一系列和它相连的ISCSI目标端的信息。iSCSI发起端选择一个目标端来建立对话。
零配置发现
这种机制用于iSCSI发送设备完全不知道iSCSI目标端的信息的情况下。iSCSI发起端利用现有的IP网络协议SLP(Service Location Protocol for Discovery,服务定位协议)。iSCSI目标端使用SLP来注册,iSCSI发起端可以通过查询SLP代理来获得注册的iSCSI目标端的信息。当iSCSI目标端加入到网络中的时候,拓扑结构也随之改变。虽然这种方法增加了实现的复杂性,但它不需要重新配置发起端即可找到新的目标端。
二、 安装
基础配置
首先打开VMware虚拟机为192.168.72.163主机添加两块磁盘
[root@nginx1 ~]# systemctl stop firewalld.service NetworkManager
[root@nginx1 ~]# systemctl disable firewalld.service NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service
[root@nginx1 ~]# setenfoce 0
[root@nginx1 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
配置epel源
[root@nginx1 ~]# yum install -y epel-release
target服务器配置
监听端口:3260/tcp
添加磁盘
####热扫描
[root@nfs-server ~]# cd /sys/class/scsi_host
[root@nfs-server scsi_host]# for i in $(ls);do echo "- - -" > ${i}/scan;done
[root@nfs-server scsi_host]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 199G 0 part
├─openeuler-root 253:0 0 70G 0 lvm /
├─openeuler-swap 253:1 0 3.9G 0 lvm [SWAP]
└─openeuler-home 253:2 0 125.1G 0 lvm /home
sdb 8:16 0 20G 0 disk
sdc 8:32 0 20G 0 disk
sr0 11:0 1 4G 0 rom
####分区
[root@nfs-server ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 119.5G 0 part
├─centos-root 253:0 0 115.6G 0 lvm /
└─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 5G 0 part
sdc 8:32 0 5G 0 disk
└─sdc1 8:33 0 5G 0 part
sr0 11:0 1 1024M 0 rom
target服务安装
[root@nfs-server scsi_host]# yum install -y scsi-target-utils
###配置文件路径
[root@nfs-server ~]# vim /etc/tgt/targets.conf
target服务启停
###启动并开机自启
[root@Ding ~]# systemctl enable --now tgtd
Created symlink from /etc/systemd/system/multi-user.target.wants/tgtd.service to /usr/lib/systemd/system/tgtd.service.
[root@Ding ~]# systemctl stop tgtd
####停止并开启不自启
[root@Ding ~]# systemctl disable --now tgtd
Removed symlink /etc/systemd/system/multi-user.target.wants/tgtd.service.
target存储配置
用于windows连接
###配置sdb
[root@Ding ~]# tgtadm -L iscsi -o new -m target -t 1 -T iqn.20250709.com.jx.www:sdb
[root@Ding ~]# tgtadm -o new -m logicalunit -t 1 -l 1 -b /dev/sdb
[root@Ding ~]# tgtadm -L iscsi -m target -o bind -t 1 -I ALL
[root@Ding ~]# tgt-admin --dump >> /etc/tgt/targets.conf
[root@Ding ~]# vim /etc/tgt/targets.conf
[root@Ding ~]# cat /etc/tgt/targets.conf
# This is a sample config file for tgt-admin.
#
# The "#" symbol disables the processing of a line.
# Set the driver. If not specified, defaults to "iscsi".
default-driver iscsi
# Set iSNS parameters, if needed
#iSNSServerIP 192.168.111.222
#iSNSServerPort 3205
#iSNSAccessControl On
#iSNS On
# Continue if tgtadm exits with non-zero code (equivalent of
# --ignore-errors command line option)
#ignore-errors yes
default-driver iscsi
<target iqn.20250709.com.jx.www:sdb>
backing-store /dev/sdb
</target>
用于Linux连接
###配置sdc
[root@Ding ~]# tgtadm -L iscsi -o new -m target -t 2 -T iqn.20250709.com.jx.www:sdc
[root@Ding ~]# tgtadm -o show -m target
Target 1: iqn.20250709.com.jx.www:sdc
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
Account information:
ACL information:
[root@Ding ~]# tgt-admin -s
Target 1: iqn.20250709.com.jx.www:sdc
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
Account information:
ACL information:
[root@Ding ~]# tgtadm -o new -m logicalunit -t 2 -l 1 -b /dev/sdc
[root@Ding ~]# tgt-admin -s
Target 1: iqn.20250709.com.jx.www:sdc
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 214748 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/sda
Backing store flags:
Account information:
ACL information:
[root@Ding ~]# tgtadm -L iscsi -m target -o bind -t 2 -I ALL
[root@Ding ~]# tgt-admin --dump >> /etc/tgt/targets.conf
[root@Ding ~]# vim /etc/tgt/targets.conf
[root@Ding ~]# cat /etc/tgt/targets.conf
# This is a sample config file for tgt-admin.
#
# The "#" symbol disables the processing of a line.
# Set the driver. If not specified, defaults to "iscsi".
default-driver iscsi
# Set iSNS parameters, if needed
#iSNSServerIP 192.168.111.222
#iSNSServerPort 3205
#iSNSAccessControl On
#iSNS On
# Continue if tgtadm exits with non-zero code (equivalent of
# --ignore-errors command line option)
#ignore-errors yes
default-driver iscsi
<target iqn.20250709.com.jx.www:sdc>
backing-store /dev/sdc
</target>
<target iqn.20250709.com.jx.www:sdb>
backing-store /dev/sdb
</target>
initiator(Linux)客户端配置
[root@Ding ~]# yum install -y epel-release
[root@Ding ~]# yum install -y iscsi-initiator-utils
Linux客户端连接
###下载命令
[root@lnmp-web1 ~]# yum install -y iscsi-initiator-utils
###启动服务
[root@lnmp-web1 ~]# systemctl start iscsid
### 发现
[root@lnmp-web1 ~]# iscsiadm -m discoverydb -t sendtargets -p 192.168.72.163:3260 -D
192.168.72.163:3260,1 iqn.20250709.com.jx.www:sdb
192.168.72.163:3260,1 iqn.20250709.com.jx.www:sdc
### 映射
[root@lnmp-web1 ~]# iscsiadm -m node -T iqn.20250709.com.jx.www:sdc -p 192.168.72.163:3260 -l
Logging in to [iface: default, target: iqn.20250709.com.jx.www:sdc, portal: 192.168.72.163,3260]
Login to [iface: default, target: iqn.20250709.com.jx.www:sdc, portal: 192.168.72.163,3260] successful.
### 查看
[root@lnmp-web1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 199G 0 part
├─openeuler-root 253:0 0 70G 0 lvm /
├─openeuler-swap 253:1 0 3.9G 0 lvm [SWAP]
└─openeuler-home 253:2 0 125.1G 0 lvm /home
sdb 8:16 0 20G 0 disk
sr0 11:0 1 4G 0 rom
### 查看服务端变化
[root@nginx1 ~]# tgt-admin -s
Connection: 0
IP Address: 192.168.115.112
### 分区
[root@nginx1 ~]# fdisk /dev/sdb
### 挂载
[root@nginx1 ~]# mount /dev/sdb1 /mnt
### 自动映射(不建议)
[root@nginx1 ~]# iscsiadm -m node -T iqn.20230106.com.jx.www -p 192.168.115.128:3260 -o update -n node.startup -v automatic
验证
切换到192.168.72.166主机
[root@lnmp-web1 ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.39.1)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
设备不包含可识别的分区表。
Created a new DOS (MBR) disklabel with disk identifier 0xc8311362.
命令(输入 m 获取帮助):n
分区类型
p 主分区 (0个主分区,0个扩展分区,4空闲)
e 扩展分区 (逻辑分区容器)
选择 (默认 p):
将使用默认回应 p。
分区号 (1-4, 默认 1):
第一个扇区 (2048-41943039, 默认 2048):
最后一个扇区,+/-sectors 或 +size{K,M,G,T,P} (2048-41943039, 默认 41943039):
创建了一个新分区 1,类型为“Linux”,大小为 20 GiB。
命令(输入 m 获取帮助):w
分区表已调整。
将调用 ioctl() 来重新读分区表。
正在同步磁盘。
[root@lnmp-web1 ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.47.0 (5-Feb-2023)
创建含有 5242624 个块(每块 4k)和 1310720 个 inode 的文件系统
文件系统 UUID:11a02707-7a57-4cab-8c26-7316775d84be
超级块的备份存储于下列块:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
正在分配组表:完成
正在写入 inode表:完成
创建日志(32768 个块):完成
写入超级块和文件系统账户统计信息:已完成
###挂载
[root@lnmp-web1 ~]# mount /dev/sdb1 /mnt
切换到192.168.72.163主机
###格式化
[root@Ding ~]# fdisk /dev/sdc
欢迎使用 fdisk (util-linux 2.39.1)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):p
Disk /dev/sdc:20 GiB,21474836480 字节,41943040 个扇区
磁盘型号:VMware Virtual S
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xc8311362
设备 启动 起点 末尾 扇区 大小 Id 类型
/dev/sdc1 2048 41943039 41940992 20G 83 Linux
###格式化
[root@Ding ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.39.1)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):p
Disk /dev/sdb:20 GiB,21474836480 字节,41943040 个扇区
磁盘型号:VMware Virtual S
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xc26830d9
设备 启动 起点 末尾 扇区 大小 Id 类型
/dev/sdb1 2048 41938943 41936896 20G 7 HPFS/NTFS/exFAT
命令(输入 m 获取帮助):q
###挂载
[root@Ding ~]# mount /dev/sdb1 /mnt/
[root@Ding ~]# cd /mnt/
[root@Ding mnt]# ls
'System Volume Information'
切换到windows在sdb磁盘上创建dir1目录
切换到192.168.72.163主机
###卸载sdb
[root@Ding ~]# umount /mnt
###挂载sdc
[root@Ding ~]# mount /dev/sdc1 /mnt/
[root@Ding ~]# ls
anaconda-ks.cfg
[root@Ding ~]# cd /mnt/
[root@Ding mnt]# ls
lost+found
###在sdc上创建目录dir1
[root@Ding mnt]# mkdir dir1
[root@Ding mnt]# ls
dir1 lost+found
切换到192.168.72.166主机
[root@lnmp-web1 ~]# cd /mnt/
[root@lnmp-web1 mnt]# ls
dir1 lost+found
[root@lnmp-web1 mnt]# mkdir dir2
[root@lnmp-web1 mnt]# ls
dir1 dir2 lost+found
[root@lnmp-web1 mnt]# dd if=/dev/zero of=./1.txt bs=100M count=1
输入了 1+0 块记录
输出了 1+0 块记录
104857600 字节 (105 MB, 100 MiB) 已复制,0.992584 s,106 MB/s
[root@lnmp-web1 mnt]# df -h
文件系统 大小 已用 可用 已用% 挂载点
/dev/mapper/openeuler-root 69G 2.4G 63G 4% /
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 1.7G 0 1.7G 0% /dev/shm
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
tmpfs 675M 13M 663M 2% /run
tmpfs 1.7G 0 1.7G 0% /tmp
/dev/sda2 974M 174M 733M 20% /boot
/dev/mapper/openeuler-home 123G 40K 117G 1% /home
192.168.72.163:/home/data 123G 56M 117G 1% /usr/share/nginx/html
/dev/sdb1 20G 101M 19G 1% /mnt
注意:切换到192.168.72.163主机上查看数据未同步
[root@Ding mnt]# ls
dir1 lost+found
[root@Ding mnt]# df -h
文件系统 大小 已用 可用 已用% 挂载点
/dev/mapper/openeuler-root 69G 2.3G 63G 4% /
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 1.7G 0 1.7G 0% /dev/shm
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
tmpfs 675M 9.1M 666M 2% /run
tmpfs 1.7G 0 1.7G 0% /tmp
/dev/sda2 974M 174M 733M 20% /boot
/dev/mapper/openeuler-home 123G 56M 117G 1% /home
/dev/sdc1 20G 28K 19G 1% /mnt
###卸载sdc
[root@Ding ~]# umount /mnt/
[root@Ding ~]# df -h
文件系统 大小 已用 可用 已用% 挂载点
/dev/mapper/openeuler-root 69G 2.3G 63G 4% /
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 1.7G 0 1.7G 0% /dev/shm
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
tmpfs 675M 9.1M 666M 2% /run
tmpfs 1.7G 0 1.7G 0% /tmp
/dev/sda2 974M 174M 733M 20% /boot
/dev/mapper/openeuler-home 123G 56M 117G 1% /home
切换到192.168.72.167主机
###下载iscsi
[root@lnmp-web2 ~]# yum install -y iscsi-initiator-utils
###启动服务
[root@lnmp-web2 ~]# systemctl start iscsid
[root@lnmp-web2 ~]# iscsiadm -m discoverydb -t sendtargets -p 192.168.72.163:3260 -D
192.168.72.163:3260,1 iqn.20250709.com.jx.www:sda
192.168.72.163:3260,1 iqn.20250709.com.jx.www:sdb
192.168.72.163:3260,1 iqn.20250709.com.jx.www:sdc
[root@lnmp-web2 ~]# iscsiadm -m node -T iqn.20250709.com.jx.www:sdc -p 192.168.72.163:3260 -l
Logging in to [iface: default, target: iqn.20250709.com.jx.www:sdc, portal: 192.168.72.163,3260]
Login to [iface: default, target: iqn.20250709.com.jx.www:sdc, portal: 192.168.72.163,3260] successful.
[root@lnmp-web2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 199G 0 part
├─openeuler-root 253:0 0 70G 0 lvm /
├─openeuler-swap 253:1 0 3.9G 0 lvm [SWAP]
└─openeuler-home 253:2 0 125.1G 0 lvm /home
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part
###挂载sdb
[root@lnmp-web2 ~]# mount /dev/sdb1 /mnt/
[root@lnmp-web2 ~]# cd /mnt/
[root@lnmp-web2 mnt]# ls
1.txt dir1 dir2 lost+found
###创建目录dir3
[root@lnmp-web2 mnt]# mkdir dir3
切换到192.168.72.166主机上显示数据同步
[root@lnmp-web1 mnt]# ls
1.txt dir1 dir2 lost+found
注意:192.168.72.166卸载掉sdb后再挂载才能显示出192.168.72.167主机创建的目录dir3
[root@lnmp-web1 mnt]# cd
[root@lnmp-web1 ~]# umount /mnt/
[root@lnmp-web1 ~]# mount /dev/sdb1 /mnt/
[root@lnmp-web1 ~]# cd /mnt/
[root@lnmp-web1 mnt]# ls
1.txt dir1 dir2 dir3 lost+found
此时切换到192.168.72.163主机上挂载sdb能查看到192.168.72.167主机同步的数据
[root@Ding ~]# mount /dev/sdc1 /mnt/
[root@Ding ~]# cd /mnt/
[root@Ding mnt]# ls
1.txt dir1 dir2 dir3 lost+found
windows客户端连接
在windows找到iSCSI发起程序
在目标输入192.168.72.163回车
选择连接sda
点击连接登录成功后点击完成退出
在发现中查看到iSCSI服务启动之后的监听端口号3260,完成配置
验证
进入windows计算机管理初始化磁盘2
右键转换成MBR磁盘
新建简单卷并格式化磁盘2
这块磁盘F就可以使用了!
总结:
iSCSI的核心价值在于以IP网络重构存储边界,其技术本质与优势可归纳为
1.架构革新:
块级虚拟化:通过逻辑单元(LUN)将远程存储映射为本地磁盘,支持分区、格式化等原生操作;
组件解耦:由启动器(Initiator)发起请求、目标器(Target)响应执行,依赖以太网交换机实现双向通信。
2.核心优势:
成本革命:复用IP网络设施,避免光纤通道的专用硬件投入;
弹性扩展:支持跨广域网(WAN)连接,突破物理距离限制;
生态兼容:无缝适配Linux/Windows等系统,兼容虚拟化平台(如VMware、Hyper-V)。
3.应用与挑战:
场景适配:虚拟化集群共享存储、远程备份容灾、无盘工作站启动;
性能瓶颈:依赖网络质量,千兆以太网带宽可能制约I/O效率(可通过硬件HBA卡或TOE技术优化);
安全演进:早期依赖CHAP认证/IPSec加密,现代版本强化传输层安全性。
技术演进启示:iSCSI以“协议封装”实现存储资源的民主化访问,其IP-SAN架构平衡了成本、灵活性与兼容性,成为云时代混合存储生态的基石。随着25/100GbE网络普及与RDMA(如iSER)技术融合,iSCSI将持续赋能分布式存储与边缘计算场景