One, the number of files limit modification
1. User Level
To view the maximum open file limit for Linux system users:
# Ulimit-n
1024
(1) vi/etc/security/limits.conf
MySQL Soft nofile 10240
MySQL Hard nofile 10240
Where MySQL specifies the limit on the number of open files to modify for which user.
Use the ' * ' sign to modify the restrictions for all users; soft or hard Specifies whether you want to modify the soft or rigid limit; 10240 Specifies the new limit value that you want to modify, that is, the maximum number of open files (note that the soft limit value is less than or equal to the hard limit).
(2) Vi/etc/pam.d/login
Session required/lib/security/pam_limits.so
This is to tell Linux that after the user completes the system login, the Pam_limits.so module should be called to set the system's maximum limit on the number of resources that the user can use (including the maximum number of files a user can open).
The pam_limits.so module will then read the configuration from the/etc/security/limits.conf file to set these throttling values.
2. Linux system level
See the hard limit on the number of simultaneous open files for Linux systems:
# Sysctl-a|grep File-max
Fs.file-max = 65535
This indicates that this Linux system allows up to 65,535 files to be open at the same time (that is, the total number of open files for all users), the Linux system-level hard limit, and the limit of open files at all user levels will not exceed this number.
Typically, this system-level hard limit is the best maximum number of simultaneous open files that the Linux system calculates at startup, based on the state of the system's hardware resources.
(1) vi/etc/sysctl.conf
Fs.file-max = 1000000
Immediate effect:
# sysctl-p
Second, network port limit Modification
To view the maximum number of tracking TCP connections for Linux systems:
# Sysctl-a | grep Ipv4.ip_conntrack_max
Net.ipv4.ip_conntrack_max = 20000
This indicates that the system will limit the number of TCP connections to maximum traces by default to 20000.
To view the Linux system port range:
# Sysctl-a | grep ipv4.ip_local_port_range
Net.ipv4.ip_local_port_range = 1024 30000
Attention:
Each TCP client connection consumes a unique local port number (this port number is within the system's local port number range limit) If the existing TCP client connection has filled all the local port numbers. You will not be able to create a new TCP connection.
(1) vi/etc/sysctl.conf
Net.ipv4.ip_local_port_range = 1024 65535
Net.ipv4.ip_conntrack_max = 20000
If set according to the above port range, it is theoretically possible for a single process to establish up to 60,000 TCP client connections at the same time.
If set according to the above parameters, it is theoretically possible for a single process to establish a maximum of more than 20,000 TCP client connections at the same time.
Note:
The number of simultaneous open files for MySQL users can be set to 10,240;
Set the number of simultaneous open files for Linux system to 1 million (must be greater than the number of simultaneous open files to the user limit);
Limit the number of TCP connections to maximum tracing for Linux systems to 20,000 (however, the recommended setting is 10240, because the number of simultaneous open files for MySQL users is limited to 10,240, and smaller values save memory);
Configure the Linux system port range to 1024~30000 (can support more than 60,000 connections, do not recommend modification; By default, more than 20,000 connections are supported);
Combined with the above four points, the number of TCP connections is limited to 10,140.
The 10,240 files also have to remove the standard input, standard output, standard error, Server listener socket, and UNIX domain socket for inter-process communication that must be opened by each process.
Therefore, you only need to adjust the Ulimit parameter when you need to adjust the number of TCP connections.
View TCP connections and status commands under Linux:
Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
from:http://blog.csdn.net/duan19056/article/details/51210110
Limitation of TCP maximum connection number under Linux