目前:阿里云服务器默认为:open files (-n) 65535
[root@iZbp16qstyvxjc2nlzquvpZ ~]# 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) 63457
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
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) 63457
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
亚马逊服务器默认为open files: (-n) 1024
[root@localhost ~]# 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) 39188
max locked memory (kbytes, -l) 64
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) 655350
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
备注:
Too many open files
"执行下面命令即可修改最大句柄数为655350:
[root@demo /root]#ulimit -n 655350
但是,这种方法只针对当前进程有效。重新打开一个shell或者开启一个进程,你就会发现参数还是
ulimit -n xx修改之前的数字。
另一种方法就是修改linux系统参数。vi /etc/security/limits.conf
添加:
# End of file
# -----------分割线,上面是配置文件的模板,下面是自己添加的------------------------
* soft nofile 655350 #表示任何一个用户可以打开的最大的文件描述符数量
* hard nofile 655350
* soft nproc 655350 #表示任何一个用户可以打开的最大的进程数
* hard nproc 655350
@student hard nofile 65535 #student组中的任何人最多能打开文件描述符数量是65535,并且会在打开65000个时发出警告
@student soft nofile 65000
"/etc/security/limits.conf" 70L, 3225C
修改以后保存,注销当前用户,重新登录,执行ulimit -a ,ok ,参数生效了:
[root@localhost ~]# 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) 39182
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) 655350
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[root@localhost ~]#
参考文献:
linux最大文件句柄数:https://jinjiajin.net/101.html
注:以上内容仅提供参考和交流,请勿用于商业用途,如有侵权联系本人删除!
如有对思路不清晰或有更好的解决思路,欢迎与本人交流,微信:seesun2012(非紧急项目请加QQ群解答
),QQ群:273557553
你遇到的问题是小编创作灵感的来源!