栏目头部广告

Linux使用systemctl启动服务报错: Error:No space left on device

一、现象与分析

CentOS 7.9使用systemctl启动nginx服务报错: Error:No space left on device。3ddee864-14b9-4919-a9f3-f90a7c67cac1.png

(1)查看磁盘空间实际占用情况

udisk.png

(2)查看磁盘inodes占用情况

83505f55-5452-4089-9a53-9510b98ede73.png

注:通过截图不难发现,磁盘和inodes使用率非常低,完全不应该出现磁盘满的情况。

二、问题解决

经过一番查阅资料,我发现了这样一句描述“By default, Linux only allocates 8192 watches for inotify, which is ridiculously low. And when it runs out, the error is also No space left on device, which may be confusing if you aren't explicitly looking for this issue.”

(1)查看CentOS7.9默认inotify的max_user_watches值

[root@192-168-0-45 ~]# sysctl fs.inotify
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 8192

# 查看更多inotify相关参数配置,可以通过man命令
[root@10-10-52-145 ~]# man inotify

注:可以发现,系统默认inotify的max_user_watches值的确为8192。

(2)再查看CentOS7.9当前使用量

[root@10-10-52-145 ~]# find /proc/*/fd -user "$USER" -lname anon_inode:inotify \
-printf '%hinfo/%f\n' 2>/dev/null \
| xargs cat | grep -c '^inotify'

8200

注:可以发现,其值已经超过了默认最大值。

(3)问题解决

# 调整max_user_watches大小,扩大10倍
[root@10-10-52-145 ~]# vim /etc/sysctl.conf 
fs.inotify.max_user_watches = 81920

# 刷新配置
[root@10-10-52-145 ~]# sysctl -p
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
fs.inotify.max_user_watches = 81920

# 再次查看inotify
[root@10-10-52-145 ~]# sysctl fs.inotify
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 81920

#  服务验证
[root@10-10-52-145 ~]# systemctl restart nginx.service

注:可以看出,调整max_user_watches值后,报错消失。

作者:UStarGao
链接:https://starcto.com/application_of_operational/300.html
来源:STARCTO
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处

UCloud云平台推荐


UCloud新用户专属注册连接

UCloud CDN超值特惠专场

UCloud全球云主机(UHost/VPS)大促页面

UCloud快杰云主机大促页面

加载中~
文章详情页广告

随便看看

底部广告
`