View and modify the number of file handles opened by a process under Linux

Source: http://blog.csdn.net/kobejayandy/article/details/47128349
https://my.oschina.net/pwd/blog/373092?p=1
Comment: The communication program written, the tomcat startup user cannot log in , and reported Caused by: java.lang.OutOfMemoryError: unable to create new native thread, the problem is caused by the current user file handle setting, the operating system was set to 1024 at that time, and it should be noted that the ulimit view takes effect only after reopening the shell terminal



-- --View the default maximum number of file handles in the Linux system, which is 1024 by default
# ulimit -n
1024
----View the number of file handles opened by a process in the Linux system
# lsof -n | grep 5950 -c
212
---- The method of modifying the maximum number of file handles of the Linux system:
      1) ulimit -n 65535 
            is valid for the current session, and the user exits or the system is reset to restore the default value
      2) Modify the profile file: add in the profile file: ulimit -n 65535
           is only for Valid for a single user
      3) Modify the file: /etc/security/limits.conf , add in the file: (effective immediately - running the ulimit -a command in the current session cannot be displayed)
* soft nofile 32768 #limit the maximum number of file handles for a single process (the system alarms when this limit is reached) 
* hard nofile 65536 #limit the maximum number of single process Number of file handles (the system will report an error when this limit is reached)
 
      4) Modify the file: /etc/sysctl.conf. Add in the file:
fs.file-max=655350 #Limit the maximum number of file handles in the entire system 
      Run the command: /sbin/sysctl -p to make the configuration take effect

----------------
Appendix:
Appendix 1: Centos 6.* can modify /etc/security/limits.d/90-nproc.conf
However, centos 5.* does not have the file 90-nproc.conf, I am here by modifying /etc/security/ limits.conf, add
*soft nproc 65535
*hard nproc 65535 at the end

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326689212&siteId=291194637