How to increase the number of network connections in CentOS

Time:2020-10-27

CentOS uses external access by default, and the total number of TCP links initiated is less than 28232.

It can be calculated by the result of the following command

$ cat /proc/sys/net/ipv4/ip_local_port_range

What I get here is:

32768 60999

The subtraction of the two is equal to 28231, which means that the number of external TCP connections is 28231.

There are several ways to increase the number of available TCP connections:

1. Execute the following command

$ echo "10000 65535" > /proc/sys/net/ipv4/ip_local_port_range

2. Modify configuration file

$ vi /etc/sysctl.conf  

add to: net.ipv4 .ip_ local_ port_ range = 1024 65535

Then execute the following command to reload the configuration

$ sysctl -p 

 

Increase the number of open handles to CentOS: the default number of handles in Linux is 1024 (you can use ulimit – A or ulimit – n to view them)

Make the value of ulimits take effect permanently and modify the configuration file / etc / security/ limits.conf Then add the following:

* soft nofile 65535 
* hard nofile 65535 

At the same time, you need to modify the limit of the total number of open handles in the system (modify / etc/ sysctl.conf )Add the following,Restart

fs.file-max = 6553560

To view the network connection:

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

 

Recommended Today

MySQL tutorial

MySQL tutorial MySQL is the most popular relational database management system. In web application, MySQL is one of the best RDBMS (relational database management system) application software. In this tutorial, you will quickly master the basic knowledge of MySQL, and easy to use MySQL database. What is a database? Database is a warehouse that organizes, […]