- 论坛徽章:
- 0
|
如何修改linux内核默认文件描述符最大同时打开数量?
Securing and Optimizing Linux: RedHat Edition -A Hands on Guide
Prev Chapter 6. Linux General Optimization Next
--------------------------------------------------------------------------------
6.9. The file-max parameter
The file-max file /proc/sys/fs/file-max sets the maximum number of file-handles that the Linux kernel will allocate. We generally tune this file to improve the number of open files by increasing the value of /proc/sys/fs/file-max to something reasonable like 256 for every 4M of RAM we have: i.e. for a machine with 128 MB of RAM, set it to 8192 - 128/4=32 32*256=8192.
The default setup for the file-max parameter under Red Hat Linux is: "4096" To adjust the value of file-max to 128 MB of RAM, type the following on your terminal:
[root@deep] /# echo "8192" >;/proc/sys/fs/file-max
Add the above commands to the /etc/rc.d/rc.local script file and you'll not have to type it again the next time your server reboots.
Edit the /etc/sysctl.conf file and add the following line: # Improve the number of open files
fs.file-max = 8192
You must restart your network for the change to take effect. The command to manually restart the network is the following: [root@deep] /# /etc/rc.d/init.d/network restart
Setting network parameters [ OK ] Bringing up interface lo [ OK ] Bringing up interface eth0 [ OK ] Bringing up interface eth1 [ OK ]
: When you regularly receive from your server a lot of messages with errors about running out of open files, you might want to raise this limit. The default value is 4096. A file server or web server needs a lot of open files.
--------------------------------------------------------------------------------
Prev Home Next
The /etc/nsswitch.conf file Up The ulimit parameter
看这里:
http://www.faqs.org/docs/securing/chap6sec72.html |
|