centos7-iSCSI自启动连接存储

一、实验环境
客户端:Centos8 IP: 10.10.10.1

服务器:windows server2012 R2 IP:10.10.10.254

二、iSCSI自启动连接存储
1. 服务器server2012R2 已安装好相关iSCSI相关服务并建立了虚拟磁盘,且指定了发起方程序ID为Centos8的IP地址

注:此步骤请参考其他教程进行配置

 

 

2. 客户端Centos8配置

A. 安装iSCSI服务

yum -y install iscsi-initiator-utils
B. 查询iSCSI存储映射

iscsiadm -m discovery -t sendtargets -p 10.10.10.254:3260
注:由于我服务器端使用了双网卡所以会查询出两个IP(不影响)

重点:注意查看既有IPv4地址又存在IPv6地址

 

C. 发起连接请求

注:请根据B步骤查询出来的值进行填写

iscsiadm -m node -T iqn.1991-05.com.microsoft:win-xxxx-xxxxx-target -p 10.10.10.254:3260 -l
D. 确认是否成功连接

查询会话: iscsiadm -m session


E. 设置开机启动

服务自启动:
systemctl enable iscsi

开机自启动连接iSCSI存储:
iscsiadm -m node -T iqn.1991-05.com.microsoft:win-pnftl64adk7-xxxxx-xxxxx -p 10.10.10.254:3260 -o update -n node.startup -v automatic
三、发现问题
A. 问题触发:

配置完iSCSI自启动连接存储后,重启Centos8过程发现启动非常慢

通过启动过程发现是iSCSI服务在自启动过程一直在尝试扫描和登录存储设备,时间长达2分钟之久

A start job is running for Login and scanning of iSCSI devices (1min 44s / no limit)

 

B. 查找原因:

B1. 先查看系统启动后的服务状态信息是否正常

查看iSCSI服务状态:
systemctl status iscsi
服务成功启动并且也自动连接到iSCSI存储设备,但存在两条错误信息

iscsiadm: initiator reported error (8 - connection timed out) #连接超时

 

B2. 查看系统启动日志信息

发现产生了大量的iSCSI请求错误信息,且请求的都是IPv6地址而我们并没有进行配置(回头查看自启动连接配置只使用了ipv4的地址),使得系统自启动连接iSCSI存储设备时消耗了大量的时间,导致系统启动非常慢。

查看系统启动日志:
journalctl -b
Dec 19 13:04:35 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:35 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:38 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:38 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:41 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:41 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:44 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:44 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:47 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:47 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:50 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:50 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:53 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:53 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:56 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:56 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:04:59 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:04:59 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:02 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:05:02 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:05 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:05:05 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:08 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:05:08 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:11 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:05:11 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:14 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:05:14 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:17 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:05:17 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:20 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900::1005:3260 (-1,101)
Dec 19 13:05:20 xxxx-xx iscsid[1109]: iscsid: cannot make a connection to 240e:382:2436:9900:bca3:c4cd:3b39:e1dd:3260 (-1,101)
Dec 19 13:05:23 xxxx-xx iscsid[1109]: iscsid: Connection-1:0 to [target: iqn.1991-05.com.microsoft:win-pnftl64adk7-xxx-xxx, portal: 240e:382:2436:9900::1005,3260] through [iface: default] is shutdown.
Dec 19 13:05:23 xxxx-xx iscsid[1109]: iscsid: Connection-1:0 to [target: iqn.1991-05.com.microsoft:win-pnftl64adk7-xxx-xxx, portal: 240e:382:2436:9900:bca3:c4cd:3b39:e1dd,3260] through [iface: default] is shutdow>
Dec 19 13:05:23 xxxx-xx iscsiadm[1100]: iscsiadm: Could not login to [iface: default, target: iqn.1991-05.com.microsoft:win-pnftl64adk7-xxx-xxx, portal: 240e:382:2436:9900::1005,3260].
Dec 19 13:05:23 xxxx-xx iscsiadm[1100]: iscsiadm: initiator reported error (8 - connection timed out)
Dec 19 13:05:23 xxxx-xx iscsiadm[1100]: iscsiadm: Could not login to [iface: default, target: iqn.1991-05.com.microsoft:win-pnftl64adk7-xxx-xxx, portal: 240e:382:2436:9900:bca3:c4cd:3b39:e1dd,3260].
Dec 19 13:05:23 xxxx-xx iscsiadm[1100]: iscsiadm: initiator reported error (8 - connection timed out)
Dec 19 13:05:23 xxxx-xx iscsiadm[1100]: iscsiadm: Could not log into all portals

四、解决问题
问题缘由:经过上述排查,是因为系统自启动连接iSCSI存储设备时由于我们只配置了IPv4地址的连接方式,而系统会自动对IPv6的地址也同时进行扫描和登录,导致产生了大量超时的请求。

方案1:禁用IPv6
由于实际环境中目前未使用IPv6网络,可在server 2012 R2服务器上面禁用掉IPv6即可

 

此时再次使用查询命令发现,已无IPv6地址记录,同时重启系统后发现可快速启动并自动连接到存储设备

 

 

方案2:新增IPv6配置方式连接iSCSI存储
iscsi-initiator-utils目前机制还不支持用链路本地地址(link-local address fe80开头的IPv6地址)地址登录iscsi服务端。

其他方式还待研究......

本次实验记录源于真实环境发现的问题,折腾了很久也没找到相关实用案例,只能手工本地查看日志得出解决办法。特做此记录....勿喷!!!
————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/qq_22787559/article/details/122022517

posted @ 2025-05-15 15:39  aaahwh  阅读(192)  评论(0)    收藏  举报