【NFS】Lock reclaim failed-造成web卡住504
服务器环境:kernel:3.10.0-862.14.4.el7.x86_64nfs:1:1.3.0-0.68.el7
目录
警报触发
搬砖搬砖。。。突然邮件弹窗XXX系统访问504,难道又是别人请求响应超时了?紧接着又来了几个504,不秒啊,决定上机器一探究竟。
排查过程
ps -ef
发现不少php程序,每分钟几个很规律。怀疑是不是crond里面添加的计划任务卡住了。先记着继续查看
top,lsof -p XX ,df -Th,iostat
一套工具下去,想看看是不是系统资源限制了,发现没什么异常。
less /var/log/message
查询message日志,有打印 kernel: NFS: nfs4_reclaim_open_state: Lock reclaim failed。
一想,系统用了NFS,NFS挂着目录touch文件报错,原因应该就是这个了。
登录另外一台机器,尝试在NFS挂着目录上写入文件,很正常。
下面就实现plan A:
将服务流量转入正常服务器,
systemctl disable keepalived
因为是使用的Keepalived,所以关闭当前异常机器的Keepalived,将正常机器的计划任务打开,php经常正常执行没有卡住。web也正常了 ,
但是不能放松,因为问题还没解决。
解决问题
NFS实在是不太熟,所以去网上搜一搜,还真查到了
Author: Andrew Elble <aweitsgrit 。edu>
Date:
Fri Nov 3 14:86:31 2017 -0400
nfsd: deal with revaked delegations appropriately
If a delegation has been revoked by the server, operations using that delegation should error out with NFS4ERR_DELEG_REVOKED in the >4.1 case, and NFS4ERR_BAD_STATEID otherwise. The server needs NFSv4.1 clients to explicitly free revoked delegations. If the server returns NFS4ERR_DELEG_REVOKED, the client will do that; otherwise it may just forget about the delegation and be unable to recover when it later sees SEQ4_ STATUS_ RECALLABLE_STATE_REVOKED set on a SEQUENCE reply. That can cause the Linux 4.1 client to loop in its stage manager.
sSigned-off-by: Andrew E1ble <aueits@rit. edu>
Revlewed-by: Trond Pyklebust ctrond .nyklebust@primarydata.com
CC: stab1e@vger.kerne1.org
Signed-off-by: J. Bruce Fields <bf1elds@redhat.com>
这个bug影响的范围
* NFS4.1 or above
* 3.10.0-862.*.el7 and 3.10.0-957.*el7 kernels
当前服务器环境:
kernel:3.10.0-862.14.4.el7.x86_64
nfs:1:1.3.0-0.68.el7
mount|grep nfs
通过 mount |grep nfs 发现客户端NFS使用NFS v4.1版本,正好匹配上。
NFS4 client hangs and must be rebooted to recover.安装文档的意思是必须要重启才能解决
杀php进程
注释计划任务
umount
使用重新挂载 指定版本4.0
mount -t nfs -o timeo=30,retrans=3,vers=4 10.0.0.1:/share /data
注意 开机启动挂载也需要修改(/etc/fstab)
文件写入正常了
后续优化,避免同类问题
- 客户端挂使用NFS4.0
经过mount 命令发现,默认挂着NFS版本为4.1
使用重新挂载 mount -t nfs -o timeo=30,retrans=3,vers=4.0 10.0.0.1:/share /data
- 服务端关闭文件租赁锁
#是否启用文件的租借锁 1:启用 0:不启用
echo 0 > /proc/sys/fs/leases-enable
sysctl -w fs.leases-enable=0
- 将升级内核,并加入到系统初始化中
yum update kernel* #升级内核
需要 重启系统reboot
收获
NFS server delegation
NFS v4引入了服务器委托作为一种加快文件访问的方式,服务器可以将对客户端的读取或写入访问委派给客户端,这样客户端就不必继续询问服务器该文件是否已被另一个客户端更改,回收过程称为委托回收
问题随时都能发生,要保持警惕性,查看日志是非常必要的。
优先解决线上问题。
参考资料
更多推荐
所有评论(0)