查看命令
ulimit -a
# ulimit -a
real-time non-blocking time (microseconds, -R) unlimited
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31286
max locked memory (kbytes, -l) 1015236
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 31286
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
临时的修改,关闭终端失效
// S代表soft,超过该值则warning; H代表hard,超过则error
ulimit -n 1000000
ulimit -SHn 1000000
ulimit -Sn 1000000
ulimit -Hn 1000000
永久设置
sudo vim /etc/security/limits.conf
打开后,在文件最后添加:
* soft nofile 1000000
* hard nofile 1000000
* soft nproc 1000000
* hard nproc 1000000
ubuntu系统下,*对root不生效但是对其他用户生效,所以添加如下配置
root soft nofile 1000000
root hard nofile 1000000
root soft nproc 1000000
root hard nproc 1000000
ubuntu总配置
root soft nofile 1000000
root hard nofile 1000000
root soft nproc 1000000
root hard nproc 1000000
* soft nofile 1000000
* hard nofile 1000000
* soft nproc 1000000
* hard nproc 1000000
修改进程级别open files配置
然后,在下面的两文件中加入:
DefaultLimitNOFILE=1000000
sudo vim /etc/systemd/user.conf
sudo vim /etc/systemd/system.conf
如果是ubuntu,再设置个用户最大可打开的文件数
vim /etc/sysctl.conf
# 单用户最大监控实例数
fs.inotify.max_user_instances = 65535
评论区