当前位置:网站首页>Aborted connection 1055898 to db:

Aborted connection 1055898 to db:

2022-07-06 11:22:00 wx5caecf2ed0645


mysql In the error log , Find a lot of similar information below :(mysql 5.7.18)

       
[Note] Aborted connection 1055898 to db: 'xxx' user: 'yyy' host: 'xxx.xxx.xxx.xxx' (Got timeout reading communication packets)
  • 1.


such Aborted connection Under the circumstances ,mysql Will increase aborted_clients The value of the status counter . This also means the following questions :

(1) The client is connected normally , But it ended abnormally ( It may be that the program does not close the connection normally )

(2) client sleep More than wait_timeout、 or interactive_timeout Value ( This will cause the connection to be mysql closed )

(3) Client exception terminal , Or the query exceeds max_allowed_packet Value

       
  • 1.

  1. ​mysql> show variables like '%max_allowed_packet%';​
  2. ​+--------------------------+------------+​
  3. ​| Variable_name | Value |​
  4. ​+--------------------------+------------+​
  5. ​| max_allowed_packet | 16777216 |​
  6. ​| slave_max_allowed_packet | 1073741824 |​
  7. ​+--------------------------+------------+​


Of course , It may also be caused by other reasons . To be honest , Abnormal terminals are difficult to diagnose , It may also be with the network 、 Firewall related . Consider the following aspects :

1. If there are a large number of connection processes in sleep State time is long , That means the application is not correct 、 Close the database connection in time . It is strongly recommended to properly close the database connection in the application , Otherwise, we need to rely on mysql Of wait_timeout To close the connection .

2. It is recommended to check max_allowed_packet Value , Ensure that the value is set reasonably , In this way, the client will not receive "packet too large" Message tip . If the setting is unreasonable , The connection will be abnormally disconnected .

3. It is suggested to pay attention to the process time_wait Number . If netstat Found a large number of connections in time_wait state , It indicates that the connection closing problem of the proposed application end adjustment .

       
  • 1.

  1. ​# netstat -ano|grep TIME_WAIT​
  2. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55586 TIME_WAIT timewait (32.97/0/0)​
  3. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55367 TIME_WAIT timewait (27.82/0/0)​
  4. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55776 TIME_WAIT timewait (37.09/0/0)​
  5. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:56505 TIME_WAIT timewait (54.61/0/0)​
  6. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55553 TIME_WAIT timewait (31.94/0/0)​
  7. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:56643 TIME_WAIT timewait (57.73/0/0)​
  8. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55221 TIME_WAIT timewait (23.70/0/0)​
  9. ​tcp 0 0 xxx.xxx.xxx.xxx:10054 xxx.xxx.xxx.xxx:55920 TIME_WAIT timewait (41.18/0/0)​

4. Make sure the transaction is correct 、 Submitted in time .

5. Ensure that there is no abnormal disconnection on the application side , such as php If set max_execution_time=5, Even if you increase connect_timeout The value of will not have an effect . Other programming languages have similar problems .

6. Check DNS Whether there is delay problem in the configuration . Check whether skip_name_resolve, And the use of IP Verify the host instead of using the host name . After setting this parameter , Use ip Verify the host , Instead of using host names . After using this parameter ,mysql In the authorization table host Column must be IP Address or localhost.

7. If it is percona, You can open the audit log .

8. increase net_read_timeout、net_write_timeout Value , And observe whether the error still occurs .net_read_timeout Rarely lead to errors , Unless the network environment is very poor .

The connection to the abnormal terminal is because the connection is not normal .server End will not cause connection abort, Unless the client / There is a network problem on the server . But this is also caused by the network , instead of server End of the problem . Network problems can be viewed with the help of tools , such as :tcpdump,netstat -s



Go back to the problem itself , Have a look first mysql Parameter Settings :

       
  • 1.

  1. ​mysql> show variables like '%timeout%';​
  2. ​+-----------------------------+----------+​
  3. ​| Variable_name | Value |​
  4. ​+-----------------------------+----------+​
  5. ​| connect_timeout | 10 |​
  6. ​| interactive_timeout | 1800 |​
  7. ​| lock_wait_timeout | 31536000 |​
  8. ​| net_read_timeout | 30 |​
  9. ​| net_write_timeout | 60 |​
  10. ​| wait_timeout | 1800 |​
  11. ​+-----------------------------+----------+​
  12. ​mysql> show global variables like '%log_warning%';​
  13. ​+---------------+-------+​
  14. ​| Variable_name | Value |​
  15. ​+---------------+-------+​
  16. ​| log_warnings | 2 |​
  17. ​+---------------+-------+​
  18. ​1 row in set (0.00 sec)​

  19. ​mysql> ​

If log_warnings The value is greater than 1,mysql Similar information will be written to the error log :

       
  • 1.

  1. ​[Warning] Aborted connection 305628 to db: 'db' user: 'dbuser' host: 'hostname' (Got an error reading communication packets)​
  2. ​[Warning] Aborted connection 305627 to db: 'db' user: 'dbuser' host: 'hostname' (Got an error reading communication packets)​

If you don't want to record this information in the log , It can be modified log_waring Value :

       
mysql>set global log_warnings=1;
  • 1.


原网站

版权声明
本文为[wx5caecf2ed0645]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131626548533.html