In linux, you can use ulimit-a to view related messages when modifying the number of files opened by processes. For www.2cto.com 1, the maximum number of files opened by linux by default is 1024. You can view them through ulimit-n. Many system limits can be changed by modifying the/etc/security/limits. conf file. This file has a detailed comment on how to modify it. If you want to change the maximum number of files opened by all user processes to 65536, you can add the following two lines * soft nofile 8192 * hard nofile 8192 to modify only a user or a group, for more information, see file notes. After the modification, the system must be restarted to take effect or ulimit-HSn 8192 www.2cto.com 2. in Linux kernel 2.2.x, run the following command: # echo '123456'>; /proc/sys/fs/file-max # echo '000000'>;/proc/sys/fs/inode-max and add the preceding command to/etc/rc. c/rc. in the local file so that the above values are configured each time the system restarts. 3. in Linux, we can use the ulimit-n command to view the maximum number of file handles that a single process can open (socket connections are included ). The default is 1024. Www.2cto.com is fully enough for general applications (such as Apache and system processes. However, how to process a large number of requests by a single process such as squid, mysql, and java is a little stretched. If the number of file handles opened by a single process exceeds the value defined by the system, the "too program files open" error message will be mentioned. How many file handles are opened by the current process? The following small script can help you view it: lsof-n | awk '{print $2}' | sort | uniq-c | sort-nr | more run the above script as the root user during system access peak hours, possible results: # lsof-n | awk '{print $2}' | sort | uniq-c | sort-nr | more 131 24204 57 24244 57 24231 56 24264 where the first column is the Open File handle quantity, the second column is the process number. After obtaining the process number, we can use the ps command to get the detailed content of the process. Www.2cto.com ps-aef | grep 24204 mysql 24204 24162 99? 00:24:25/usr/sbin/mysqld. It turns out that the maximum number of file handles opened by the mysql process. However, he currently only opens 131 file handles, far from the default 1024. However, if the system concurrency is very large, especially the squid server, it is likely to exceed 1024. At this time, you must adjust the system parameters to adapt to application changes. Linux has hard and soft limits. You can use ulimit to set these two parameters. Run the following command as the root user: In the ulimit-HSn 4096 or above command, H specifies the hard size, and S specifies the soft size, n indicates the maximum number of opened file handles for a single process. I personally think it is best not to exceed 4096. After all, the more open file handles, the slower the response time. After the number of handles is set, the default value is restored after the system restarts. If you want to save it permanently, you can modify the. bash_profile file, and modify/etc/profile to add the above command to the end.