Modify the number of openfiles on Linux

Source: Internet
Author: User
In Linux, the default number of openfiles is 1024. sometimes the application reports the Toomanyopenfiles error because the number of openfiles is insufficient. My Linux is CentOS5.6 modification method: www.2cto.com (1) ulimit-HSn102400 this is just...

 

In Linux, the default number of open files is 1024. sometimes the application reports the Too program open files error because the number of open files is insufficient.

I use CentOS 5.6 for Linux.

 

Modification method: www.2cto.com

(1) ulimit-HSn 102400

This is only valid on the current terminal. after exiting, open files becomes the default value.

(2) write ulimit-HSn 102400 to/etc/profile, because/etc/profile is automatically executed every time you log on to the terminal.

(3) for the value of the modified open files to take effect permanently, you must modify the configuration file:/etc/security/limits. conf. after this file, add:

* Soft nofile 102400

* Hard nofile 102400

This method takes effect only after the machine is restarted.

(4) to increase the number of open files of a program, you can add the command in (1) before the startup script. When the program is a daemon, this method may be invalid and there is no terminal.

 

 

PS:

Another kernel parameter that affects the value of open files is file-max, which is the total limit of the Linuxt system. You can view it in the following text:

Cat/proc/sys/fs/file-max

Or

Sysctl-a | grep fs. file-max

 

You can use the following method to modify file-max on the server:

(1) restore to the default value after the machine is restarted

Echo 34166>/proc/sys/fs/file-max

Or

Sysctl-w "fs. file-max = 34166"

(2) modify the configuration file/etc/sysctl. conf and add a line at the end:

Fs. file-max = 34166

Then restart the machine to make it take effect. It will take effect permanently.

From Pig Run

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.