iSCSI存储

在 CentOS 7 中,iSCSI(互联网小型计算机系统接口)是一种通过 TCP/IP 网络将远程存储设备(如硬盘、RAID 阵列)模拟为本地磁盘的技术,可实现存储资源的集中管理和共享,适用于服务器集群、虚拟机存储等场景

核心角色

iSCSI 架构包含两个核心角色:

  • iSCSI Target(目标端):存储服务端,提供可共享的存储资源(如块设备、文件),等待客户端连接
  • iSCSI Initiator(发起端):客户端,通过网络连接 Target,将远程存储识别为本地磁盘并使用

CentOS 7 中 iSCSI 的配置要点

1. iSCSI Target(服务端)配置
  • 工具:主要通过targetcli命令行工具管理(需安装targetcli包)
  • 核心步骤:
    • 定义后端存储:指定提供共享的存储资源(如本地块设备/dev/sdb、文件/var/iscsi/store.img
    • 创建 Target IQN:Target 的唯一标识,格式为iqn.yyyy-mm.域名反写:自定义标识(如iqn.2025-08.com.example:target01
    • 配置 LUN:将后端存储关联到 Target,生成逻辑单元号(LUN),供客户端识别
    • 设置 ACL:通过允许特定 Initiator 的 IQN 访问,限制 Target 的访问权限
    • 绑定网络端口:默认使用 TCP 3260 端口,需配置监听的 IP
  • 服务管理:通过target.service启动 / 停止,设置systemctl enable target开机自启
2. iSCSI Initiator(客户端)配置
  • 工具:通过iscsi-initiator-utils包提供的工具(如iscsiadm)管理
  • 核心步骤:
    • 配置 Initiator IQN:在/etc/iscsi/initiatorname.iscsi中定义(如InitiatorName=iqn.2025-08.com.example:initiator01
    • 发现 Target:通过iscsiadm -m discovery -t st -p TargetIP发现网络中的 Target
    • 登录 Target:通过iscsiadm -m node -T TargetIQN -p TargetIP --login建立连接
    • 使用存储:登录后,远程存储会被识别为本地块设备(如/dev/sdc),可格式化(如mkfs.xfs)并挂载使用
  • 服务管理:通过iscsid.service启动服务,设置systemctl enable iscsid开机自启;如需开机自动登录 Target,可配置iscsiadm -m node -T TargetIQN -p TargetIP --op update -n node.startup -v automatic

注意事项

  • 防火墙:需开放 TCP 3260 端口(如firewall-cmd --add-port=3260/tcp --permanent
  • 安全:可通过 CHAP 认证增强安全性(在 Target 和 Initiator 中配置用户名 / 密码)
  • 持久化:确保 Target 和 Initiator 的配置在重启后仍生效(如 Target 的targetcli配置自动保存,Initiator 的自动登录设置)

总之,CentOS 7 通过targetcliiscsi-initiator-utils工具链,可便捷实现 iSCSI 存储的部署,满足远程存储共享需求

配置iscsi存储服务器–(提供iscsi目标)

第一步先分区:

[root@syf2 ~]# fdisk /dev/sda 
Welcome 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.


Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000cfdb0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   115361791    56631296   8e  Linux LVM
/dev/sda3       115361792   123750399     4194304   83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): 
Using default response e
Selected partition 4
First sector (123750400-209715199, default 123750400): 
Using default value 123750400
Last sector, +sectors or +size{K,M,G} (123750400-209715199, default 209715199): +10G
Partition 4 of type Extended and of size 10 GiB is set

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000cfdb0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   115361791    56631296   8e  Linux LVM
/dev/sda3       115361792   123750399     4194304   83  Linux
/dev/sda4       123750400   144721919    10485760    5  Extended

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
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)
Syncing disks.

实际大小

[root@syf2 ~]# parted /dev/sda
GNU Parted 3.1
Using /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  Flags
 1      1.00MiB   1025MiB   1024MiB   primary   xfs          boot
 2      1025MiB   56329MiB  55304MiB  primary                lvm
 3      56329MiB  60425MiB  4096MiB   primary
 4      60425MiB  70665MiB  10240MiB  extended
   

安装targetcli软件包—在RHEL7上提供配置iscsi目标的使用程序是targetcli:

先配置yum仓库:

[root@syf2 ~]# cd /etc/yum.repos.d/
[root@syf2 yum.repos.d]# ls
CentOS-Base.repo       CentOS-Media.repo
CentOS-CR.repo         CentOS-Sources.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo
CentOS-fasttrack.repo
[root@syf2 yum.repos.d]# rm -rf *
[root@syf2 yum.repos.d]# vim qvq.repo
[ovo]
name=ovo02
baseurl=file:///mnt
enabled=1
gpgcheck=0
~                                                         
~ 
[root@syf2 yum.repos.d]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@syf2 ~]# yum -y install targetcli
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
ovo                                | 3.6 kB     00:00     
(1/2): ovo/group_gz                  | 166 kB   00:00     
(2/2): ovo/primary_db                | 3.1 MB   00:00     
Resolving Dependencies
--> Running transaction check
---> Package targetcli.noarch 0:2.1.fb46-7.el7 will be installed
--> Processing Dependency: python-rtslib >= 2.1.fb41 for package: targetcli-2.1.fb46-7.el7.noarch
--> Processing Dependency: python-configshell for package: targetcli-2.1.fb46-7.el7.noarch
--> Running transaction check
---> Package python-configshell.noarch 1:1.1.fb23-5.el7 will be installed
--> Processing Dependency: python-urwid for package: 1:python-configshell-1.1.fb23-5.el7.noarch
--> Processing Dependency: pyparsing for package: 1:python-configshell-1.1.fb23-5.el7.noarch
---> Package python-rtslib.noarch 0:2.1.fb63-13.el7 will be installed
--> Processing Dependency: python-kmod for package: python-rtslib-2.1.fb63-13.el7.noarch
--> Running transaction check
---> Package pyparsing.noarch 0:1.5.6-9.el7 will be installed
---> Package python-kmod.x86_64 0:0.9-4.el7 will be installed
---> Package python-urwid.x86_64 0:1.1.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================
 Package             Arch    Version           Repository
                                                     Size
==========================================================
Installing:
 targetcli           noarch  2.1.fb46-7.el7    ovo   67 k
Installing for dependencies:
 pyparsing           noarch  1.5.6-9.el7       ovo   94 k
 python-configshell  noarch  1:1.1.fb23-5.el7  ovo   68 k
 python-kmod         x86_64  0.9-4.el7         ovo   57 k
 python-rtslib       noarch  2.1.fb63-13.el7   ovo  100 k
 python-urwid        x86_64  1.1.1-3.el7       ovo  654 k

Transaction Summary
==========================================================
Install  1 Package (+5 Dependent packages)

Total download size: 1.0 M
Installed size: 4.6 M
Downloading packages:
----------------------------------------------------------
Total                        3.5 MB/s | 1.0 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-kmod-0.9-4.el7.x86_64           1/6 
  Installing : python-rtslib-2.1.fb63-13.el7.noarch   2/6 
  Installing : pyparsing-1.5.6-9.el7.noarch           3/6 
  Installing : python-urwid-1.1.1-3.el7.x86_64        4/6 
  Installing : 1:python-configshell-1.1.fb23-5.el7.   5/6 
  Installing : targetcli-2.1.fb46-7.el7.noarch        6/6 
  Verifying  : 1:python-configshell-1.1.fb23-5.el7.   1/6 
  Verifying  : python-urwid-1.1.1-3.el7.x86_64        2/6 
  Verifying  : targetcli-2.1.fb46-7.el7.noarch        3/6 
  Verifying  : python-rtslib-2.1.fb63-13.el7.noarch   4/6 
  Verifying  : pyparsing-1.5.6-9.el7.noarch           5/6 
  Verifying  : python-kmod-0.9-4.el7.x86_64           6/6 

Installed:
  targetcli.noarch 0:2.1.fb46-7.el7                       

Dependency Installed:
  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                       

Complete!

安装好后就可以用这个实际的工具命令来做我们的存储管理

[root@syf2 ~]# 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'.

/> help 

GENERALITIES
============
This is a shell in which you can create, delete and configure
configuration objects.

The available commands depend on the current path or target
path you want to run a command in: different path have
different sets of available commands, i.e. a path pointing at
an iscsi target will not have the same availaible commands as,
say, a path pointing at a storage object.

The prompt that starts each command line indicates your
current path. Alternatively (useful if the prompt displays
an abbreviated path to save space), you can run the
pwd command to display the complete current path.

Navigating the tree is done using the cd command. Without
any argument, cd will present you with the full objects
tree. Just use arrows to select the destination path, and
enter will get you there. Please try help cd for navigation
tips.

COMMAND SYNTAX
==============
Commands are built using the following syntax:

[TARGET_PATH] COMMAND_NAME [OPTIONS]

The TARGET_PATH indicates the path to run the command from.
If ommited, the command will be run from your current path.

The OPTIONS depend on the command. Please use help
COMMAND to get more information.


AVAILABLE COMMANDS
==================
The following commands are available in the
current path:

  - bookmarks action [bookmark] 
  - cd [path] 
  - clearconfig [confirm] 
  - exit 
  - get [group] [parameter...] 
  - help [topic] 
  - ls [path] [depth] 
  - pwd 
  - refresh 
  - restoreconfig [savefile] [clear_existing] 
  - saveconfig [savefile] 
  - sessions [action] [sid] 
  - set [group] [parameter=value...] 
  - status 
  - version 
/> ls
o- / ............................................... [...]
  o- backstores .................................... [...]   //后备存储
  | o- block ........................ [Storage Objects: 0]   //块设备
  | o- fileio ....................... [Storage Objects: 0]   //使用dd命令创建的文件
  | o- pscsi ........................ [Storage Objects: 0]   //物理scsi,通常不使用
  | o- ramdisk ...................... [Storage Objects: 0]   //类似于U盘
  o- iscsi .................................. [Targets: 0]
  o- loopback ............................... [Targets: 0]
/> cd backstores/block
/backstores/block> ls
o- block ............................ [Storage Objects: 0]
/backstores/block> create block1 /dev/sda4
Created block storage object block1 using /dev/sda4.
/backstores/block> ls
o- block ............................ [Storage Objects: 1]
  o- block1 . [/dev/sda4 (0 bytes) write-thru deactivated]
    o- alua ............................. [ALUA Groups: 1]
      o- default_tg_pt_gp . [ALUA state: Active/optimized]
/backstores/block> cd ..
/backstores> ls
o- backstores ...................................... [...]
  o- block .......................... [Storage Objects: 1]
  | o- block1  [/dev/sda4 (0 bytes) write-thru deactivated]
  |   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]
/backstores> cd /
/> ls
o- / ............................................... [...]
  o- backstores .................................... [...]
  | o- block ........................ [Storage Objects: 1]
  | | o- block1  [/dev/sda4 (0 bytes) write-thru deactivated]
  | |   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: 0]
  o- loopback ............................... [Targets: 0]
/> cd iscsi 
/iscsi> ls
o- iscsi .................................... [Targets: 0]
/iscsi> create iqn.2025-08.com.example:qvq    //为目标创建iqn
Created target iqn.2025-08.com.example:qvq.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> ls
o- iscsi .................................... [Targets: 1]
  o- iqn.2025-08.com.example:qvq ............... [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]
/iscsi> cd iqn.2025-08.com.example:qvq/tpg1/acls
/iscsi/iqn.20...qvq/tpg1/acls> ls
o- acls ........................................ [ACLs: 0]
/iscsi/iqn.20...qvq/tpg1/acls> create iqn.2025-08.com.example:qaq
Created Node ACL for iqn.2025-08.com.example:qaq
/iscsi/iqn.20...qvq/tpg1/acls> cd ../luns
/iscsi/iqn.20...qvq/tpg1/luns> ls
o- luns ........................................ [LUNs: 0]
/iscsi/iqn.20...qvq/tpg1/luns> create /backstores/block/block1 
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.2025-08.com.example:qaq
/iscsi/iqn.20...qvq/tpg1/luns> ls
o- luns ........................................ [LUNs: 1]
  o- lun0 .. [block/block1 (/dev/sda4) (default_tg_pt_gp)]
/iscsi/iqn.20...qvq/tpg1/luns> cd ../portals/
/iscsi/iqn.20.../tpg1/portals> ls
o- portals .................................. [Portals: 1]
  o- 0.0.0.0:3260 ................................... [OK]
/iscsi/iqn.20.../tpg1/portals> delete ip_address=0.0.0.0 ip_port=3260
Deleted network portal 0.0.0.0:3260
/iscsi/iqn.20.../tpg1/portals> ls
o- portals .................................. [Portals: 0]
/iscsi/iqn.20.../tpg1/portals> create ip_address=192.168.100.20 ip_port=3260
Using default IP port 3260
Created network portal 192.168.100.20:3260.
/iscsi/iqn.20.../tpg1/portals> ls
o- portals .................................. [Portals: 1]
  o- 192.168.100.20:3260 ............................ [OK]
/iscsi/iqn.20.../tpg1/portals> cd /
/> ls
o- / ............................................... [...]
  o- backstores .................................... [...]
  | o- block ........................ [Storage Objects: 1]
  | | o- block1  [/dev/sda4 (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:qvq ............. [TPGs: 1]
  |   o- tpg1 ..................... [no-gen-acls, no-auth]
  |     o- acls ................................ [ACLs: 1]
  |     | o- iqn.2025-08.com.example:qaq  [Mapped LUNs: 1]
  |     |   o- mapped_lun0 ...... [lun0 block/block1 (rw)]
  |     o- luns ................................ [LUNs: 1]
  |     | o- lun0  [block/block1 (/dev/sda4) (default_tg_pt_gp)]
  |     o- portals .......................... [Portals: 1]
  |       o- 192.168.100.20:3260 .................... [OK]
  o- loopback ............................... [Targets: 0]
/> exit 
Global pref auto_save_on_exit=true     //自动保存
Configuration saved to /etc/target/saveconfig.json
[root@syf2 ~]# systemctl restart target
[root@syf2 ~]# systemctl enable target
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.
[root@syf2 ~]# systemctl stop firewalld
[root@syf2 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@syf2 ~]# vim /etc/selinux/config 
...
SELINUX=disabled   //改成disabled
...
[root@syf2 ~]# reboot      //重启
//重启之后,东西还在
[root@syf2 ~]# targetcli 
targetcli shell version 2.1.fb46
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> cd /
/> ls
o- / ............................................... [...]
  o- backstores .................................... [...]
  | o- block ........................ [Storage Objects: 1]
  | | o- block1  [/dev/sda4 (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:qvq ............. [TPGs: 1]
  |   o- tpg1 ..................... [no-gen-acls, no-auth]
  |     o- acls ................................ [ACLs: 1]
  |     | o- iqn.2025-08.com.example:qaq  [Mapped LUNs: 1]
  |     |   o- mapped_lun0 ...... [lun0 block/block1 (rw)]
  |     o- luns ................................ [LUNs: 1]
  |     | o- lun0  [block/block1 (/dev/sda4) (default_tg_pt_gp)]
  |     o- portals .......................... [Portals: 1]
  |       o- 192.168.100.20:3260 .................... [OK]
  o- loopback ............................... [Targets: 0]
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup/.
Configuration saved to /etc/target/saveconfig.json

iscsi客户端配置
安装iscsi-initiator-utils

先配置yum仓库

[root@syf ~]# cd /etc/yum.repos.d/
[root@syf yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo         CentOS-Media.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo
[root@syf yum.repos.d]# rm -rf *
[root@syf yum.repos.d]# vim qwq.repo
[twob]
name=twob0
baseurl=file:///mnt
enabled=1
gpgcheck=0
~                                                               
~ 
[root@syf yum.repos.d]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@syf ~]# yum -y install iscsi-initiator-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package iscsi-initiator-utils.x86_64 0:6.2.0.874-10.el7 will be installed
--> Processing Dependency: iscsi-initiator-utils-iscsiuio >= 6.2.0.874-10.el7 for package: iscsi-initiator-utils-6.2.0.874-10.el7.x86_64
--> Running transaction check
---> Package iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================
 Package                     Arch   Version          Repository
                                                           Size
================================================================
Installing:
 iscsi-initiator-utils       x86_64 6.2.0.874-10.el7 twob 421 k
Installing for dependencies:
 iscsi-initiator-utils-iscsiuio
                             x86_64 6.2.0.874-10.el7 twob  92 k

Transaction Summary
================================================================
Install  1 Package (+1 Dependent package)

Total download size: 513 k
Installed size: 2.6 M
Downloading packages:
----------------------------------------------------------------
Total                              310 kB/s | 513 kB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : iscsi-initiator-utils-6.2.0.874-10.el7.x86   1/2 
  Installing : iscsi-initiator-utils-iscsiuio-6.2.0.874-1   2/2 
  Verifying  : iscsi-initiator-utils-iscsiuio-6.2.0.874-1   1/2 
  Verifying  : iscsi-initiator-utils-6.2.0.874-10.el7.x86   2/2 

Installed:
  iscsi-initiator-utils.x86_64 0:6.2.0.874-10.el7               

Dependency Installed:
  iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-10.el7      

Complete!

修改/etc/iscsi/initiatorname.iscsi配置文件—作为iscsi节点,客户端需要唯一的iqn,我们需要将该配置文件中的iqn改成我们之前在acl中新建的那个iqn

[root@syf ~]# vim /etc/iscsi/initiatorname.iscsi 
InitiatorName=iqn.2025-08.com.example:qvq
~                                                               
~  

重启iscsi、iscsid服务,并设置下次启动生效

[root@syf ~]# systemctl restart iscsi
[root@syf ~]# systemctl enable iscsi
[root@syf ~]# systemctl restart iscsid
[root@syf ~]# systemctl enable iscsid
Created symlink from /etc/systemd/system/multi-user.target.wants/iscsid.service to /usr/lib/systemd/system/iscsid.service.

发现目标

在发现模式中,sendtargets请求仅返回带有为此启动器配置的访问权限的目标

[root@syf ~]# iscsiadm -m discovery -t sendtargets -p 192.168.100.20:3260
192.168.100.20:3260,1 iqn.2025-08.com.example:qvq
[root@syf ~]# ls
anaconda-ks.cfg  Downloads             Pictures   Videos
Desktop          initial-setup-ks.cfg  Public
Documents        Music                 Templates

登陆目标

iscsiadm -m node -T iqn.2025-08.com.example:qvq -p 192.168.100.20:3260 -l

登录成功后使用fdisk -l命令查看磁盘情况,会发现客户端多了一个块设备

fdisk  -l

使用iscsi块存储
对/dev/sdb设备进行分区,并格式化,规划划分分区大小为1G,格式化为xfs

parted  /dev/sdb
udevadm settle
mkfs.xfs  /dev/sdb1

挂载

mkdir  /iscsistorage
mount  /dev/sdb1  /iscsistorage(临时挂载)

永久挂载

blkid /dev/sdb4----把查询到的UUID复制
vim  /etc/fstab
UUID=...粘贴    /iscsistorage    xfs   defaults,_netdev   0   0

mount  -a

注:_netdev一定要加上,因为我们一旦重启了服务器,系统启动过程中是先读取/etc/fstab文件,然后再读取网卡的,由于我们iscsi存储时属于网络共享,所以如果我们没有写入_netdev这个参数的话,系统就识别不了iscsi存储共享的设备,导致系统启动失败

注销目标
临时注销:

iscsiadm  -m  node  -T  iqn.2020-03.com.example:disk1  -p 192.168.100.20:3260   -u

永久注销—永久注销iscsi目标前,一定先要临时注销iscsi目标

iscsiadm  -m  node  -T  iqn.2020-03.com.example:disk1  -p 192.168.100.20:3260   -u

iscsiadm  -m  node  -T  iqn.2020-03.com.example:disk1  -p 192.168.100.20:3260  -o  delete
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐