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 xfs4 56321MiB 102400MiB 46079MiB extended5 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 kpython-configshell noarch 1:1.1.fb23-5.el7 aa 68 kpython-kmod x86_64 0.9-4.el7 aa 57 kpython-rtslib noarch 2.1.fb63-13.el7 aa 100 kpython-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服務從服務器配置到客戶端連接的全流程,實現遠程塊存儲的共享與訪問。