iSCSI服务配置全指南(含服务器与客户端)
一、iSCSI简介
1. 概念
互联网小型计算机系统接口(Internet Small Computer System Interface,简称iSCSI)是一种基于TCP/IP的协议,其核心功能是通过IP网络仿真SCSI高性能本地存储总线,实现远程块存储设备的数据传输与管理。iSCSI采用客户端/服务器(C/S)架构,其中提供存储资源的一方称为“iSCSI目标(Target)”,访问存储的一方称为“iSCSI启动器(Initiator)”。
二、iSCSI存储服务器配置(提供iSCSI目标)
1. 准备存储分区
首先为iSCSI服务创建专用存储分区(以/dev/sda5
为例,大小5G):
partprobe /dev/sda # 刷新分区表,使系统识别新分区
[root@zhangyiwei ~]# fdisk /dev/sda # 进入分区工具,新建分区
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):p
磁盘 /dev/sda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0009fd54
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 10487807 4194304 82 Linux swap / Solaris
/dev/sda3 10487808 115345407 52428800 83 Linux
命令(输入 m 获取帮助):n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): e
已选择分区 4
起始 扇区 (115345408-209715199,默认为 115345408):
将使用默认值 115345408
Last 扇区, +扇区 or +size{K,M,G} (115345408-209715199,默认为 209715199):
将使用默认值 209715199
分区 4 已设置为 Extended 类型,大小设为 45 GiB
命令(输入 m 获取帮助):p
磁盘 /dev/sda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0009fd54
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 10487807 4194304 82 Linux swap / Solaris
/dev/sda3 10487808 115345407 52428800 83 Linux
/dev/sda4 115345408 209715199 47184896 5 Extended
命令(输入 m 获取帮助):n
All primary partitions are in use
添加逻辑分区 5
起始 扇区 (115347456-209715199,默认为 115347456):
将使用默认值 115347456
Last 扇区, +扇区 or +size{K,M,G} (115347456-209715199,默认为 209715199):+10G
分区 5 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):P
磁盘 /dev/sda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0009fd54
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 10487807 4194304 82 Linux swap / Solaris
/dev/sda3 10487808 115345407 52428800 83 Linux
/dev/sda4 115345408 209715199 47184896 5 Extended
/dev/sda5 115347456 136318975 10485760 83 Linux
命令(输入 m 获取帮助):W
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。
[root@zhangyiwei ~]# partprobe /dev/sda# 刷新分区表,使系统识别新分区
[root@zhangyiwei ~]# parted /dev/sda #查看分区情况
GNU Parted 3.1
使用 /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit
Unit? [compact]? Mib
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 102400MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system 标志
1 1.00MiB 1025MiB 1024MiB primary xfs 启动
2 1025MiB 5121MiB 4096MiB primary linux-swap(v1)
3 5121MiB 56321MiB 51200MiB primary xfs
4 56321MiB 102400MiB 46079MiB extended
5 56322MiB 66562MiB 10240MiB logical
(parted) quit
2. 安装配置工具
RHEL7中使用targetcli
工具配置iSCSI目标,安装命令:
[root@zhangyiwei ~]# yum -y install targetcli
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 targetcli.noarch.0.2.1.fb46-7.el7 将被 安装
--> 正在处理依赖关系 python-rtslib >= 2.1.fb41,它被软件包 targetcli-2.1.fb46-7.el7.noarch 需要
--> 正在处理依赖关系 python-configshell,它被软件包 targetcli-2.1.fb46-7.el7.noarch 需要
--> 正在检查事务
---> 软件包 python-configshell.noarch.1.1.1.fb23-5.el7 将被 安装
--> 正在处理依赖关系 python-urwid,它被软件包 1:python-configshell-1.1.fb23-5.el7.noarch 需要
--> 正在处理依赖关系 pyparsing,它被软件包 1:python-configshell-1.1.fb23-5.el7.noarch 需要
---> 软件包 python-rtslib.noarch.0.2.1.fb63-13.el7 将被 安装
--> 正在处理依赖关系 python-kmod,它被软件包 python-rtslib-2.1.fb63-13.el7.noarch 需要
--> 正在检查事务
---> 软件包 pyparsing.noarch.0.1.5.6-9.el7 将被 安装
---> 软件包 python-kmod.x86_64.0.0.9-4.el7 将被 安装
---> 软件包 python-urwid.x86_64.0.1.1.1-3.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=====================================================================================================
Package 架构 版本 源 大小
=====================================================================================================
正在安装:
targetcli noarch 2.1.fb46-7.el7 aa 67 k
为依赖而安装:
pyparsing noarch 1.5.6-9.el7 aa 94 k
python-configshell noarch 1:1.1.fb23-5.el7 aa 68 k
python-kmod x86_64 0.9-4.el7 aa 57 k
python-rtslib noarch 2.1.fb63-13.el7 aa 100 k
python-urwid x86_64 1.1.1-3.el7 aa 654 k
事务概要
=====================================================================================================
安装 1 软件包 (+5 依赖软件包)
总下载量:1.0 M
安装大小:4.6 M
Downloading packages:
-----------------------------------------------------------------------------------------------------
总计 24 MB/s | 1.0 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : python-kmod-0.9-4.el7.x86_64 1/6
正在安装 : python-rtslib-2.1.fb63-13.el7.noarch 2/6
正在安装 : pyparsing-1.5.6-9.el7.noarch 3/6
正在安装 : python-urwid-1.1.1-3.el7.x86_64 4/6
正在安装 : 1:python-configshell-1.1.fb23-5.el7.noarch 5/6
正在安装 : targetcli-2.1.fb46-7.el7.noarch 6/6
验证中 : 1:python-configshell-1.1.fb23-5.el7.noarch 1/6
验证中 : python-urwid-1.1.1-3.el7.x86_64 2/6
验证中 : targetcli-2.1.fb46-7.el7.noarch 3/6
验证中 : python-rtslib-2.1.fb63-13.el7.noarch 4/6
验证中 : pyparsing-1.5.6-9.el7.noarch 5/6
验证中 : python-kmod-0.9-4.el7.x86_64 6/6
已安装:
targetcli.noarch 0:2.1.fb46-7.el7
作为依赖被安装:
pyparsing.noarch 0:1.5.6-9.el7 python-configshell.noarch 1:1.1.fb23-5.el7
python-kmod.x86_64 0:0.9-4.el7 python-rtslib.noarch 0:2.1.fb63-13.el7
python-urwid.x86_64 0:1.1.1-3.el7
完毕!
3. 创建后备存储(Backstores)
后备存储是iSCSI目标提供的实际存储资源,支持block
(块设备)、fileio
(文件)、pscsi
(物理SCSI)、ramdisk
(内存盘)等类型,此处以块设备为例:
# 进入targetcli交互模式
[root@zhangyiwei named]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb46
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> 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]
/>
# 切换到block存储目录
/> cd backstores/block
/backstores/block>
# 创建名为block1的后备存储,关联/dev/sda5
/backstores/block> create blok1 /dev/sda5
Created block storage object blok1 using /dev/sda5.
# 验证创建结果(应显示block1及关联的设备信息)
/backstores/block> ls
o- block ....................................................................... [Storage Objects: 1]
o- blok1 ............................................. [/dev/sda5 (0 bytes) write-thru deactivated]
o- alua ........................................................................ [ALUA Groups: 1]
o- default_tg_pt_gp ............................................ [ALUA state: Active/optimized]
# 返回根目录
/backstores/block> cd /
4. 创建iSCSI目标(Target)与IQN
IQN(iSCSI Qualified Name)是iSCSI目标的唯一标识,格式为iqn.YYYY-MM.域名反写:自定义名称
:
# 切换到iscsi配置目录
/> cd iscsi
# 创建目标IQN(示例:iqn.2025-08.com.example:disk1)
iscsi> create iqn.2025-08.com.example:disk1
Created target iqn.2025-08.com.example:disk1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
# 验证创建结果(默认生成TPG 1和监听0.0.0.0:3260的门户)
/iscsi> ls
o- iscsi ............................................................................... [Targets: 1]
o- iqn.2025-08.com.example:disk1 ........................................................ [TPGs: 1]
o- tpg1 .................................................................. [no-gen-acls, no-auth]
o- acls ............................................................................. [ACLs: 0]
o- luns ............................................................................. [LUNs: 0]
o- portals ....................................................................... [Portals: 1]
o- 0.0.0.0:3260 ........................................................................ [OK]
5. 配置访问控制列表(ACL)
ACL用于限制客户端(启动器)的访问权限,需指定客户端的IQN:
# 切换到目标的TPG1的acls目录
/iscsi> cd iqn.2020-03.com.example:disk1/tpg1/acls
# 创建ACL,允许IQN为iqn.2025-08.com.example:desk1的客户端访问
/iscsi/iqn.20...sk1/tpg1/acls> /iscsi/iqn.2025-08.com.example:disk1/tpg1/acls> create iqn.2025-08.com.example:desk1
# 验证配置
/iscsi/iqn.20...sk1/tpg1/acls> cd ..
/iscsi/iqn.20...le:disk1/tpg1> ls
o- tpg1 ................................................................. [no-gen-acls, no-auth]
o- acls ............................................................................ [ACLs: 0]
o- luns ............................................................................ [LUNs: 0]
o- portals ...................................................................... [Portals: 1]
o- 0.0.0.0:3260 ....................................................................... [OK]
6. 创建LUN(逻辑单元号)
LUN将后备存储映射到目标,使客户端识别为块设备:
# 切换到目标的TPG1的luns目录
/iscsi/iqn.20...le:disk1/tpg1> cd luns
# 将后备存储block1映射为LUN 0(同时激活后备存储)
/iscsi/iqn.20...sk1/tpg1/luns> create /backstores/block/blok1
Created LUN 0.
# 验证配置
/iscsi/iqn.20...sk1/tpg1/luns> ls
o- luns .............................................................................. [LUNs: 1]
o- lun0 ......................................... [block/blok1 (/dev/sda5) (default_tg_pt_gp)]
7. 配置门户(Portal)
门户指定目标监听的IP地址和端口(默认端口3260),建议删除默认的0.0.0.0
(所有地址),仅保留服务器实际IP
:
# 切换到目标的TPG1的portals目录
/iscsi/iqn.20...sk1/tpg1/luns> cd ../portals/
# 删除默认门户0.0.0.0:3260
//iscsi/iqn.20.../tpg1/portals> delete ip_address=0.0.0.0 ip_port=3260
Deleted network portal 0.0.0.0:3260
# 创建新门户(监听IP:172.16.30.20,端口:3260)
/iscsi/iqn.20.../tpg1/portals> create ip_address=192.168.100.10 ip_port=3260
Using default IP port 3260
Created network portal 192.168.100.10:3260.
# 验证配置
/iscsi/iqn.20.../tpg1/portals> ls
o- portals ........................................................................ [Portals: 1]
o- 192.168.100.10:3260 .................................................................. [OK]
8. 保存配置并退出
# 返回根目录,预览整体配置
/iscsi/iqn.20.../tpg1/portals> cd /
/> ls
o- / ..................................................................................... [...]
o- backstores .......................................................................... [...]
| o- block .............................................................. [Storage Objects: 1]
| | o- blok1 ...................................... [/dev/sda5 (0 bytes) write-thru activated]
| | o- alua ............................................................... [ALUA Groups: 1]
| | o- default_tg_pt_gp ................................... [ALUA state: Active/optimized]
| o- fileio ............................................................. [Storage Objects: 0]
| o- pscsi .............................................................. [Storage Objects: 0]
| o- ramdisk ............................................................ [Storage Objects: 0]
o- iscsi ........................................................................ [Targets: 1]
| o- iqn.2025-08.com.example:disk1 ................................................. [TPGs: 1]
| o- tpg1 ........................................................... [no-gen-acls, no-auth]
| o- acls ...................................................................... [ACLs: 0]
| o- luns ...................................................................... [LUNs: 1]
| | o- lun0 ................................. [block/blok1 (/dev/sda5) (default_tg_pt_gp)]
| o- portals ................................................................ [Portals: 1]
| o- 192.168.100.10:3260 .......................................................... [OK]
o- loopback ..................................................................... [Targets: 0]
# 确认后备存储、目标、ACL、LUN、门户配置正确
# 退出交互模式(自动保存配置到/etc/target/saveconfig.json)
/> exit
9. 启动服务并设置开机自启
# 重启target服务
[root@zhangyiwei named]# systemctl restart target
# 设置开机自启
[root@zhangyiwei named]# systemctl enable target
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.
#本机在测试环境已经关闭防火墙,如果开启防火墙需要配置防火墙相关
firewall-cmd --add-port=3260/tcp --permanent
firewall-cmd --reload
三、iSCSI客户端配置(启动器)
1. 安装客户端工具
[root@zhangyiwei-2 ~]# yum -y install iscsi-initiator-utils
已加载插件:fastestmirror, langpacks
源 'aa' 在配置文件中未指定名字,使用标识代替
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 iscsi-initiator-utils.x86_64.0.6.2.0.874-10.el7 将被 安装
--> 正在处理依赖关系 iscsi-initiator-utils-iscsiuio >= 6.2.0.874-10.el7,它被软件包 iscsi-initiator-utils-6.2.0.874-10.el7.x86_64 需要
--> 正在检查事务
---> 软件包 iscsi-initiator-utils-iscsiuio.x86_64.0.6.2.0.874-10.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================================================================
Package 架构 版本 源 大小
================================================================================================================================
正在安装:
iscsi-initiator-utils x86_64 6.2.0.874-10.el7 aa 421 k
为依赖而安装:
iscsi-initiator-utils-iscsiuio x86_64 6.2.0.874-10.el7 aa 92 k
事务概要
================================================================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:513 k
安装大小:2.6 M
Downloading packages:
--------------------------------------------------------------------------------------------------------------------------------
总计 68 MB/s | 513 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : iscsi-initiator-utils-6.2.0.874-10.el7.x86_64 1/2
正在安装 : iscsi-initiator-utils-iscsiuio-6.2.0.874-10.el7.x86_64 2/2
验证中 : iscsi-initiator-utils-iscsiuio-6.2.0.874-10.el7.x86_64 1/2
验证中 : iscsi-initiator-utils-6.2.0.874-10.el7.x86_64 2/2
已安装:
iscsi-initiator-utils.x86_64 0:6.2.0.874-10.el7
作为依赖被安装:
iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-10.el7
完毕!
2. 配置客户端IQN
客户端IQN需与服务器ACL中允许的IQN一致:
vim /etc/iscsi/initiatorname.iscsi
# 修改为服务器ACL中配置的客户端IQN
InitiatorName=iqn.20225-08.com.example:desk1
3. 重启服务并设置开机自启
[root@zhangyiwei-2 ~]# systemctl restart iscsid
[root@zhangyiwei-2 ~]# systemctl enable iscsid
Created symlink from /etc/systemd/system/multi-user.target.wants/iscsid.service to /usr/lib/systemd/system/iscsid.service.
4. 发现iSCSI目标
获取服务器上可访问的目标信息:
[root@zhangyiwei-2 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.100.10:3260
192.168.100.10:3260,1 iqn.2025-08.com.example:disk1
# 成功后返回目标IQN及服务器地址,如:192.168.100.10:3260,1 iqn.2025-08.com.example:disk1
5. 登录目标
建立与iSCSI目标的连接:
[root@zhangyiwei-2 ~]# iscsiadm -m node -T iqn.2025-08.com.example:disk1 -p 192.168.100.10:3260 -l
Logging in to [iface: default, target: iqn.2025-08.com.example:disk1, portal: 192.168.100.10,3260] (multiple)
Login to [iface: default, target: iqn.2025-08.com.example:disk1, portal: 192.168.100.10,3260]
# 选项说明:-m node(节点模式)、-T(目标IQN)、-p(服务器地址:端口)、-l(登录)
6. 验证块设备
登录成功后,客户端会新增一块来自服务器的块设备(如/dev/sdb
):
[root@zhangyiwei-2 ~]# fdisk -l # 查看新增设备,确认/dev/sdb存在
磁盘 /dev/sda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0009fd54
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 10487807 4194304 82 Linux swap / Solaris
/dev/sda3 10487808 115345407 52428800 83 Linux
磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 4194304 字节
7. 使用iSCSI块存储
对新增设备进行分区、格式化:
# 分区(以划分500Mib分区为例)
parted /dev/sdb # 进入分区工具,
udevadm settle # 刷新设备信息
# 格式化(xfs格式)
mkfs.xfs /dev/sdb1
[root@zhangyiwei-2 ~]# parted /dev/sdb
GNU Parted 3.1
使用 /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit
Unit? [compact]? Mib
(parted) p
Model: LIO-ORG blok1 (scsi)
Disk /dev/sdb: 10240MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
(parted) mklabel
新的磁盘标签类型? gpt
警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to
continue?
是/Yes/否/No? yes
(parted) p
Model: LIO-ORG blok1 (scsi)
Disk /dev/sdb: 10240MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
(parted) mkpart
分区名称? []?
文件系统类型? [ext2]?
起始点? 10Mib
结束点? 510Mib
警告: The resulting partition is not properly aligned for best performance.
忽略/Ignore/放弃/Cancel? i
(parted) p
Model: LIO-ORG blok1 (scsi)
Disk /dev/sdb: 10240MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 10.0MiB 510MiB 500MiB
(parted) quit
信息: You may need to update /etc/fstab.
[root@zhangyiwei-2 ~]# udevadm settle # 刷新设备信息
# 格式化(xfs格式)
[root@zhangyiwei-2 ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=32000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=128000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
8. 挂载存储
(1)临时挂载
[root@zhangyiwei-2 ~]# mkdir /iscsistorage
[root@zhangyiwei-2 ~]# mount /dev/sdb1 /iscsistorage
[root@zhangyiwei-2 ~]# mount -a
[root@zhangyiwei-2 ~]# df -TH
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda3 xfs 54G 3.9G 50G 8% /
devtmpfs devtmpfs 2.1G 0 2.1G 0% /dev
tmpfs tmpfs 2.1G 5.6M 2.1G 1% /dev/shm
tmpfs tmpfs 2.1G 14M 2.1G 1% /run
tmpfs tmpfs 2.1G 0 2.1G 0% /sys/fs/cgroup
/dev/sda1 xfs 1.1G 171M 893M 17% /boot
tmpfs tmpfs 413M 8.2k 413M 1% /run/user/42
tmpfs tmpfs 413M 29k 413M 1% /run/user/0
/dev/sr0 iso9660 4.6G 4.6G 0 100% /mnt
/dev/sdb1 xfs 521M 27M 495M 6% /iscsistorage #可以看到sdb1已经被挂载
(2)永久挂载
需添加_netdev
参数(确保网络就绪后再挂载,避免系统启动失败):
# 获取设备UUID
[root@zhangyiwei-2 ~]# blkid
/dev/sr0: UUID="2018-11-25-23-54-16-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/sda1: UUID="74269aae-48fe-4073-8c4e-c4c87f4692aa" TYPE="xfs"
/dev/sda2: UUID="533b117f-155a-439c-8239-9d721d6ef1ab" TYPE="swap"
/dev/sda3: UUID="0334c5de-90d6-4e19-82bf-abe877f230e6" TYPE="xfs"
/dev/sdb1: UUID="c41c9e93-9de3-42fc-b9a1-209bd5f3b644" TYPE="xfs" PARTUUID="2a3d02a9-2f80-49d5-b761-e87e7cad0a12"
# 编辑/etc/fstab
[root@zhangyiwei-2 ~]# vim /etc/fstab
# 添加以下行(UUID替换为实际值)
UUID=c41c9e93-9de3-42fc-b9a1-209bd5f3b644 /iscsistorage xfs defaults,_netdev 0 0
# 生效配置
[root@zhangyiwei-2 ~]# mount -a
四、注销iSCSI目标
1. 临时注销(断开连接,保留配置.需要卸载挂载或者终止设备进程)
iscsiadm -m node -T iqn.2020-03.com.example:disk1 -p 192.168.100.10:3260 -u
# -u表示注销(logout)
2. 永久注销(删除配置,需先临时注销)
# 先临时注销
iscsiadm -m node -T iqn.2025-08.com.example:disk1 -p 192.168.100.10:3260 -u
# 再删除节点配置
iscsiadm -m node -T iqn.2025-08.com.example:disk1 -p 192.168.100.10:3260 -o delete
通过以上步骤,可完成iSCSI服务从服务器配置到客户端连接的全流程,实现远程块存储的共享与访问。