首先出现这个提示的原因:应用程序打开的文件数量超过了系统设定值。

如何查看当前系统每个用户最大允许打开文件数量:

[root@registry ~]# 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) 3820

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) 3820

virtual memory (kbytes, -v) unlimited

file locks (-x) unlimited

或者

[root@registry ~]# ulimit -n

1024

其中 open files (-n) 1024 表示每个用户最大允许打开的文件数量是1024

#查看一下当前已有的连接数,以此来判断open files 为1024 是否足够

[root@registry ~]# lsof -n |awk '{print$2}'|sort |uniq -c |sort -nr |more

590 5458

445 1065

306 638

267 770

190 5682

189 5457

158 704

130 1194

117 681

81 1263

68 5419

66 640

62 1

60 5677

57 678

55 1067

51 9036

51 1196

48 5698

44 677

44 470

38 494

32 637

29 4430

20 4614

17 9250

14 4566

12 9256

12 9251

11 9254

11 9252

10 9255

10 693

9 9253

3 92

3 9037

3 9033

3 9

3 8964

3 8

3 726

其中第一列是打开的文件句柄数量,第二列是进程id号

通过句柄数量最多的进程,查看是哪个应用程序打开了最多的文件句柄,通过命令:

[root@registry ~]# ps -aef |grep PID

设置open files 数值的方法

1.临时设置方法

[root@registry ~]# ulimit -n 4096

[root@registry ~]# 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) 3820

max locked memory (kbytes, -l) 64

max memory size (kbytes, -m) unlimited

open files (-n) 4096

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) 3820

virtual memory (kbytes, -v) unlimited

file locks (-x) unlimited

这样就可以把当前用户的最大允许打开文件数量设置为4096,但这种设置方法在重启后会还原为默认值。

2.永久设置方法

[root@registry ~]# vim /etc/security/limits.conf

# End of file

root soft nofile 65535

root hard nofile 65535

* soft nofile 65535

* hard nofile 65535

在文件末尾添加上述四行,其中后面两行的 * 表示所有的用户,也可以根据需要设置某一个用户,比如www

# End of file

root soft nofile 65535

root hard nofile 65535

www soft nofile 65535

www hard nofile 65535

注销账户,重新登录即可生效。

如果想查看某个进程最大允许打开的文件数量,可通过如下命令查看:

[root@registry ~]# top

top - 15:39:21 up 101 days, 6:26, 1 user, load average: 0.33, 0.57, 0.52

Tasks: 70 total, 1 running, 69 sleeping, 0 stopped, 0 zombie

%Cpu(s): 6.7 us, 0.0 sy, 0.0 ni, 93.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

KiB Mem : 3881824 total, 111956 free, 3505012 used, 264856 buff/cache

KiB Swap: 2047996 total, 1001156 free, 1046840 used. 123968 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

12872 www 20 0 2738092 743948 2292 S 6.7 19.2 652:05.43 java

1 root 20 0 43380 2244 1352 S 0.0 0.1 4:11.26 systemd

2 root 20 0 0 0 0 S 0.0 0.0 0:00.31 kthreadd

3 root 20 0 0 0 0 S 0.0 0.0 28:18.97 ksoftirqd/0

5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H

7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0

8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh

9 root 20 0 0 0 0 S 0.0 0.0 33:52.08 rcu_sched

10 root rt 0 0 0 0 S 0.0 0.0 0:39.61 watchdog/0

12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs

13 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns

14 root 20 0 0 0 0 S 0.0 0.0 0:07.72 khungtaskd

15 root 0 -20 0 0 0 S 0.0 0.0 0:00.18 writeback

16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd

17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset

18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd

19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md

25 root 20 0 0 0 0 S 0.0 0.0 12:21.57 kswapd0

26 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd

27 root 39 19 0 0 0 S 0.0 0.0 0:17.32 khugepaged

28 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto

36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld

38 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kmpath_rdacd

39 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kpsmoused

40 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ipv6_addrconf

59 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 deferwq

101 root 20 0 0 0 0 S 0.0 0.0 0:03.48 kauditd

225 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff

233 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0

234 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_0

235 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_1

236 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 scsi_tmf_1

240 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ttm_swap

252 root 0 -20 0 0 0 S 0.0 0.0 1:07.64 kworker/0:1H

257 root 20 0 0 0 0 S 0.0 0.0 3:12.26 jbd2/vda1-8

258 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ext4-rsv-conver

325 root 20 0 119080 5460 5316 S 0.0 0.1 5:27.58 systemd-journal

354 root 20 0 44032 8 4 S 0.0 0.0 0:00.08 systemd-udevd

[root@registry ~]# cat /proc/12872/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 65535 65535 processes

Max open files 65535 65535 files

Max locked memory 65536 65536 bytes

Max address space unlimited unlimited bytes

Max file locks unlimited unlimited locks

Max pending signals 15089 15089 signals

Max msgqueue size 819200 819200 bytes

Max nice priority 0 0

Max realtime priority 0 0

Max realtime timeout unlimited unlimited us

linux进程打开链接数,Linux 进程打开最大文件连接数Too many open files相关推荐

  1. Linux进程最大socket数,Linux下高并发socket最大连接数所受的各种限制(详解)

    1.修改用户进程可打开文件数限制 在Linux平台上,无论编写客户端程序还是服务端程序,在进行高并发TCP连接处理时,最高的并发数量都要受到系统对用户单一进程同时可打开文件数量的限制(这是因为系统为每 ...

  2. linux下查看进程的线程数,linux查看进程的线程数

    top -H -p $PID  #查看对应进程的那个线程占用CPU过高 1.top -H 手册中说:-H : Threads toggle 加上这个选项启动top,top一行显示一个线程.否则,它一行 ...

  3. linux 统计端口链接,linux netstat 统计链接数查看外部(转)

    服务器上的一些统计数据: 1)统计80端口链接数 netstat -nat|grep -i "80"|wc -l 2)统计httpd协议链接数 ps -ef|grep httpd| ...

  4. linux 查看ln链接地址,linux ln链接详解

    1.序 Linux具有为一个文件起多个名字的功能,称为链接.被链接的文件可以存放在相同的目录下,但是必须有不同的文件名,而不用在硬盘上为同样的数据重复备份.另外,被链接的文件也可以有相同的文件名,但是 ...

  5. 微信打开链接提示用浏览器打开

    在微信里无法打开下载链接和被封掉的域名,而在浏览器中却可以.那么有没有解决办法呢? 肯定是有的 解决方案:弹出一个遮罩,提示用户在浏览器中打开进行下载或者是打开网页 其实原来很简单,就是判断当前是在微 ...

  6. 微信/QQ中打开链接提示浏览器中打开遮罩

    在微信里无法打开下载链接,而在浏览器中却可以.通过google 发现,原来是微信屏蔽了内置浏览器的下载功能.那么有没有解决办法呢? 解决方案:弹出一个遮罩,提示用户在浏览器中打开进行下载或者是打开网页 ...

  7. linux查看redis链接数,查看redis连接数

    多线程同步工具--LockSupport 用例1:子线程等待主线程发放许可! public static void main(String[] args) { Thread thread = new ...

  8. linux下c 链接mongodb,Linux下mongoDB下载与安装

    百度网盘下载:https://pan.baidu.com/s/1r0JoOtoYzJEC_HOe-NALwg 提取码:rm12 此处提供的是mongodb-linux-x86_64-4.0.11.tg ...

  9. gtk-vnc linux,vncviewer远程链接桌面linux

    1.在服务器上启用vnc (1)查看有没有安装vnc [root@localhost ~]# rpm -qa |grep vnc gtk-vnc-0.3.2-3.el5 vnc-4.1.2-14.el ...

最新文章

  1. 确认了!MySQL 狠甩 Oracle 稳居 Top1!
  2. vuex——做简单的购物车功能
  3. ORACLE MTTR
  4. [渝粤教育] 苏州大学文正学院 网络互联技术与实践 参考 资料
  5. android adb工具linux,Ubuntu Android ADB 使用
  6. bzoj 2843: 极地旅行社
  7. word度量单位无效_【一定要看】这篇Word毕业论文排版全攻略,25个技能请收藏好~...
  8. Redis脚本实现分布式锁
  9. 数据可视化:CSV格式,JSON格式
  10. 利用GDB、KGDB调试应用程序及内核驱动模块
  11. java android开发框架_android开发的三大框架是什么?
  12. visio一分二连接线_Visio-换线流程(初稿)
  13. 计算机维修不是事儿光盘视频,硬盘维修及数据恢复不是事儿配套光盘视频教程...
  14. 制作U盘启动盘 优启通
  15. 2022 年最新博客专家申请流程
  16. Visual Studio快捷键大全
  17. 项目实战:Qt贝塞尔曲线拽托顶点实时显示工具
  18. 元宵佳节,戴铭老师亲自带你分析iOS行业动态!
  19. 十位数连加 c语言,用C语言编写一个简易计算器可实现加减乘除,连加连减,连乖连除....
  20. Exsi上ubuntu虚拟机显卡tesla p100 驱动和cuda踩坑。

热门文章

  1. 听说你想去大厂看学姐,带你看看拼多多运营面经
  2. tableau可视化数据分析60讲(一)-tableau概念性叙述及环境配置
  3. 多少个没收到会收敛_三分历史纪录2973个,库里2483个,库里生涯结束三分会是多少个?...
  4. QT一次性连接多个按钮槽函数
  5. GPU高效通信算法-Ring Allreduce
  6. 面试总结-百度(2)
  7. 【LeetCode从零单排】No121 Best Time to Buy and Sell Stock
  8. c#读取xml中特定节点的值(实例)
  9. 微服务实践分享(2)api网关
  10. jedis连接sentinel示例程序