linux系统句柄限制调整,当使用netty/socket触发达到系统最大连接数时查看

发布时间 2023-08-17 11:16:35作者: Binz

1、查看局部文件句柄限制

ulimit -n

2、修改限制

vi /etc/security/limits.conf


#soft表示警告的限制,hard表示真正限制,nofile表示打开的最大文件数
#默认为
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535



#调整后为  *代表任何用户
root soft nofile 1000000
root hard nofile 1000000
* soft nofile 1000000
* hard nofile 1000000

3、重启后生效

shutdown -r now

 

4、如果还是有限制,查看全局句柄限制,file-max 表示在linux 中最终所有x线程能够打开的最大文件数

cat /proc/sys/fs/file-max

 

5、修改最大值

sudo vi /etc/sysctl.conf

#在文件的末尾添加 
fs.file-max=1000000

6、执行命令让配置生效,执行后在查看  cat /proc/sys/fs/file-max

sudo sysctl -p