Linux: Find Out How Many File Descriptors Are Being Used

本文介绍了解决数据库服务器因文件句柄限制导致无法启动新进程的问题。通过调整Linux内核参数fs.file-max,将最大文件句柄数从8192增加到331287,有效解决了“too many open files”错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Today my DBA reported that the server she was working on was spitting out “too many open files” errors and no new processes could be started.
This is a common problem with DB servers with heavy transactions. In my environment there are 6 DB instances running on the server. No quite the optimized setup I would say.
The fix was to increase the total file descriptors kernel parameter count in the /etc/sysctl.conf file. I doubled my limit from 8192 to 16384.
The walk through,
1. Find out what the current open file descriptor limit is.
 
~# more /proc/sys/fs/file-max
 
~# 8192
 
or
~# sysctl -a | grep fs.file-max
 
~# fs.file-max = 8192
 
2. View how many open file descriptors are currently being used.
~# more /proc/sys/fs/file-nr
 
~# 8191
 
3. View how many files are open. The number returned might defer as 1 file descriptor can have multiple open files attached to it.
~# lsof | wc -l
 
~# 10325
 
4. Edit the kernel paramneter file /etc/sysctl.conf and add line “fs.file-max=[new value]” to it.
~# vi /etc/sysctl.conf
 
fs.file-max = 331287
 
5. Apply the changes.
~# sysctl -p
~# fs.file-max = 331287
 
Problem fixed.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值