Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Easily solve the MySQL database connection error too many     - Use Redis as time-series database: why and how (Database)

- Oracle 10g in the unique and index problems (Database)

- RHEL7.0 log system (Linux)

- MySQL my.cnf sql_mode schema modifications (Database)

- NaSC using simple mathematical operations on Ubuntu and Elementary OS (Linux)

- Linux device driver development small example --LED lights (Programming)

- Wireshark basic introduction and learning TCP three-way handshake (Linux)

- MySQL Data Types (Database)

- MySQL Error Code Complete (Database)

- Getting Started with Linux system to learn: how to check the version of SSH on Linux (Linux)

- MySQL monitoring tools -orzdba (Database)

- Java memory analysis tool uses detailed MAT (Programming)

- MySQL 5.6 Open full query log (Database)

- In-depth understanding of capture Node.js garbage collection and memory leaks (Programming)

- Recover Ubuntu 14.04 wakes up from standby in case mouse keyboard appears dead (Linux)

- Java Builder mode (Programming)

- DataGuard add temporary data files bug (Database)

- Hardware Firewall Basics (Linux)

- CentOS7 install JDK (Linux)

- MySQL main and backup replication structures (using mysqld_multi) (Database)

 
         
  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:      
 
- RHEL5.8 physical opportunities to Read-only file system (Linux)
- Ubuntu cut screen method (Linux)
- Ubuntu 15.04 Linux install anti-virus software Antiviral 0.2 (Linux)
- Linux system boot process ARM platforms (Linux)
- C ++ constant definition (Programming)
- Shilpa Nair interview experience sharing RedHat Linux package management (Linux)
- Java Virtual Machine Basics (Programming)
- Android Scroller call mechanism and the relationship of computeScroll (Programming)
- Oracle 11g upgrade PSU detailed steps (Database)
- How to install Git on CentOS 7 (Linux)
- Chkconfig command Detailed service is added and shut down the system in two ways to start service under Linux (Linux)
- GNU / Linux system, how to clean up memory space (Linux)
- Solaris 11 forget the root password (Linux)
- Under CentOS using yum command to install the Task Scheduler crontab (Linux)
- Android and OpenCV2.4.4 build an image processing framework (2013 edition) (Linux)
- Nginx server load balancing dual-system availability (Server)
- Linux Shell Scripting multithreading (Programming)
- Use NTFS-3G to mount NTFS partitions under Linux U disk and removable hard disk (Linux)
- Common data structures and functions of Linux process scheduling (Programming)
- Installation configuration CUDA under Ubuntu 14.04 (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.