Optimize or modify the maximum number of CentOS connections
System Environment: CentOS + Keepalived + HAProxy + MariaDB + Galera + MongoDB
When we set up a high-availability server environment, we will encounter a limit on the number of system-level connections, because CentOS sets a limit on the number of connections by default based on the system hardware information, this quantity is often a problem we have encountered. So today we need to modify the default value of the system to meet our requirements and solve the connection problems caused by high concurrency.
Run the following command to view the current maximum number of connections:
[Root @ HA ~] # Ulimit-n1024
Modify the following configuration file:
Edit/etc/security/limits. conf
[Root @ HA ~] # Vi/etc/security/limits. conf
* Soft nofile 65535 * hard nofile 65535 * soft noproc 65535 * hard noproc 65535
Add the preceding content to the configuration file.
Edit/etc/pam. d/login
[Root @ HA ~] # Vi/etc/pam. d/login
Session required pam_limits.so
Add the preceding content to the configuration file.
Save the above, restart the server, and then use ulimit-n
[Root @ HA ~] # Ulimit-n65535