Home  >  Article  >  System Tutorial  >  How to modify the maximum open file limit for Linux system users?

How to modify the maximum open file limit for Linux system users?

WBOY
WBOYOriginal
2024-07-19 04:59:42400browse

如何修改 Linux 系统用户最大打开文件限制?

1. Change of file number limit 1. View the maximum open file limit for Linux system users at the user level: #ulimit-n1024(1)vi/etc/security/limits.confmysqlsoftnofile10240mysqlhardnofile10240 where mysql specifies which user’s open file is to be changed number limit. The '*' sign can be used to indicate changing the limit for all users; soft or hard specifies whether to change the soft limit or the hard limit; 10240 specifies the new limit value that you want to change, that is, the maximum number of open files (please note that the soft limit value must be greater than or equal to the hard limit). (2)vi/etc/pam.d/loginsessionrequired/lib/security/pam_limits.so This tells Linux that after the user completes the system login, the pam_limits.so module should be called to set the number of various resources that the system can use for the user. The maximum limit (including the limit on the maximum number of files that a user can open). The pam_limits.so module will read the configuration from the /etc/security/limits.conf file to set this limit value. 2. Check the Linux system’s hard limit on the number of files opened at the same time at the Linux system level: #sysctl-a|grepfile-maxfs.file-max=65535 This indicates that this Linux system allows the maximum number of files opened at the same time (that is, including the total number of files opened by all users) ) 65535 files linux tcp connection limit linux operation and maintenance blog is a Linux system-level hard limit. All user-level limits on the number of open files will not exceed this value.

Generally, this system-level hard limit is the optimal maximum number of simultaneous open files estimated based on the system hardware resource conditions when the Linux system is started. (1)vi/etc/sysctl.conffs.file-max=1000000 takes effect immediately: #sysctl-p 2. Network port limit changes View the maximum number of tracking TCP connections in the Linux system: #sysctl-a|grepipv4.ip_conntrack_maxnet.ipv4.ip_conntrack_max =20000 This indicates that the system will limit the maximum number of tracked TCP connections to 20000 by default. View the Linux system port range: #sysctl-a|grepipv4.ip_local_port_rangenet.ipv4.ip_local_port_range=102430000 Note: Each TCP client connection occupies a unique local port number (this port number is within the local port number range limit of the system) ), if the existing TCP client connection has occupied all local port numbers. New TCP connections will not be created. (1) vi/etc/sysctl.confnet.ipv4.ip_local_port_range=102465535net.ipv4.ip_conntrack_max=20000 If adobe air linux is set according to the above port range, theoretically a single process can complete more than 60,000 TCP clients at the same time. join.

If the above parameters are set, theoretically a single process can complete more than 20,000 TCP client connections at the same time. Note: Set the number of files that mysql users can open at the same time to 10240; set the number of files that the Linux system can open at the same time to 1,000,000 (must be less than the limit on the number of files opened at the same time for users); set the maximum number of TCP connections tracked by the Linux system The number is limited to 20,000 (however, it is recommended to set it to 10,240; because the number of simultaneous open files for mysql users has been limited to 10,240; and a smaller value can save video memory); configure the Linux system port range to 1024~30,000 (you can Supports more than 60,000 connectionsLinux TCP connection limit, not recommended to change; already supports more than 20,000 connections by default); based on the above four points, the number of TCP connections is limited to 10,140. From these 10240 files, we must also remove the standard input, standard output, standard error, server eavesdropping socket, Unix domain socket for inter-process communication and other files that must be opened by each process.

限制连接数的固件_限制连接数有什么用_linux tcp连接数限制

Therefore, when you need to adjust the number of TCP connections, you only need to adjust the ulimit parameter.

限制连接数的固件_限制连接数有什么用_linux tcp连接数限制

Command to view the number and status of tcp connections under Linux:

限制连接数的固件_限制连接数有什么用_linux tcp连接数限制

netstat -n|awk'/^tcp/{++S[$NF]}END{for(ainS)printa,S[a]}'

The above is the detailed content of How to modify the maximum open file limit for Linux system users?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn