在數(shù)字化轉(zhuǎn)型加速的背景下,企業(yè)業(yè)務(wù)對存儲的需求正從 “本地夠用” 向 “高效共享、彈性擴(kuò)展、遠(yuǎn)距離可達(dá)” 升級。傳統(tǒng)存儲方案面臨三大核心痛點(diǎn):
DAS 存儲雖性能強(qiáng)勁,但資源獨(dú)占、無法共享,多服務(wù)器部署時需重復(fù)配置,運(yùn)維成本高企;
NAS 存儲雖支持文件共享,但文件系統(tǒng)封裝 / 解封裝過程帶來額外延遲,難以滿足數(shù)據(jù)庫、虛擬化等高 IOPS 場景需求;
FC SAN 存儲雖實(shí)現(xiàn)塊級共享與遠(yuǎn)距離傳輸,但專用光纖網(wǎng)絡(luò)成本昂貴,部署與維護(hù)門檻高,中小企業(yè)難以負(fù)擔(dān)。
如何在 “低成本 IP 網(wǎng)絡(luò)” 基礎(chǔ)上,實(shí)現(xiàn) “塊級存儲共享 + 遠(yuǎn)距離傳輸 + 低延遲”?iSCSI(Internet SCSI)技術(shù)給出了答案。它將 SCSI 塊指令封裝為 TCP/IP 數(shù)據(jù)包,借助現(xiàn)有以太網(wǎng)實(shí)現(xiàn)存儲資源的跨網(wǎng)共享,既保留了塊存儲的高性能,又降低了 SAN 架構(gòu)的部署成本,成為企業(yè)虛擬化集群、數(shù)據(jù)庫集群、容災(zāi)備份等場景的核心存儲技術(shù)。
本文將從存儲類型對比切入,系統(tǒng)解析 iSCSI 技術(shù)原理、核心術(shù)語,再通過 CentOS 7 服務(wù)端 / 客戶端、Windows 客戶端的完整部署實(shí)踐,提供可直接落地的運(yùn)維指南,幫助技術(shù)人員快速掌握 iSCSI 的配置與故障排查能力。
1、常見的存儲類型
● DAS(Direct-AttachedStorage)直接附加存儲,存儲設(shè)備一般通過scsi/ide總線直接連接到主機(jī)上,常見的如SATA硬盤,SAS硬盤等,直接通過準(zhǔn)線連接到計(jì)算機(jī)主板上面。該方式顯著的優(yōu)點(diǎn)就是傳輸速度快,但傳輸距離受總線長度限制,且只能供本地使用。
● NAS(Network AttachedStorage)網(wǎng)絡(luò)附加存儲,將存儲設(shè)備與服務(wù)器分離,集中管理數(shù)據(jù),從而提升并發(fā)存儲能力、降低維護(hù)成本。典型的應(yīng)用示例有NFS服務(wù)器,SAMBA服務(wù)器,NFS服務(wù)器等文件服務(wù)器,通過向外提供文件系統(tǒng)的方式向外提供存儲
● SAN(Storage Area Network)存儲區(qū)域網(wǎng)絡(luò),采用FC(Fibre Channel)光纖通道或者Ethernet進(jìn)行遠(yuǎn)距離傳輸,區(qū)別于Fiber Channel光纖通道技術(shù),通過FC交換機(jī)連接存儲陣列和服務(wù)器主 機(jī),建立專用于數(shù)據(jù)存儲的區(qū)域網(wǎng)絡(luò)。

1.1三種類型存儲的區(qū)別
DAS與SAN都是塊級別(Block-level)的存儲,而NAS是文件系統(tǒng)(File System level)級的存儲。因?yàn)槲募到y(tǒng)是操作系統(tǒng)對磁盤數(shù)據(jù)的一次封裝。每次對數(shù)據(jù)訪問時提供文件服務(wù)的服務(wù)器都要對數(shù)據(jù)進(jìn)行數(shù)據(jù)封裝,和解封裝,然后再對塊設(shè)備磁盤進(jìn)行讀寫。而DAS是直接對塊設(shè)備進(jìn)行讀寫,因此NAS的存儲速度不如前面兩者。
SAN(Storage Area Network)相當(dāng)于模擬了遠(yuǎn)距離傳輸?shù)腄AS,特點(diǎn)是速度快。支持的并發(fā)服務(wù)主機(jī)數(shù)量多。大家都知道遠(yuǎn)距離傳輸是需要跨越Internet,而廣域網(wǎng)的帶寬是遠(yuǎn)不能和局域網(wǎng)相比的,因此缺點(diǎn)便是網(wǎng)絡(luò)速度瓶頸問題。
2、ISCSI介紹
iSCSI(Internet SmallComputer System Interface)基于Internet的小型計(jì)算機(jī)系統(tǒng)接口,由IBM公司研究開發(fā)的,是一個可以讓硬件設(shè)備在IP協(xié)議的上層運(yùn)行的SCSI指令集存儲技術(shù),可以實(shí)現(xiàn)在IP網(wǎng)絡(luò)上運(yùn)行SCSI協(xié)議,使其能夠在諸如高速千兆以太網(wǎng)上進(jìn)行路由選擇。iSCSI技術(shù)是一種新儲存技術(shù),該技術(shù)是將現(xiàn)有SCSI接口與以太網(wǎng)絡(luò)(Ethernet)技術(shù)結(jié)合,使服務(wù)器可通過IP網(wǎng)絡(luò)進(jìn)行遠(yuǎn)距離SCSI類型的數(shù)
據(jù)存儲設(shè)備由 SCSI 總線連接。iSCSI 的主要功能是在 TCP/IP 網(wǎng)絡(luò)上的主機(jī)系統(tǒng)(啟動器 initiator)和存儲設(shè)備(目標(biāo)器 target)之間進(jìn)行大量數(shù)據(jù)的封裝和可靠傳輸過程。此外,iSCSI 提供了在 IP 網(wǎng)絡(luò)封裝 SCSI 命令,且以TCP/IP協(xié)議傳輸。iSCSI服務(wù)端程序監(jiān)聽端口為明文的TCP/3260。
實(shí)際生產(chǎn)環(huán)境中,一般都是使用集群搭建服務(wù)器,如果兩臺或多臺服務(wù)器都是使用獨(dú)立磁盤,那么磁盤的容量會有相應(yīng)的限制,使用ISCSI 技術(shù),實(shí)現(xiàn)遠(yuǎn)程磁盤的使用,集群的服務(wù)器都掛在同一個遠(yuǎn)程存儲設(shè)備到本地實(shí)現(xiàn)數(shù)據(jù)讀寫,這樣也就減少了一個同步數(shù)據(jù)的任務(wù),大大減輕了服務(wù)器的資源消耗。
3、ISCSI常見術(shù)語

4、提供ISCSI目標(biāo)
在原始的SCSI協(xié)議術(shù)語中,目標(biāo)是指在SCSI總線上唯一標(biāo)識的單個可連接的存儲或輸出設(shè)備。在
iSCSI中,SCSI總線是在IP網(wǎng)絡(luò)中仿真,目標(biāo)可以是網(wǎng)絡(luò)附加存儲機(jī)柜中的專用物理設(shè)備,也可以是網(wǎng)絡(luò)存儲服務(wù)器上iSCSI軟件配置的邏輯設(shè)備。
4.1環(huán)境描述

本章使用磁盤分區(qū)作為存儲設(shè)備,將主機(jī)磁盤/dev/sdb進(jìn)行分區(qū),其中分區(qū)/dev/sdb1大小為10G,未曾格式化,以此來提供存儲空間。
[root@iscsi-server ~]# fdisk /dev/sdbWelcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0x6b62b934.
Command (m for help): nPartition type:
p primary (0 primary, 0 extended, 4 free)e extended
Select (default p):Using default response p Partition number (1-4, default 1):First sector (2048-209715199, default 2048):Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):+10GPartition 1 of type Linux and of size 10 GiB is set
Command (m for help): wThe partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.[root@iscsi-server ~]# lsblk
NAMEMAJ:MINRMSIZEROTYPEMOUNTPOINTsda8:00100G0disk├─sda18:10500M0part/boot└─sda28:2042G0part├─centos-root253:0040G0lvm/└─centos-swap253:102G0lvm[SWAP]sdb8:160100G0disk└─sdb18:17010G0partsr011:014.5G0rom
4.2ISCSI實(shí)踐
在服務(wù)器端可以使用targetcli交互式shell工具,在其中可以創(chuàng)建刪除和配置iSCSI目標(biāo)組件,并且在此命令行工具中支持shell常用的Linux命令:cd、ls、pwd等。可以通過yum安裝targetcli包提供此命令(此命令是紅帽7.2版本才支持的命令,之前使用tgtadm命令管理iSCSI設(shè)備)。
4.2.1安裝targetcli軟件包
1 [root@iscsi-server ~]# yum -y install targetcli
4.2.2targetcli交互模式
執(zhí)行targetcli命令,不帶任何選項(xiàng),進(jìn)入交互模式,targetcli處于初始空白配置。
1[root@iscsi-server ~]# targetcli
2Warning: Could not load preferences file /root/.targetcli/prefs.bin.
3targetcli shell version 2.1.53
4Copyright 2011-2013 by Datera, Inc and others.
5For help on commands, type 'help'. 6
7 /> ls
8 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]
4.2.3創(chuàng)建后備存儲
后備存儲一共分為4種,如下:

本次使用block類型的后備存儲,將之前準(zhǔn)備的大小為10GB的磁盤分區(qū)/dev/sdb1關(guān)聯(lián)到block中,且后備存儲名稱為block1
1/> cd backstores/
2/backstores> ls
3o- backstores
..................................................................... [...]
4o- block .........................................................
[Storage Objects: 0]
5o- fileio ........................................................
[Storage Objects: 0]
6o- pscsi .........................................................
[Storage Objects: 0]
7o- ramdisk .......................................................
[Storage Objects: 0]
8/backstores> cd block
9/backstores/block> ls
10o- block ...........................................................
[Storage Objects: 0]
11/backstores/block> create block1 /dev/sdb1
12Created block storage object block1 using /dev/sdb1.
13/backstores/block> cd ../
14/backstores>
4.2.4為目標(biāo)創(chuàng)建IQN
創(chuàng)建IQN,IQN名稱為iqn.2021-10.com.example:disk1
1/> cd iscsi
2/iscsi> create iqn.2021-10.com.example:disk1
3Created target iqn.2021-10.com.example:disk1.
4Created TPG 1.
5Global pref auto_add_default_portal=true
6Created default portal listening on all IPs (0.0.0.0), port 3260.
7/iscsi> ls
8o- iscsi ...................................................................
[Targets: 1]
9o- iqn.2021-10.com.example:disk1
............................................ [TPGs: 1]
10o- tpg1 ...................................................... [no-gen-
acls, no-auth]
11o- acls
................................................................. [ACLs: 0]
12o- luns
................................................................. [LUNs: 0]
13o- portals ...........................................................
[Portals: 1]
14o- 0.0.0.0:3260
.[OK]
15? /iscsi>
16
4.2.5創(chuàng)建ACL
iSCSI協(xié)議是通過客戶端名稱進(jìn)行驗(yàn)證的,也就是說,用戶在訪問存儲共享資源時不需要輸入密碼,只要iSCSI客戶端的名稱與服務(wù)端中設(shè)置的訪問控制列表中某一名稱條目一致即可,因此需要在iSCSI服務(wù)端的配置文件中寫入一串能夠驗(yàn)證用戶信息的名稱。acls參數(shù)目錄用于存放能夠訪問iSCSI服務(wù)端共享存儲資源的客戶端名稱。
在TPG中,創(chuàng)建ACL以控制客戶端節(jié)點(diǎn)的訪問,ACL名稱為iqn.2021-10.com.example:client
1/iscsi> cd iqn.2021-10.com.example:disk1/
2/iscsi/iqn.20...example:disk1> ls
3o- iqn.2021-10.com.example:disk1
.............................................. [TPGs: 1]
4o- tpg1 ........................................................ [no-gen-
acls, no-auth]
5o- acls
.[ACLs:
0]
6o- luns
.[LUNs:
0]
7o- portals .............................................................
[Portals: 1]
8o- 0.0.0.0:3260
.[OK]
9/iscsi/iqn.20...example:disk1> cd tpg1/acls
10/iscsi/iqn.20...sk1/tpg1/acls> create iqn.2021-10.com.example:client
11Created Node ACL for iqn.2021-10.com.example:client
12/iscsi/iqn.20...sk1/tpg1/acls> ls
13o- acls
....................................................................... [ACLs: 1]
14o- iqn.2021-10.com.example:client ....................................
[Mapped LUNs: 0]
15/iscsi/iqn.20sk1/tpg1/acls>
此ACL將目標(biāo)配置為僅接受來自以iqn.2021-10.com.example:client作為啟動器名稱的客戶端連接
4.2.6創(chuàng)建LUN
在TPG中,為每個后備存儲創(chuàng)建一個LUN,此步驟還將激活每個后備存儲, 由于TPG中存在ACL,因此ACL將自動分配給每個創(chuàng)建的LUN,此處為block1后備存儲創(chuàng)建LUN
1/iscsi/iqn.20...sk1/tpg1/acls> cd ..
2/iscsi/iqn.20...le:disk1/tpg1> cd luns
3/iscsi/iqn.20...sk1/tpg1/luns> create /backstores/block/block1
4Created LUN 0.
5Created LUN 0->0 mapping in node ACL iqn.2021-10.com.example:client
6/iscsi/iqn.20...sk1/tpg1/luns> ls
7o- luns
.......................................................................? [LUNs: 1]
8o- lun0 ................................. [block/block1 (/dev/sdb1) (default_tg_pt_gp)]
9/iscsi/iqn.20...sk1/tpg1/luns>
創(chuàng)建一個LUN分配給目標(biāo),當(dāng)啟動器連接到該目標(biāo)時,將連接上一個新的SCSI設(shè)備。
4.2.7創(chuàng)建門戶
在TPG中,創(chuàng)建一個門戶配置偵聽IP地址和端口,偵聽的IP地址為服務(wù)器上本地網(wǎng)絡(luò)接口的IP地址,端口為標(biāo)準(zhǔn)的ISCSi端口3260,由于在“為目標(biāo)創(chuàng)建IQN”時進(jìn)行了默認(rèn)的門戶創(chuàng)建,所以建議先刪除默認(rèn)門戶配置。
1/iscsi/iqn.20...sk1/tpg1/luns> cd ..
2/iscsi/iqn.20...le:disk1/tpg1> cd portals/
3/iscsi/iqn.20.../tpg1/portals> ls
4o- portals .................................................................
[Portals: 1]
5o- 0.0.0.0:3260
.[OK]
6/iscsi/iqn.20.../tpg1/portals> delete ip_address=0.0.0.0 ip_port=3260
7Deleted network portal 0.0.0.0:3260
8/iscsi/iqn.20.../tpg1/portals> create ip_address=192.168.26.201 ip_port=3260
9Using default IP port 3260
10Created network portal 192.168 26.201:3260.
11/iscsi/iqn.20.../tpg1/portals> ls
12o- portals .................................................................
[Portals: 1]
13o- 192.168.26.201:3260
.[OK]
14? /iscsi/iqn.20/tpg1/portals>
4.2.8整體預(yù)覽targetcli配置

退出targetcli后, targetcli的所有配置將自動保存,生成的持久配置文件以javascript對象表示法
(JSON)格式來存儲,存儲文件位于/etc/target/saveconfig.json。
4.2.9控制服務(wù)
1[root@iscsi-server ~]# systemctl start target
2[root@iscsi-server ~]# systemctl enable target
5、客戶端訪問
在CentOS 7系統(tǒng)中,已經(jīng)默認(rèn)安裝了iSCSI客戶端服務(wù)程序initiator。如果您的系統(tǒng)沒有安裝的話,可以使用Yum軟件倉庫手動安裝。
1 [root@client ~]# yum -y install iscsi-initiator-utils
修改/etc/iscsi/initiatorname.iscsi配置文件,啟動服務(wù)
iSCSI協(xié)議是通過客戶端的名稱來進(jìn)行驗(yàn)證,而該名稱也是iSCSI客戶端的唯一標(biāo)識,而且必須與服務(wù)端配置文件中訪問控制列表中的信息一致,否則客戶端在嘗試訪問存儲共享設(shè)備時,系統(tǒng)會彈出驗(yàn)證失敗的保存信息。
1[root@client ~]# vim /etc/iscsi/initiatorname.iscsi
2InitiatorName=iqn.2021-10.com.example:client
3[root@client ~]# systemctl start iscsi
4[root@client ~]# systemctl enable iscsi
5.1發(fā)現(xiàn)目標(biāo)
在ISCSI客戶端連上目標(biāo)之前,必須先發(fā)現(xiàn)目標(biāo),發(fā)現(xiàn)過程將目標(biāo)節(jié)點(diǎn)信息和設(shè)置存儲
在/var/lib/iscsi/nodes目錄中,并且使用/etc/iscsi/iscsid.conf配置文件中的默認(rèn)值,,使用到的命令如下:
iscsiadm是一個模式化的命令,是客戶端的命令
-m {discovery|node|session|iface}
discovery:發(fā)現(xiàn)某個server是否有target輸出及有哪些輸出 node:自己作為節(jié)點(diǎn)與server端建立連接
session:查看會話 iface:進(jìn)行接口管理的
-d:debug_lebel? 等級為0—8越高輸出的debug信息越詳細(xì),可省略
-I:指定使用哪個網(wǎng)絡(luò)接口,如果只有一塊網(wǎng)卡則不用指定
-t:sendtarget,slp,iSNS三種形式,一般用的是sendtarget簡寫為st
-p:IP:port IP為server的IP,port可以省略,默認(rèn)為3260
發(fā)現(xiàn)輸出target后與登錄target有關(guān)的
-U 登出
-R 重新登入
-l 登入
-T 指定targetname
-p 指定server的IP/port
-s 顯示session的統(tǒng)計(jì)數(shù)據(jù)
?發(fā)現(xiàn)目標(biāo)
1[root@client ~]# iscsiadm -m discovery -t st -p 192.168.26.201:3260
2192.168.26.201:3260,1 iqn.2021-10.com.example:disk1
發(fā)現(xiàn)目標(biāo)后,使用iscsiadm命令可以獲得有關(guān)目標(biāo)的信息,同時使用選項(xiàng)"-P N" 可以查看不同詳細(xì)級別的信息,其中N為數(shù)字,使用iscsiadm獲得有關(guān)目標(biāo)信息的具體命令及描述如下:
iscsiadm -m discovery [-P 0 | 1] : 顯示有關(guān)已發(fā)現(xiàn)目標(biāo)的信息
iscsiadm -m node [-P 0 | 1 ] : 顯示有關(guān)已知目標(biāo)的信息
iscsiadm -m session [-P 0 | 1| 2| 3] :顯示有關(guān)活動會話的信息
1[root@client ~]# iscsiadm -m discovery -P 1
2SENDTARGETS:
3DiscoveryAddress: 192.168.26.201,3260
4Target: iqn.2021-10.com.example:disk1
5Portal: 192.168.26.201:3260,1
6Iface Name: default
7iSNS:
8No targets found.
9STATIC:
10No targets found.
11FIRMWARE:
12No targets found.
5.2登錄目標(biāo)
語法格式如下:
iscsiadm -m node -T 發(fā)現(xiàn)的目標(biāo)IQN [ -p target_server[:port]] -l
1[root@client ~]# iscsiadm -m node -T iqn.2021-10.com.example:disk1 -p 192.168.26.201:3260 -l
2Logging in to [iface: default, target: iqn.2021-10.com.example:disk1, portal: 192.168.26.201,3260] (multiple)
3Login to [iface: default, target: iqn.2021-10.com.example:disk1, portal: 192.168.26.201,3260] successful.
登錄成功后,使用命令fdisk -l 查看磁盤情況,會發(fā)現(xiàn)客戶端多了一個塊存儲設(shè)備
[root@client ~]# fdisk -l 2
3 Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
4Units = sectors of 1 * 512 = 512 bytes
5Sector size (logical/physical): 512 bytes / 512 bytes
6I/O size (minimum/optimal): 512 bytes / 512 bytes
7Disk label type: dos
8Disk identifier: 0x000ac425 9
10DeviceBootStartEndBlocksIdSystem
11/dev/sda1*2048102604751200083Linux
12/dev/sda2102604889122815440483848eLinux LVM
13
14Disk /dev/mapper/centos-root: 42.9 GB, 42949672960 bytes, 83886080 sectors
15Units = sectors of 1 * 512 = 512 bytes
16Sector size (logical/physical): 512 bytes / 512 bytes
17I/O size (minimum/optimal): 512 bytes / 512 bytes
18
19
20Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
21Units = sectors of 1 * 512 = 512 bytes
22Sector size (logical/physical): 512 bytes / 512 bytes
23I/O size (minimum/optimal): 512 bytes / 512 bytes
24
25
26 Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
27Units = sectors of 1 * 512 = 512 bytes
28Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
5.3使用ISCSI塊存儲
在ISCSI客戶端上對/dev/sdb設(shè)備進(jìn)行分區(qū),并格式化,規(guī)劃劃分分區(qū)大小為3G,格式化文件系統(tǒng)為xfs
1
[root@client ~]# fdisk /dev/sdb2Welcome to fdisk (util-linux 2.23.2).34Changes will remain in memory only, until you decide to write them.5Be careful before using the write command. 67Device does not contain a recognized partition table8Building a new DOS disklabel with disk identifier 0x253cf37c. 910Command (m for help): n11Partition type:12pprimary (0 primary, 0 extended, 4 free)13eextended14Select (default p):15Using default response p16Partition number (1-4, default 1):17First sector (8192-20971519, default 8192):18Using default value 819219Last sector, +sectors or +size{K,M,G} (8192-20971519, default 20971519): +3G20Partition 1 of type Linux and of size 3 GiB is set 2122Command (m for help): w23The partition table has been altered! 2425 Calling ioctl() to re-read partition table.26 Syncing disks.27 [root@client ~]# mkfs.xfs /dev/sdb128 meta-data=/dev/sdb1isize=512agcount=4, agsize=196608 blks29=sectsz=512attr=2, projid32bit=130=crc=1finobt=0, sparse=031? data=bsize=4096blocks=786432, imaxpct=2532=sunit=0swidth=0 blks33? naming=version 2bsize=4096ascii-ci=0 ftype=134? log=internal logbsize=4096blocks=2560, version=235=sectsz=512sunit=0 blks, lazy-count=136 realtime =noneextsz=4096blocks=0, rtextents=0
?創(chuàng)建掛載目錄,掛載
1
2
3 [root@client ~]# mkdir /iscsistorage [root@client ~]# mount /dev/sdb1 /iscsistorage/
[root@client ~]# df -Th
4 Filesystem Type Size Used Avail Use% Mounted on
5 devtmpfs devtmpfs 979M 0 979M 0% /dev
6 tmpfs tmpfs 991M 0 991M 0% /dev/shm
7 tmpfs tmpfs 991M 9.5M 981M 1% /run
8 tmpfs tmpfs 991M 0 991M 0% /sys/fs/cgroup
9 /dev/mapper/centos-root xfs 40G 1.5G 39G 4% /
10 /dev/sda1 xfs 497M 130M 367M 27% /boot
11 tmpfs tmpfs 199M 0 199M 0% /run/user/0
12 /dev/sdb1 xfs 3.0G 33M 3.0G 2% /iscsistorage
?編輯/etc/fstab文件,實(shí)現(xiàn)掛載開機(jī)自動生效
&使用blkid確定文件系統(tǒng)UUID并使用UUID掛載,而不是/dev/sd*設(shè)備名稱。(每次引導(dǎo)時顯示的設(shè)備名稱都不同,具體取決于iSCSI設(shè)備通過網(wǎng)絡(luò)進(jìn)行響應(yīng)的順序。如果按設(shè)備名稱掛載,這會導(dǎo)致使用錯誤的設(shè)備。)
&在/etc/fstab中使用_netdev作為掛載選項(xiàng)。(這將確保客戶端不會嘗試掛載文件系統(tǒng),直至啟用聯(lián)網(wǎng)。否則,在引導(dǎo)時系統(tǒng)將出錯。)
1[root@client ~]# blkid /dev/sdb1
2/dev/sdb1: UUID="d04ec76a-87c8-4812-a34d-3bd534183d9e" TYPE="xfs"
3[root@client ~]# vim /etc/fstab
4UUID="d04ec76a-87c8-4812-a34d-3bd534183d9e" /iscsistorage xfs defaults,_netdev 0 0
5.4停止使用目標(biāo)
要停止使用某個目標(biāo),可以使用命令“iscsiadm”臨時注銷目標(biāo)。臨時注銷目標(biāo)后,節(jié)點(diǎn)記錄依然存在,用于在系統(tǒng)重新啟動或iscsi服務(wù)重新啟動后自動登錄到目標(biāo)。如果未指定門戶,則將臨時注銷所有相關(guān)門戶的目標(biāo)。
1 iscsiadm -m node -T 發(fā)現(xiàn)的目標(biāo)IQN [ -p target_server[:port]] -u
1[root@client ~]# umount /dev/sdb1
2[root@client ~]# iscsiadm -m node -T iqn.2021-10.com.example:disk1 -p 192.168.26.201:3260 -u
3Logging out of session [sid: 1, target: iqn.2021-10.com.example:disk1, portal: 192.168.26.201,3260]
4Logout of [sid: 1, target: iqn.2021-10.com.example:disk1, portal: 192.168.26.201,3260] successful.
永久注銷目標(biāo)要求刪除節(jié)點(diǎn)記錄,以便在不執(zhí)行其他發(fā)現(xiàn)的情況下,不會再次進(jìn)行手動或自動登錄。如果不指定門戶,將刪除所有相關(guān)門戶的目標(biāo)節(jié)點(diǎn)記錄。
1 iscsiadm -m node -T 發(fā)現(xiàn)的目標(biāo)IQN [ -p target_server[:port]] -o delete
iSCSI客戶端永久注銷iSCSI目標(biāo)前,一定要先執(zhí)行臨時注銷iSCSI目標(biāo)操作
1[root@client ~]# iscsiadm -m node -T iqn.2021-10.com.example:disk1 -p 192.168.26.201:3260 -o delete
2[root@client ~]# iscsiadm -m discovery -P 1
3SENDTARGETS:
4DiscoveryAddress: 192.168.26.201,3260
5iSNS:
6No targets found.
7STATIC:
8No targets found.
9FIRMWARE:
10No targets found.
11[root@client ~]# ls /var/lib/iscsi/nodes/
12[root@client ~]#
6、配置Windows客戶端連接iSCSI設(shè)備
第一步:運(yùn)行iSCSI發(fā)起程序。
控制面板–>系統(tǒng)和安全–>管理工具–>iSCSI發(fā)起程序。





7. 運(yùn)維注意事項(xiàng)
網(wǎng)絡(luò)可靠性:iSCSI 依賴 TCP/IP 網(wǎng)絡(luò),生產(chǎn)環(huán)境需配置雙網(wǎng)卡綁定(Bonding)、冗余交換機(jī),避免單點(diǎn)故障;
防火墻配置:服務(wù)端需開放 TCP 3260 端口,客戶端無需額外端口開放(動態(tài)端口通信);
數(shù)據(jù)備份:iSCSI 提供的是塊存儲服務(wù),需在客戶端或應(yīng)用層配置數(shù)據(jù)備份策略(如定時快照、異地備份);
性能優(yōu)化:
服務(wù)端 / 客戶端使用萬兆以太網(wǎng),減少帶寬瓶頸;
客戶端掛載時啟用noatime選項(xiàng)(減少文件訪問時間更新,降低 I/O 開銷);
故障排查:
客戶端無法發(fā)現(xiàn) Target:檢查網(wǎng)絡(luò)連通性(ping)、服務(wù)端 target 服務(wù)狀態(tài)、防火墻規(guī)則;
登錄失?。捍_認(rèn)客戶端 IQN 與服務(wù)端 ACL 一致、服務(wù)端門戶配置正確;
掛載失敗:檢查/etc/fstab中 UUID 是否正確、_netdev選項(xiàng)是否添加。