Tune and change max open files for Linux
#!/bin/bash
## 文件数限制
ulimit -n
ulimit -Sn
ulimit -Hn
## 最大文件描述符
cat /proc/sys/fs/file-max
## fs.nr_open,进程级别
## fs.file-max,系统级别
## 临时修改
sysctl -w fs.nr_open=100000000
sysctl -w fs.file-max=10000000
## 永久修改
echo "fs.nr_open = 10000000" >> /etc/sysctl.conf
echo "fs.file-max = 11000000" >> /etc/sysctl.conf
## 临时修改最大打开文件数
ulimit -n 10240000
## 查看当前打开的文件数
sysctl fs.file-nr
## 已使用的文件描述符数
cat /proc/sys/fs/file-nr |cut -f1
## 最大线程数
cat /proc/sys/kernel/threads-max
## 已使用的线程数
ps -eLf | wc -l
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here
Try iOS App