mysql 5.5 - 数据库定期崩溃(每周 1-2 次)

标签 mysql

我的多个服务器上都遇到了这个问题,现在是 mysql 5.5,但早期版本也存在这个问题。 以前是myisam,现在主要用innodb。

发生的情况是数据库随机关闭。 我正在使用等待这些事件并重新启动数据库的看门狗,但这有时会导致索引损坏,从而导致表无法使用,直到我重建它们。

知道那可能是什么吗?

错误日志文件:

  2018-01-17T06:26:01.736698Z 892611 [Note] Aborted connection 892611 to db: 'user1' user: 'user1' host: 'localhost' (Got an error reading communication packets)
2018-01-17T10:12:01.228074Z 967251 [Note] Aborted connection 967251 to db: 'user1' user: 'user1' host: 'localhost' (Got an error reading communication packets)
2018-01-17T10:48:04.651854Z 893804 [Note] Aborted connection 893804 to db: 'user1' user: 'user1' host: 'localhost' (Got an error reading communication packets)
2018-01-17T11:48:17.152359Z 1138745 [Note] Aborted connection 1138745 to db: 'user1' user: 'user1' host: 'localhost' (Got timeout reading communication packets)
2018-01-17T14:21:21.893942Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 5706ms. The settings might not be optimal. (flushed=2005 and evicted=0, during the time.)
2018-01-17T16:10:04.688262Z 1299954 [Note] Aborted connection 1299954 to db: 'user1' user: 'user1' host: 'localhost' (Got an error reading communication packets)
2018-01-17T18:43:22.859228Z 1394892 [Note] Aborted connection 1394892 to db: 'mail' user: 'mailadm' host: 'localhost' (Got timeout reading communication packets)
2018-01-17T19:23:25.254960Z 1424505 [Note] Access denied for user 'root'@'localhost' (using password: YES)
2018-01-17T19:33:53.296113Z 1430352 [Note] Aborted connection 1430352 to db: 'reading.service' user: 'reading_website' host: 'localhost' (Got an error reading communication packets)
2018-01-17T19:56:01.129085Z 0 [Note] Giving 149 client threads a chance to die gracefully
2018-01-17T19:56:01.130337Z 0 [Note] Shutting down slave threads
2018-01-17T19:56:03.136533Z 0 [Note] Forcefully disconnecting 42 remaining clients

更新:此处是请求的状态

+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Threads_cached    | 11    |
| Threads_connected | 112   |
| Threads_created   | 8916  |
| Threads_running   | 7     |
+-------------------+-------+
4 rows in set (0.04 sec)

mysql>  SHOW GLOBAL VARIABLES LIKE 'thread_%';
+-------------------+---------------------------+
| Variable_name     | Value                     |
+-------------------+---------------------------+
| thread_cache_size | 16                        |
| thread_handling   | one-thread-per-connection |
| thread_stack      | 262144                    |
+-------------------+---------------------------+
3 rows in set (0.01 sec)

mysql> SHOW GLOBAL STATUS LIKE 'uptime%'
    -> ;
+---------------------------+--------+
| Variable_name             | Value  |
+---------------------------+--------+
| Uptime                    | 109176 |
| Uptime_since_flush_status | 109176 |
+---------------------------+--------+
2 rows in set (0.01 sec)

最佳答案

my.cnf/ini [mysqld] 部分要做的事情,

thread_cache_size=100  # from 16 to minimize thread thrashing to support ~ 8000 threads created.

评论https://forge.typo3.org/issues/19050的内容并确保您在适当的时候关闭了连接。由于您的threads_connected为112,并且只有7个正在运行,因此客户端完成时看起来还没有实现。本文档还描述了 PHP(如果涉及 PHP)需要在/etc/php5/cgi/php.ini 概念中设置 MySQL.allow_persistent = Off。

关于mysql 5.5 - 数据库定期崩溃(每周 1-2 次),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48310942/

相关文章:

MySQL如何在没有外键的情况下级联删除

mysql - 删除查询优化

php - mysqli_result 类实际获取的数据存在于何处?

mysql - SQL:在双重多对多关系中查找交集

javascript - 无需重新加载页面即可更新 MySQL

mysql - Mysql在建库中使用 "_"有特殊含义吗?

mysql - SQL 数据库设计|管理者与团队的角色关系

sql - 选择问题

mysql - ElasticSearch 和现有的 MySQL 数据库

php - 如何在 Magento 的低库存系列中只获取已启用的产品