0%

设置ulimit

设置ulimit

centos服务器设置ulimit,ulimit是指服务器允许的最大打开文件数目

查看ulimit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ulimit -a

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 127567
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 655350
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) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

open files默认是1024,有时候会不够,可以进行修改

临时修改

1
2
3
4
# -H 表示硬限制
# -S 表示软限制
# 如果不加-H和-S则两个一起修改
ulimit -n 655360

永久修改

配置文件在/etc/security/limits.conf

可以进行修改

1
* - nofile 655360

查看某进程的limits

在/proc/${pid}/limits文件中存储着对应pid的limit信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cat /proc/31925/limits 
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 61371 61371 processes
Max open files 1024 4096 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 61371 61371 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us

欢迎关注我的其它发布渠道