今天突然发现网站瘫痪了。
使用命令中的“top”检查 CPU,我发现顶部的 mysqld_Safe 使用了所有的 CPU。
经过谷歌搜索后,我找到了一些不同的解决方案,我进行了“重新启动”,重新启动了所有内容,幸运的是一切都恢复了。
现在是时候找出为什么会发生这种情况并防止它发生。
我检查 mysql 日志并发现:
Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution 140914 13:06:32 [Note] /usr/libexec/mysqld: Normal shutdown 140914 13:06:32 [Note] Event Scheduler: Purging the queue. 0 events 140914 13:06:32 InnoDB: Starting shutdown... 140914 13:06:36 InnoDB: Shutdown completed; log sequence number 0 37356736 140914 13:06:36 [Note] /usr/libexec/mysqld: Shutdown complete 140914 13:06:36 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 140914 13:07:07 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 140914 13:07:08 InnoDB: Initializing buffer pool, size = 8.0M 140914 13:07:08 InnoDB: Completed initialization of buffer pool 140914 13:07:08 InnoDB: Started; log sequence number 0 37356736 140914 13:07:08 [Note] Event Scheduler: Loaded 0 events 140914 13:07:08 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution 141222 00:16:48 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 141222 0:16:49 InnoDB: Initializing buffer pool, size = 8.0M 141222 0:16:49 InnoDB: Completed initialization of buffer pool InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 141222 0:16:49 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... 141222 0:16:53 InnoDB: Started; log sequence number 0 254950608 141222 0:16:53 [Note] Event Scheduler: Loaded 0 events 141222 0:16:53 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
通常它看起来像这样:
Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
140913 23:44:50 [Note] /usr/libexec/mysqld: Normal shutdown
140913 23:44:50 [Note] Event Scheduler: Purging the queue. 0 events
140913 23:44:50 InnoDB: Starting shutdown...
140913 23:44:51 InnoDB: Shutdown completed; log sequence number 0 36460121
140913 23:44:51 [Note] /usr/libexec/mysqld: Shutdown complete
140913 23:44:51 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
140913 23:45:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140913 23:45:18 InnoDB: Initializing buffer pool, size = 8.0M
140913 23:45:18 InnoDB: Completed initialization of buffer pool
140913 23:45:18 InnoDB: Started; log sequence number 0 36460121
140913 23:45:18 [Note] Event Scheduler: Loaded 0 events
140913 23:45:18 [Note] /usr/libexec/mysqld: ready for connections.
这清楚地说明了一件事:它没有正常关闭并且启动了崩溃恢复。
现在我的问题是:
为什么它甚至会关闭并启动?为什么会有这样的“事件”(据我所知?)- 可以禁用它吗?
我该如何防止这次崩溃?如果有任何明确的答案可以解决这个问题。