In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "Linux how to modify open files", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Linux how to modify open files" bar!
The default open files of the linux system is 1024. If the program reports an error in too many open files, it is because the number of open files is not enough, so ulimit and file-max need to be modified.
The meaning of file-max. Man proc, you can get a description of file-max:
/ proc/sys/fs/file-maxThis file defines a system-wide limit on the number of open files for all processes. (Seealso setrlimit (2), which can be used by a process to set the per-process limit,RLIMIT_NOFILE, on the number of files it may open. If you get lots of error messagesabout running out of file handles, try increasing this value: that is, file-max sets the total number of files that can be opened by all processes in the system. At the same time, some programs can set the limit of each process through setrlimit call. If you get a lot of error messages about running out of file handles, you should increase this value. That is, this parameter is system-level.
Ulimit
Provides control over the resources available to the shell and to processes started by it, on systems that allow such control. That is, to set the resource limits for the current shell and the processes started by it. Obviously, for the server, both file-max and ulimit need to be set, otherwise the problem of running out of file descriptors may occur.
1. Modify file-max
# echo 6553560 > / proc/sys/fs/file-max# sysctl-w "fs.file-max=34166"
The first two machines will be restored to their default values after restarting the machine.
Or # vim / etc/sysctl.conf adds the following, and the restart takes effect
Fs.file-max = 6553560
two。 Need to change open files
# ulimit-HSn 102400 / / this is only valid on the current terminal. After exiting, open files becomes the default value again. Of course, it can also be written to / etc/profile, because / etc/profile will be executed automatically every time you log in to the terminal.
Or
# vim / etc/security/limits.conf / / add the following configuration and restart will take effect
* soft nofile 65535 * hard nofile 65535
Appendix 1.
To increase the number of open files for a program, you can add the ulimit-HSn 102400 command before the startup script. But when the program is a daemon, this method may not work because there is no terminal.
Appendix 2.
If a service is already started, it is invalid to adjust the ulimit dynamically, especially when it comes to online business.
At this point, you can consider modifying the / proc/' program pid'/limits to achieve dynamic modification.
Thank you for your reading, the above is the content of "how Linux modifies open files". After the study of this article, I believe you have a deeper understanding of how Linux modifies open files, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.