`
san_yun
  • 浏览: 2663947 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

close_wait导致的to many 问题

 
阅读更多


今天发现线上jython load很高,查看jstack,jstat都没有异常情况,本来想通过jmap,结果提示我too many open files,应该是网络链接的问题,发现果然大量close_wait,估计是因为长链接,nginx重启的时候,java这头没有关闭,重启之后搞定。

 

 

 

 

 Too many open files经常在使用linux的时候出现,大多数情况是您的程序没有正常关闭一些资源引起的,所以出现这种情况,请检查io读写,socket通讯等是否正常关闭。

如果检查程序没有问题,那就有可能是linux默认的open files值太小,不能满足当前程序默认值的要求,比如数据库连接池的个数,tomcat请求连接的个数等。。。

查看当前系统open files的默认值,可执行:

[root@pororo script]# 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) 128161
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 800000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 128161
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

 如果发现open files项比较小,可以按如下方式更改:

1. 检查/proc/sys/fs/file-max文件来确认最大打开文件数已经被正确设置。

cat /proc/sys/fs/file-max 

如果设置值太小,修改文件/etc/sysctl.conf的变量到合适的值。这样会在每次重启之后生效。 如果设置值够大,跳过这一步。

echo  2048  > /proc/sys/fs/file-max 

 

编辑文件/etc/sysctl.conf,插入下行:

  1. fs.file-max =  8192  

2. 在/etc/security/limits.conf文件中设置最大打开文件数, 下面是一行提示:

#<domain>  <type>  <item>  <value> 

 

添加如下这行:

  1. * - nofile  8192  

这行设置了每个用户的默认打开文件数为2048。 注意"nofile"项有两个可能的限制措施。就是<type>项下的hard和soft。 要使修改过得最大打开文件数生效,必须对这两种限制进行设定。 如果使用"-"字符设定<type>, 则hard和soft设定会同时被设定。

硬限制表明soft限制中所能设定的最大值。 soft限制指的是当前系统生效的设置值。 hard限制值可以被普通用户降低。但是不能增加。 soft限制不能设置的比hard限制更高。 只有root用户才能够增加hard限制值。

当增加文件限制描述,可以简单的把当前值双倍。 例子如下, 如果你要提高默认值1024, 最好提高到2048, 如果还要继续增加, 就需要设置成4096。

最后用ulimit -a再次查看,open files的值,没什么问题的话,就已经改过来了。

 

 

 

 

  • 大小: 205.6 KB
分享到:
评论

相关推荐

    Mysql错误:Too many connections的解决方法

    MySQL错误“Too many connections”是数据库用户在尝试建立新的连接时遇到的一个常见问题。这个错误表明MySQL服务器已经达到了其允许的最大并发连接数,通常默认设置为100个。当数据库连接未正确关闭,或者应用程序...

    牛津英语7B Unit2练习卷及答案精选.doc

    12. (D) The shop that is **close** to my home is often **closed** at 9:30 p.m. "close"表示“靠近”,"closed"表示“关着的”。 13. (D) The fifth lesson **is** very difficult. 序数词前加"The",且谓语...

    php.ini-development

    To disable this feature set this option to empty value ;user_ini.filename = ; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) ;user_ini.cache_ttl = ...

    微软内部资料-SQL性能优化3

    It is up to the application to define what consistency means, and isolation in some form is needed to achieve consistent results. SQL Server uses locking to achieve isolation. Definition of ...

    牛津英语7B Unit 2练习题及答案精选.doc

    10. 固定搭配:"We can’t wait to see our teacher...",can't wait to do sth.表示迫不及待要做某事。 11. 动词不定式做主语:"It took me two hours to walk to the hospital.",it作形式主语,真正的主语是不定...

    BURNINTEST--硬件检测工具

    - Changed the Memory test to wait for the Video Playback test and 3D test to allow memory allocation for these tests. - Minor changes to the No operation error watchdog timer for the CD and Hard ...

    DbfDotNet_version_1.0_Source

    In Dbf.Net you don't have to write any code, if you don't want to wait for the garbage collector to collect your individual you can call SaveChanges. Dbf.Net ADO.Net Collapse Copy Codevoid ...

    CE中文版-启点CE过NP中文.exe

    Symbolhandler: When the symbolhandler now waits till it's done, it won't wait for the structures to be parsed anymore Additions and Changes: Lua Engine: Added autocomplete DLL injection: On DLL ...

    八下动词练习.pdf

    4. **情态动词**:如"I can’t wait to try the new hat."、"It is impossible for me to tell you everything.",这里的"can't wait to do"表示迫不及待要做某事,"it is impossible for sb. to do"表示某人做某事...

    计算机网络第六版答案

    Many of these data centers are located in, or close to, lower tier ISPs. Therefore, when Google delivers content to a user, it often can bypass higher tier ISPs. What motivates content providers to ...

    GENESIS 2000 DFM PE

    having to wait for the R&D department to deliver. These customized features are not added on as scripts to be interpreted slowly but as fully compiled and integrated functions of the system. Once ...

    EurekaLog_7.5.0.0_Enterprise

    5)....Fixed: Dialog auto-close timer may reset without user input 6)....Fixed: Possible hang when quickly loading/unloading EurekaLog-enabled DLL 7)....Fixed: Possible hang in COM DLLs 8)....Fixed: ...

    UNIX Network Programming Volume 1, Third Edition (Unix网络编程卷1第3版英文版)

    SCTP One-to-Many-Style Streaming Echo Client: main Function Section 10.4. SCTP Streaming Echo Client: str_cli Function Section 10.5. Exploring Head-of-Line Blocking Section 10.6. Controlling ...

    Bochs - The cross platform IA-32 (x86) emulator

    - bugfix: close images on exit - SB16 - converted the sound output module stuff to the new 'soundmod' plugin - SF patches applied [3164945] hack to compile under WIN64 by Darek Mihocka and ...

    数位板压力测试

    The interface gives standard access to as many features as possible, while leaving room for future ex¬ten-sions and vendor-specific customizations. Applications should be able to get the tablet ...

    新冀教版六年级下册小学英语 Unit 4 Again, Please!同步练习课时练(一课一练).docx

    I can't wait to see everyone's smiling faces and make this a memorable day for all of us!" 以上就是对这份小学英语同步练习课时练的详尽解析,涵盖了动词变化、词汇应用和写作实践,旨在帮助学生全面掌握本...

    短文改错.pdf

    15. 并列连词误用:“So it was still too close to the water”中,“So”应改为“Yet”,表示转折。 16. 代词误用:“the men threw away most of his clothes”中,“his”应改为“their”,因为主语是复数。 ...

    九年级英语下册Unit1AsiaWelcometotheunit作业设计新版牛津版202002251118

    5. 介词:"near"或"close to"表示与朋友住得近。 6. 名词:"flat"在此处指公寓楼的单元。 7. 动词:"help"表示王梅乐意帮助别人学习英语。 8. 连词:"but"可以连接两个句子,表示转折,如"Chen Fang does not ...

    英语家庭日常用语.doc

    - "I have told you many times not to do that." 强调重复的警告和规则的重要性。 - "Don’t sit too close to the TV." 关注孩子的视力保护。 - "It’s nothing. It’s just a little cut." 安慰孩子处理小伤。...

Global site tag (gtag.js) - Google Analytics