CentOS 7配置iSCSI共享存储案例
案例说明:
在CentOS 7环境下,配置iscsi共享存储。
操作系统版本:
[root@node201 KingbaseHA]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
集群架构:
如下所示,node1和node2为集群节点:
节点信息:
[root@node201 KingbaseHA]# vi /etc/hosts
192.168.1.201 node201
192.168.1.202 node202
192.168.1.203 node203 iscsi_Srv
集群软件:
[root@node201 data]# rpm -qa |egrep 'corosync|pacemaker'
corosynclib-2.4.5-7.el7_9.2.x86_64
pacemaker-1.1.23-1.el7_9.1.x86_64
pacemaker-libs-1.1.23-1.el7_9.1.x86_64
pacemaker-doc-1.1.23-1.el7_9.1.x86_64
corosync-qdevice-2.4.5-7.el7_9.2.x86_64
pacemaker-cluster-libs-1.1.23-1.el7_9.1.x86_64
pacemaker-cli-1.1.23-1.el7_9.1.x86_64
corosync-2.4.5-7.el7_9.2.x86_64
iSCSI简介:
iSCSI(Internet Small Computer System Interface)是一种在IP网络上传输SCSI(Small Computer System Interface)命令和数据的存储协议。它允许将远程存储设备映射到本地主机,提供了一种基于网络的存储解决方案。
iSCSI服务架构涉及以下组件:
- iSCSI Initiator(客户端):iSCSI发起器是指主机或计算机系统,它通过iSCSI协议与远程存储设备进行通信。发起器通过网络发送iSCSI命令和数据来访问远程存储。
- iSCSI Target(服务端):iSCSI目标是远程存储设备或存储服务器,它通过iSCSI协议接受发起器的请求。目标将接收到的iSCSI命令转换为对存储设备的本地SCSI命令,并将数据传输回发起器。
- iSCSI Initiator 和 Target 之间的网络连接:iSCSI Initiator 和 Target 之间的通信是通过TCP/IP网络实现的。通常使用以太网作为传输介质,并使用标准的IP协议栈进行通信。
- iSCSI Initiator 驱动程序(iscsid):iSCSI Initiator 驱动程序是在主机操作系统上运行的软件组件,负责将iSCSI命令和数据传递给网络,并处理从网络接收到的响应。
- iSCSI Target 软件(target.service,targetcli):iSCSI Target 软件是在远程存储设备上运行的软件组件,用于接受和处理来自发起器的iSCSI请求,并将其转换为本地存储设备的操作。
- 存储设备:存储设备可以是磁盘阵列、磁盘存储系统或其他支持SCSI协议的存储设备,LVM 等。iSCSI目标通过本地存储设备提供存储服务。
一、配置ISCSI共享
1、server端安装软件
[root@node201 ~]# yum install targetd targetcli -y
2、启动target服务
[root@node201 ~]# systemctl start targetd
[root@node201 ~]# systemctl enable targetd
Created symlink from /etc/systemd/system/multi-user.target.wants/targetd.service to /usr/lib/systemd/system/targetd.service.
3、配置iscsi共享
如下所示,通过targetli工具配置iscsi的共享:
1)targetli帮助信息
[root@node203 ~]# targetcli
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] [target] [storage_object]
- saveconfig [savefile]
- sessions [action] [sid]
- set [group] [parameter=value...]
- status
- version
/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json
2)创建iscsi磁盘
/> /backstores/block create idisk1 /dev/sdb
Created block storage object idisk1 using /dev/sdb.
/> /backstores/block create idisk2 /dev/sdc
Created block storage object idisk2 using /dev/sdc.
/> ls
o- / ........................................................................................... [...]
o- backstores ................................................................................ [...]
| o- block .................................................................... [Storage Objects: 2]
| | o- idisk1 .......................................... [/dev/sdb (10.7GiB) write-thru deactivated]
| | | o- alua ..................................................................... [ALUA Groups: 1]
| | | o- default_tg_pt_gp ......................................... [ALUA state: Active/optimized]
| | o- idisk2 ......................................... [/dev/sdc (512.0MiB) 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]
iSCSI 支持下面四种后端存储类型:
block:它允许将块设备作为iSCSI后端存储使用,例如硬盘驱动器或逻辑卷。
fileio:它允许使用文件作为iSCSI后端存储使用,即将文件作为虚拟磁盘提供给iSCSI客户端。
pscsi:pscsi代表"pass-through SCSI",允许将SCSI设备直接公开给iSCSI客户端,以便客户端可以直接访问SCSI命令。
ramdisk:它允许将RAM磁盘作为iSCSI后端存储使用,即将内存中的一部分作为虚拟磁盘提供给iSCSI客户端。
3)创建iSCSI服务端
/> iscsi/ create iqn.2024-08.pip.cc:server
Created target iqn.2024-08.pip.cc:server.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/> ls
o- / ........................................................................................... [...]
o- backstores ................................................................................ [...]
| o- block .................................................................... [Storage Objects: 2]
| | o- idisk1 .......................................... [/dev/sdb (10.7GiB) write-thru deactivated]
| | | o- alua ..................................................................... [ALUA Groups: 1]
| | | o- default_tg_pt_gp ......................................... [ALUA state: Active/optimized]
| | o- idisk2 ......................................... [/dev/sdc (512.0MiB) 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: 1]
| o- iqn.2024-08.pip.cc:server ........................................................... [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]
o- loopback ........................................................................... [Targets: 0]
关于为 Target 创建 IQN,有以下几点需要进行说明:
在为 Target 创建 IQN 时会在此 IQN 下面创建一个默认的 TPG。
IQN 即 iSCSI 限定名称,一个全球唯一名称,用于以强制命名格式来识别启动器(initiator)和目标(target)。
通用格式:iqn.YYYY-MM.com.reversed.domain[:optional_string];
iqn:表示此名称将使用域作为其标识符;
YYYY-MM:拥有域名的第一个月;
com.reversed.domain:此 iSCSI 名称的创建组织的逆向域名;
optional_string:以冒号为前缀的可选字符串。
管理员如果不指定要创建的 IQN,系统会自动生成一个 IQN。
4)创建lun(共享卷)
/> cd iscsi/iqn.2024-08.pip.cc:server/tpg1/
/iscsi/iqn.20...c:server/tpg1> luns/ create /backstores/block/idisk1
Created LUN 0.
/iscsi/iqn.20...c:server/tpg1> luns/ create /backstores/block/idisk2
Created LUN 1.
/iscsi/iqn.20...c:server/tpg1> ls
o- tpg1 ....................................................................... [no-gen-acls, no-auth]
o- acls .................................................................................. [ACLs: 0]
o- luns .................................................................................. [LUNs: 2]
| o- lun0 ............................................. [block/idisk1 (/dev/sdb) (default_tg_pt_gp)]
| o- lun1 ............................................. [block/idisk2 (/dev/sdc) (default_tg_pt_gp)]
o- portals ............................................................................ [Portals: 1]
o- 0.0.0.0:3260 ............................................................................. [OK]
5)创建客户端认证(chap)
/iscsi/iqn.20...c:server/tpg1> acls/ create iqn.2024-08.pip.cc:client
Created Node ACL for iqn.2024-08.pip.cc:client
Created mapped LUN 1.
Created mapped LUN 0.
/iscsi/iqn.20...c:server/tpg1> cd acls/iqn.2024-08.pip.cc:client/
/iscsi/iqn.20...pip.cc:client> set auth userid=root
Parameter userid is now 'root'.
/iscsi/iqn.20...pip.cc:client> set auth password=123456
Parameter password is now '123456'.
/iscsi/iqn.20...pip.cc:client> info
chap_password: 123456
chap_userid: root
wwns:
iqn.2024-08.pip.cc:client
6)创建portal
管理员需要创建一个门户配置以指定监听 IP 地址和端口;如果未指定 IP 则默认使用 0.0.0.0 地址;如果未指定端口号则默认使用 3260 端口。
/> cd iscsi/iqn.2024-08.pip.cc:server/tpg1/
/iscsi/iqn.20...c:server/tpg1> ls
o- tpg1 ....................................................................... [no-gen-acls, no-auth]
o- acls .................................................................................. [ACLs: 1]
| o- iqn.2024-08.pip.cc:client .................................................... [Mapped LUNs: 2]
| o- mapped_lun0 ........................................................ [lun0 block/idisk1 (rw)]
| o- mapped_lun1 ........................................................ [lun1 block/idisk2 (rw)]
o- luns .................................................................................. [LUNs: 2]
| o- lun0 ............................................. [block/idisk1 (/dev/sdb) (default_tg_pt_gp)]
| o- lun1 ............................................. [block/idisk2 (/dev/sdc) (default_tg_pt_gp)]
o- portals ............................................................................ [Portals: 1]
o- 0.0.0.0:3260 ............................................................................. [OK]
/iscsi/iqn.20...c:server/tpg1> cd portals
/iscsi/iqn.20.../tpg1/portals> delete 0.0.0.0 3260
Deleted network portal 0.0.0.0:3260
/iscsi/iqn.20.../tpg1/portals> create 192.168.1.203 3260
Using default IP port 3260
Created network portal 192.168.1.203:3260.
/iscsi/iqn.20.../tpg1/portals> ls
o- portals .............................................................................. [Portals: 1]
o- 192.168.1.203:3260 ......................................................................... [OK]
7)查看iscsi server配置
/iscsi/iqn.20...pip.cc:client> cd /
/> ls
o- / ........................................................................................... [...]
o- backstores ................................................................................ [...]
| o- block .................................................................... [Storage Objects: 2]
| | o- idisk1 ............................................ [/dev/sdb (10.7GiB) write-thru activated]
| | | o- alua ..................................................................... [ALUA Groups: 1]
| | | o- default_tg_pt_gp ......................................... [ALUA state: Active/optimized]
| | o- idisk2 ........................................... [/dev/sdc (512.0MiB) 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.2024-08.pip.cc:server ........................................................... [TPGs: 1]
| o- tpg1 ................................................................. [no-gen-acls, no-auth]
| o- acls ............................................................................ [ACLs: 1]
| | o- iqn.2024-08.pip.cc:client .............................................. [Mapped LUNs: 2]
| | o- mapped_lun0 .................................................. [lun0 block/idisk1 (rw)]
| | o- mapped_lun1 .................................................. [lun1 block/idisk2 (rw)]
| o- luns ............................................................................ [LUNs: 2]
| | o- lun0 ....................................... [block/idisk1 (/dev/sdb) (default_tg_pt_gp)]
| | o- lun1 ....................................... [block/idisk2 (/dev/sdc) (default_tg_pt_gp)]
| o- portals ...................................................................... [Portals: 1]
| o- 192.168.1.203:3260 ................................................................. [OK]
o- loopback ........................................................................... [Targets: 0]
/> saveconfig
Last 10 configs saved in /etc/target/backup/.
Configuration saved to /etc/target/saveconfig.json
/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json
4、重启target服务
[root@node203 ~]# systemctl restart target
[root@node203 ~]# systemctl status target
● target.service - Restore LIO kernel target configuration
Loaded: loaded (/usr/lib/systemd/system/target.service; disabled; vendor preset: disabled)
Active: active (exited) since Fri 2024-08-02 10:50:45 CST; 4s ago
Process: 18476 ExecStop=/usr/bin/targetctl clear (code=exited, status=0/SUCCESS)
.......
5、配置客户端访问iscsi共享(all nodes)
iscsi-initiator-utils 提供了 iSCSI 客户端的工具和服务,用于管理和配置 iSCSI 连接。它包含了 iscsiadm 命令行工具和其他与 iSCSI 相关的组件。
主要功能和组件包括:
- iscsiadm 命令行工具:iscsi-initiator-utils 包含了 iscsiadm 命令行工具,用于管理和配置 iSCSI 连接。您可以使用该工具来发现 iSCSI 目标、建立会话、断开连接、管理目标列表等。
- iSCSI 服务:iscsi-initiator-utils 包含了 iSCSI 服务(通常是 iscsid 守护进程),它在后台运行并处理与 iSCSI 存储目标的通信。该服务负责管理 iSCSI 会话和设备,并提供与 iSCSI 目标的交互接口。
- iSCSI 配置文件:iscsi-initiator-utils 提供了用于配置 iSCSI 客户端的配置文件。这些配置文件包含了 iSCSI 目标的信息、认证设置、会话选项等。您可以编辑这些配置文件来自定义 iSCSI 连接的行为。
1)客户端安装软件
[root@node201 ~]# yum install iscsi-initiator-utils-iscsiuio -y
2)配置iscsi配置文件
如下所示,在客户端配置访问server端认证文件:
[root@node201 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2024-08.pip.cc:client
node.session.auth.authmethod = CHAP
node.session.auth.username = root
node.session.auth.password = 123456
启动服务:
[root@node201 ~]# systemctl restart iscsid
[root@node201 ~]# systemctl enable iscsid
3)客户端访问iscsi共享
# 查看iscsi共享
[root@node201 ~]# iscsiadm -m discovery -t st -p 192.168.1.203
192.168.1.203:3260,1 iqn.2024-08.pip.cc:server
# 建立到iscsi server的共享访问
[root@node201 ~]# iscsiadm -m node -T iqn.2024-08.pip.cc:server -p 192.168.1.203 --login
Logging in to [iface: default, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260] (multiple)
Login to [iface: default, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260] successful.
# 查看共享存储信息
[root@node201 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 102.9G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 102.4G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 3G 0 lvm [SWAP]
└─centos-home 253:2 0 49.3G 0 lvm /home
sdb 8:16 0 10.7G 0 disk
sdc 8:32 0 512M 0 disk
sr0 11:0 1 1024M 0 rom
# 如下所示,在客户端可以看到共享存储已作为本地磁盘访问
[root@node202 iscsi]# fdisk -l
Disk /dev/sdb: 11.5 GB, 11499421696 bytes, 22459808 sectors
......
Disk /dev/sdc: 536 MB, 536870912 bytes, 1048576 sectors
......
# 至此,共享存储配置完成。
4)通过udev对iscsi设备绑定
# 查看节点磁盘uuid
[root@node201 soft]# /usr/lib/udev/scsi_id -g -u /dev/sdb
360014052894c914c81040b4a87e59fb2
[root@node201 soft]# /usr/lib/udev/scsi_id -g -u /dev/sdc
36001405bcd67f428faf49eb9fc8c80dd
[root@node202 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb
360014052894c914c81040b4a87e59fb2
[root@node202 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc
36001405bcd67f428faf49eb9fc8c80dd
# 执行udev绑定
[root@node202 ~]# cat /etc/udev/rules.d/75-persist-iscsi.rules
KERNEL=="sd*",ENV{ID_SERIAL}=="360014052894c914c81040b4a87e59fb2",NAME:="qdisk",MODE:="0644"
KERNEL=="sd*",ENV{ID_SERIAL}=="36001405bcd67f428faf49eb9fc8c80dd",NAME:="kdata",MODE:="0644"
# 重启udev服务
[root@node201 soft]# systemctl restart systemd-udev-trigger
[root@node201 soft]# systemctl status systemd-udev-trigger
● systemd-udev-trigger.service - udev Coldplug all Devices
Loaded: loaded (/usr/lib/systemd/system/systemd-udev-trigger.service; static; vendor preset: disabled)
Active: active (exited) since Tue 2024-09-10 18:02:30 CST; 7s ago
Docs: man:udev(7)
man:systemd-udevd.service(8)
Process: 27733 ExecStart=/usr/bin/udevadm trigger --type=devices --action=add (code=exited, status=0/SUCCESS)
Process: 27732 ExecStart=/usr/bin/udevadm trigger --type=subsystems --action=add (code=exited, status=0/SUCCESS)
Main PID: 27733 (code=exited, status=0/SUCCESS)
Sep 10 18:02:30 node201 systemd[1]: Stopped udev Coldplug all Devices.
Sep 10 18:02:30 node201 systemd[1]: Stopping udev Coldplug all Devices...
Sep 10 18:02:30 node201 systemd[1]: Starting udev Coldplug all Devices...
Sep 10 18:02:30 node201 systemd[1]: Started udev Coldplug all Devices.
附件:iscsi客户端清理iscsi挂载信息
1、查看客户端iscsid进程状态
如下所示,进程状态异常,出现iscsi尝试连接:
[root@node201 ~]# systemctl status iscsid
● iscsid.service - Open-iSCSI
Loaded: loaded (/usr/lib/systemd/system/iscsid.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2024-09-02 19:31:54 CST; 3min 22s ago
......
Main PID: 1077 (iscsid)
Status: "Ready to process requests"
Tasks: 1
CGroup: /system.slice/iscsid.service
└─1077 /sbin/iscsid -f
Sep 02 19:35:08 node201 iscsid[1077]: iscsid: Kernel reported iSCSI connection 1:0 error (1020 - ISCSI_...e (3)
Sep 02 19:35:09 node201 iscsid[1077]: iscsid: Kernel reported iSCSI connection 2:0 error (1020 - ISCSI_...e (3)
Sep 02 19:35:10 node201 iscsid[1077]: iscsid: connection1:0 is operational after recovery (1 attempts)
Sep 02 19:35:11 node201 iscsid[1077]: iscsid: connection2:0 is operational after recovery (1 attempts)
Sep 02 19:35:12 node201 iscsid[1077]: iscsid: Kernel reported iSCSI connection 1:0 error (1020 - ISCSI_...e (3)
Sep 02 19:35:13 node201 iscsid[1077]: iscsid: Kernel reported iSCSI connection 2:0 error (1020 - ISCSI_...e (3)
Sep 02 19:35:14 node201 iscsid[1077]: iscsid: connection1:0 is operational after recovery (1 attempts)
Sep 02 19:35:15 node201 iscsid[1077]: iscsid: connection2:0 is operational after recovery (1 attempts)
Sep 02 19:35:16 node201 iscsid[1077]: iscsid: Kernel reported iSCSI connection 1:0 error (1020 - ISCSI_...e (3)
Sep 02 19:35:17 node201 iscsid[1077]: iscsid: Kernel reported iSCSI connection 2:0 error (1020 - ISCSI_...e (3)
Hint: Some lines were ellipsized, use -l to show in full.
2、查看系统message日志
如下所示,系统message日志也出现大量iscsi重连信息:
[root@node201 ~]# tail /var/log/message:
Sep 2 17:14:38 node201 iscsid: iscsid: connection1:0 is operational after recovery (1 attempts)
Sep 2 17:14:40 node201 kernel: connection1:0: detected conn error (1020)
Sep 2 17:14:40 node201 iscsid: iscsid: Kernel reported iSCSI connection 1:0 error (1020 - ISCSI_ERR_TCP_CONN_CLOSE: TCP connection closed) state (3)
Sep 2 17:14:42 node201 iscsid: iscsid: connection1:0 is operational after recovery (1 attempts)
Sep 2 17:14:44 node201 kernel: connection1:0: detected conn error (1020)
Sep 2 17:14:44 node201 iscsid: iscsid: Kernel reported iSCSI connection 1:0 error (1020 - ISCSI_ERR_TCP_CONN_CLOSE: TCP connection closed) state (3)
Sep 2 17:14:46 node201 iscsid: iscsid: connection1:0 is operational after recovery (1 attempts)
3、查看iscsi server及客户端磁盘信息
[root@node201 ~]# iscsiadm -m discovery -t st -p 192.168.1.203
192.168.1.203:3260,1 iqn.2024-08.pip.cc:server
[root@node202 ~]# lsscsi
[1:0:0:0] cd/dvd VBOX CD-ROM 1.0 /dev/sr0
[2:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sda
[5:0:0:0] disk LIO-ORG idisk1 4.0 /dev/sdb
[5:0:0:1] disk LIO-ORG idisk2 4.0 /dev/sdf
[5:0:0:2] disk LIO-ORG idisk7 4.0 /dev/sdg
[5:0:0:3] disk LIO-ORG idisk4 4.0 /dev/sde
[5:0:0:4] disk LIO-ORG idisk5 4.0 /dev/sdd
[5:0:0:5] disk LIO-ORG idisk6 4.0 /dev/sdc
[5:0:0:6] disk LIO-ORG idisk8 4.0 /dev/sdh
[6:0:0:0] disk LIO-ORG idisk1 4.0 /dev/sdi
[6:0:0:1] disk LIO-ORG idisk2 4.0 /dev/sdm
[6:0:0:2] disk LIO-ORG idisk7 4.0 /dev/sdn
[6:0:0:3] disk LIO-ORG idisk4 4.0 /dev/sdl
[6:0:0:4] disk LIO-ORG idisk5 4.0 /dev/sdk
[6:0:0:5] disk LIO-ORG idisk6 4.0 /dev/sdj
[6:0:0:6] disk LIO-ORG idisk8 4.0 /dev/sdo
4、清理iscsi客户端login
[root@node202 ~]# iscsiadm -m node --logoutall=all
Logging out of session [sid: 1, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260]
Logging out of session [sid: 2, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260]
Logout of [sid: 1, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260] successful.
Logout of [sid: 2, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260] successful.
# 查看client磁盘信息
[root@node202 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 102.9G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 102.4G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 3G 0 lvm [SWAP]
└─centos-home 253:2 0 49.3G 0 lvm /home
sr0 11:0 1 1024M 0 rom
[kingbase@node201 ~]$ lsscsi
[1:0:0:0] cd/dvd VBOX CD-ROM 1.0 /dev/sr0
[2:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sda
5、iscsi client重新注册到iscsi server
[root@node201 ~]# /usr/sbin/iscsiadm -m node -T iqn.2024-08.pip.cc:server -p 192.168.1.203 --login
Logging in to [iface: default, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260] (multiple)
Login to [iface: default, target: iqn.2024-08.pip.cc:server, portal: 192.168.1.203,3260] successful.
# client磁盘信息
[root@node201 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 102.9G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 102.4G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 3G 0 lvm [SWAP]
└─centos-home 253:2 0 49.3G 0 lvm /home
sdb 8:16 0 10.7G 0 disk
sdc 8:32 0 8.3G 0 disk
sdd 8:48 0 2.2G 0 disk
sde 8:64 0 128M 0 disk
└─sde1 8:65 0 96M 0 part
sdf 8:80 0 512M 0 disk
sdg 8:96 0 128M 0 disk
sdh 8:112 0 4G 0 disk
sr0 11:0 1 1024M 0 rom
# 如下所示,日志信息正常
[root@node201 ~]#tail /var/log/message:
Sep 2 17:19:38 node201 kernel: scsi 6:0:0:6: alua: Attached
Sep 2 17:19:38 node201 kernel: sd 6:0:0:6: Attached scsi generic sg8 type 0
Sep 2 17:19:38 node201 kernel: sd 6:0:0:1: [sdf] Write cache: enabled, read cache: enabled, supports DPO and FUA
Sep 2 17:19:38 node201 kernel: sd 6:0:0:6: alua: transition timeout set to 60 seconds
Sep 2 17:19:38 node201 kernel: sd 6:0:0:6: alua: port group 00 state A non-preferred supports TOlUSNA
Sep 2 17:19:38 node201 kernel: sd 6:0:0:6: [sdh] 8388608 512-byte logical blocks: (4.29 GB/4.00 GiB)
Sep 2 17:19:38 node201 kernel: sd 6:0:0:2: [sdg] Write Protect is off
Sep 2 17:19:38 node201 kernel: sd 6:0:0:1: [sdf] Optimal transfer size 33550336 bytes
Sep 2 17:19:38 node201 kernel: sd 6:0:0:2: [sdg] Write cache: enabled, read cache: enabled, supports DPO and FUA
6、查看iscsid进程状态
如下所示,iscsid进程状态正常。
[root@node201 ~]# systemctl status iscsid
● iscsid.service - Open-iSCSI
Loaded: loaded (/usr/lib/systemd/system/iscsid.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2024-09-02 19:36:59 CST; 24s ago
......
Main PID: 4279 (iscsid)
Status: "Ready to process requests"
Tasks: 1
CGroup: /system.slice/iscsid.service
└─4279 /sbin/iscsid -f
Sep 02 19:36:59 node201 systemd[1]: Stopping Open-iSCSI...
Sep 02 19:36:59 node201 iscsid[3719]: iscsid: iscsid shutting down.
Sep 02 19:36:59 node201 systemd[1]: Stopped Open-iSCSI.
Sep 02 19:36:59 node201 systemd[1]: Starting Open-iSCSI...
Sep 02 19:36:59 node201 systemd[1]: Started Open-iSCSI.
Sep 02 19:37:19 node201 iscsid[4279]: iscsid: Connection3:0 to [target: iqn.2024-08.pip.cc:server, port...l now
Hint: Some lines were ellipsized, use -l to show in full.