3.9.8 常见故障排查与运维案例
3.9.8 常见故障排查与运维案例#
一、原理草图:网络存储故障定位路径
二、通用排障流程(含命令与解释)
1. 确认现象与影响面
# 客户端查看挂载状态与卡顿点
mount | egrep 'nfs|cifs|iscsi'
df -hT
# I/O 延迟观察(需要 sysstat)
iostat -x 1 5
mount:确认已挂载类型与参数df -hT:查看文件系统类型及剩余空间iostat -x:观察await/svctm指标
- 网络与时钟基础检查
ping -c 3 storage.example.com
ss -ntp | egrep '2049|445|3260'
timedatectl status
ss -ntp:检查关键端口连接状态timedatectl:时间偏差会导致认证失败
- 关键日志
# 客户端内核与系统日志
dmesg | tail -n 50
journalctl -u nfs-client.target -n 50
# 服务端日志(按实际服务)
journalctl -u nfs-server -n 50
journalctl -u smb -n 50
journalctl -u iscsid -n 50
三、NFS 常见故障与案例(含示例与修复)
- 挂载失败/卡住
- 现象:mount.nfs: Connection timed out
# 服务端检查
systemctl status nfs-server
rpcinfo -p 10.0.0.10
firewall-cmd --list-all | egrep 'nfs|rpc'
修复示例:
# 放行端口
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --reload
# 服务重启
systemctl restart rpcbind nfs-server
- 权限拒绝
- 现象:Permission denied
# 服务端检查导出
exportfs -v
cat /etc/exports
修复示例(统一 UID/GID 或映射):
# /etc/exports
/data/share 10.0.0.0/24(rw,sync,all_squash,anonuid=1001,anongid=1001)
exportfs -rav
- 陈旧文件句柄
- 现象:Stale file handle
# 客户端强制卸载并重新挂载
umount -f /mnt/nfs
mount -t nfs -o vers=4 10.0.0.10:/data/share /mnt/nfs
NFS 安装与验证示例
# 服务端安装
yum -y install nfs-utils rpcbind
# 导出目录
mkdir -p /data/share
chown -R 1001:1001 /data/share
# 配置导出
cat > /etc/exports <<'EOF'
/data/share 10.0.0.0/24(rw,sync,no_root_squash)
EOF
# 启动服务
systemctl enable --now rpcbind nfs-server
exportfs -rav
# 客户端验证
yum -y install nfs-utils
mount -t nfs 10.0.0.10:/data/share /mnt/nfs
touch /mnt/nfs/ok && ls -l /mnt/nfs/ok
四、SMB/CIFS 常见故障与案例
- 认证失败
- 现象:NT_STATUS_LOGON_FAILURE
# 服务端用户配置检查
pdbedit -L
修复示例:
smbpasswd -a opsuser
- 版本协商失败
- 现象:mount error(95): Operation not supported
# 客户端指定协议版本
mount -t cifs //10.0.0.20/share /mnt/smb -o vers=3.0,username=opsuser
Samba 安装与最小配置示例
yum -y install samba
cat > /etc/samba/smb.conf <<'EOF'
[global]
workgroup = WORKGROUP
security = user
server min protocol = SMB2
[share]
path = /data/smb
read only = no
browsable = yes
EOF
mkdir -p /data/smb
useradd opsuser
smbpasswd -a opsuser
systemctl enable --now smb
五、iSCSI 常见故障与案例
- 发现不到 Target
iscsiadm -m discovery -t st -p 10.0.0.30
- 失败多为端口未通或 Target 未发布
- 登录失败(CHAP/IQN)
# 客户端配置 CHAP
iscsiadm -m node -T iqn.2024-01.com.lab:storage -p 10.0.0.30 \
--op update -n node.session.auth.authmethod -v CHAP
iscsiadm -m node -T iqn.2024-01.com.lab:storage -p 10.0.0.30 \
--op update -n node.session.auth.username -v chapuser
iscsiadm -m node -T iqn.2024-01.com.lab:storage -p 10.0.0.30 \
--op update -n node.session.auth.password -v chappass
iscsiadm -m node -T iqn.2024-01.com.lab:storage -p 10.0.0.30 --login
Target 安装与最小配置示例(targetcli)
yum -y install targetcli
targetcli <<'EOF'
/backstores/block create disk1 /dev/sdb
/iscsi create iqn.2024-01.com.lab:storage
/iscsi/iqn.2024-01.com.lab:storage/tpg1/luns create /backstores/block/disk1
/iscsi/iqn.2024-01.com.lab:storage/tpg1/acls create iqn.2024-01.com.lab:client01
/iscsi/iqn.2024-01.com.lab:storage/tpg1 set attribute authentication=1
/iscsi/iqn.2024-01.com.lab:storage/tpg1 set auth userid=chapuser
/iscsi/iqn.2024-01.com.lab:storage/tpg1 set auth password=chappass
saveconfig
exit
EOF
六、分布式存储(Ceph/GlusterFS)常见故障
- 集群降级
# Ceph
ceph -s
ceph health detail
# Gluster
gluster volume status
修复要点:替换故障盘/OSD/brick,避免满盘;修复网络抖动。
七、典型运维案例(含命令与回滚)
- NFS 高峰期 I/O 抖动
- 排查:
iostat -x 1 5
nfsstat -s
- 优化方案:多实例 + Keepalived;必要时使用
async
# /etc/exports(风险:断电可能丢失未落盘数据)
/data/share 10.0.0.0/24(rw,async,no_root_squash)
- 回滚:恢复
sync并重载
sed -i 's/async/sync/' /etc/exports
exportfs -rav
- SMB 小文件访问慢
- 排查:
smbstatus
iostat -x 1 5
- 优化示例:
# /etc/samba/smb.conf
[global]
aio read size = 1
aio write size = 1
socket options = TCP_NODELAY
- 重载:
systemctl reload smb
- iSCSI 多路径异常导致只读
- 排查:
multipath -ll
dmesg | egrep 'blk_update|I/O error'
- 修复:
systemctl restart multipathd
- 配置建议(/etc/multipath.conf):
defaults {
user_friendly_names yes
find_multipaths yes
queue_if_no_path yes
}
八、练习与实操题
1. 练习1:NFS 端到端故障复现与修复
- 步骤:关闭服务端 nfs-server → 客户端尝试挂载 → 记录报错
- 目标:使用 rpcinfo -p 与防火墙命令定位,并恢复挂载
2. 练习2:SMB 协议协商
- 步骤:客户端不指定 vers 挂载 → 观察报错 → 指定 vers=3.0 成功挂载
3. 练习3:iSCSI CHAP 登录失败
- 步骤:故意配置错误密码 → 观察 iscsiadm 报错 → 修正后登录并 lsblk 验证新盘
九、日常运维建议
- 配置备份:/etc/exports、/etc/samba/smb.conf、targetcli 配置
- 变更记录:版本升级、参数调整、拓扑变化
- 指标巡检:容量、I/O 延迟、网络质量、连接数
- 预案演练:故障切换、数据恢复、权限回滚