Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Easily solve the MySQL database connection error too many     - Linux system security reinforcement system by masquerading method (Linux)

- MySQL master recovery from failure using binlog (Database)

- To install and use the Doxygen under Linux (Linux)

- Java static code analysis tool Infer (Programming)

- Shell Script: create a function and specify a directory for download (Programming)

- Android imageView in the Src and Background (Programming)

- Based Corosync + Pacemaker + DRBD + LNMP Web server to achieve high availability cluster (Server)

- CentOS 6.5 installation and deployment SVN 1.8.10 (Linux)

- Use FFmpeg processing high quality GIF (Programming)

- Jetty JNDI Development combat (Linux)

- How to use the Linux terminal Git commands (Linux)

- CentOS 6.7 install Nagios Tutorials (Server)

- MongoDB collection data migration to MySQL database (Database)

- WinSCP to transfer text files will automatically convert the format (Linux)

- systemctl Command Complete Guide (Linux)

- Category prevent DoS attacks against Linux (Linux)

- Oracle to create an external table (Database)

- Git version rollback (Linux)

- MySQL master-slave delay problem (Database)

- GNU / Linux system, how to clean up memory space (Linux)

 
         
  Easily solve the MySQL database connection error too many
     
  Add Date : 2018-11-21      
         
         
         
  1, MySQL database system to allow the maximum number of connections max_connections. This parameter can be set. If not set, the default is 100. The maximum is 16384.

2, the current database connection threads threads_connected. This is a dynamic change.

View max_connections, max_connections approach see below.

If when threads_connected == max_connections, the database system can not provide more connections, and then, if the program would like to create a new connection threads, the database system will be rejected if the program did not do much error handling, there will be similar strong altar of error messages.

Because creating and destroying database connection resources, will consume system. And in order to avoid too many open simultaneously at the same time the connection thread, now generally use the so-called programming database connection pool technology.

But the database connection pool, and can not avoid procedural errors caused the connection resource depletion.

This usually occurs in the program failed to release the database connection resources or other causes database connection resources can not be released, but it is estimated that this low intensity system altar programming errors do not occur.

Easy way to check the error is in strong altar refresh the page constantly monitors the changes threads_connected. If max_connections large enough, increasing the value and threads_connected even reach max_connections, so, you should check the program. Of course, if the maximum number of threads connecting a database connection pool, threads_connected growth to the database connection pool use, no longer increase.

Strong altar from the situation of error, the more likely is the database system could not be properly configured. Ask the following piece of advice. for reference

Let your engineers to MySQL's maximum allowable number of connections from the default of 100 tune into 32000. This is not the old problem of excessive connected.

View max_connections

Enter MySQL, use the command:

show variables

View database maximum number of connections to the values:

max_connections

View threads_connected

Enter MySQL, use the command:

show status

View the current activity variable values ​​connecting thread:

threads_connected

Setting max_connections

Approach is set in the my.cnf file, add the following last red line:

[Mysqld]
port = 3306
# Socket = MySQL
skip-locking
set-variable = key_buffer = 16K
set-variable = max_allowed_packet = 1M
set-variable = thread_stack = 64K
set-variable = table_cache = 4
set-variable = sort_buffer = 64K
set-variable = net_buffer_length = 2K
set-variable = max_connections = 32000

After modification, you can restart the MySQL. Of course, in order to ensure the settings are correct, we should look max_connections.

note:

1, although the writing here 32,000. But the maximum number of connections the actual MySQL server allows 16384;

2, in addition to max_connections, the above-mentioned other configuration should be based on their need to configure your system, not rigidly stick to;

3, add the maximum allowable number of connections to the system consumes little increase.

4, if you use the my.ini for mysql configuration file settings similar, but set the format to make some modifications
     
         
         
         
  More:      
 
- CentOS 7.0 Experience with previous versions (Linux)
- Use source packages compiled and installed GCC5.1 in Mac OS X 10.10.3 (Linux)
- Java deserialization test (Programming)
- Linux install Maven and SVN client (Linux)
- Linux 10 useful examples of command-line completion (Linux)
- Python function arguments * args and ** kwargs usage (Programming)
- Struts2 configure a static resource files without Struts processing (regular match) (Programming)
- Composition and dynamic memory allocation C program (Programming)
- MNIST presentation and database conversion (Database)
- SSH does not require a password to log on to a Linux server (Server)
- Ubuntu and Archlinux install Notepadqq 0.50.2 (Linux)
- Ubuntu 14.04 How to set up an SSH without password (Linux)
- Git build a team development environment operating drills (Linux)
- CentOS terminal display Chinese (Linux)
- libnet list of functions (Programming)
- Disk storage structure and file recovery experiment (FAT file system) (Linux)
- Easily create RPM packages using the FPM (Linux)
- Oracle Duplicate build DataGuard (Database)
- Ubuntu users install the video driver Nvidia Driver 334.21 (Linux)
- In addition to wget and curl, what better alternatives (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.