java.io.IOException: Too many open files
How do I increase the maximum number of open files under CentOS Linux? How do I open more file descriptors under Linux?
The ulimit command provides control over the resources available to the shell and/or to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command (login as the root user).
The ulimit command provides control over the resources available to the shell and/or to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command (login as the root user).
Command To List Number Of Open File Descriptors
Use the following command command to display maximum number of open file descriptors:
Output:
cat /proc/sys/fs/file-max
Output:
75000
75000 files normal user can have open in single login session. To see the hard and soft values, issue the command as follows:
# ulimit -Hn
# ulimit -Sn
To see the hard and soft values for httpd or oracle user, issue the command as follows:
# su - username
In this example, su to oracle user, enter:
# su - oracle
$ ulimit -Hn
$ ulimit -Sn
Cambiar valor:
Solo para la sesión:
ulimit -Hn 10240
ulimit -Sn 10240
Permanente mente:
vi /etc/security/limits.conf
add:
root soft nofile 4096
root hard nofile 10240
* soft nofile 4096
* hard nofile 10240
* hard nofile 10240
Recommended Settings
Every deployment may have unique requirements and settings; however, the following thresholds and settings are particularly important for mongod and mongos deployments:
- -f (file size): unlimited
- -t (cpu time): unlimited
- -v (virtual memory): unlimited [1]
- -n (open files): 64000
- -m (memory size): unlimited [1]
- -u (processes/threads): 32000
Always remember to restart your mongod and mongos instances after changing the ulimit settings to make sure that the settings change takes effect.
You can change ulimit settings by issuing a command in the following form:
For many distributions of Linux you can change values by substituting the -n option for any possible value in the output ofulimit -a. See your operating system documentation for the precise procedure for changing system limits on running systems.
Note
After changing the ulimit settings, you must restart the process to take advantage of the modified settings. You can use the /proc file system to see the current limitations on a running process.
Depending on your system’s configuration, and default settings, any change to system limits made using ulimitmay revert following system a system restart. Check your distribution and operating system documentation for more information.
/proc File System
Note
This section applies only to Linux operating systems.
The /proc file-system stores the per-process limits in the file system object located at /proc/<pid>/limits, where<pid> is the process’s PID or process identifier. You can use the following bash function to return the content of the limitsobject for a process or processes with a given name:
You can copy and paste this function into a current shell session or load it as part of a script. Call the function with one the following invocations:
The output of the first command may resemble the following:
Recommended Settings
Every deployment may have unique requirements and settings; however, the following thresholds and settings are particularly important for mongod and mongos deployments:
- -f (file size): unlimited
- -t (cpu time): unlimited
- -v (virtual memory): unlimited [1]
- -n (open files): 64000
- -m (memory size): unlimited [1]
- -u (processes/threads): 32000
Always remember to restart your mongod and mongos instances after changing the ulimit settings to make sure that the settings change takes effect.
[1] | (1, 2) If you limit virtual or resident memory size on a system running MongoDB the operating system will refuse to honor additional allocation requests. |
Comentarios
Publicar un comentario
Incluye información que aporte al tema