记一次mysql宕机

E_WARNING: PDO::prepare(): MySQL server has gone away: PDO::prepare(): MySQL server has gone away
Illuminate\Database\QueryException:SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `***` )



今早发现mysql宕机,并且没有任何异常记录,日志表现为执行 shutdown 命令,但shutdown完成后没有重新启动.

查看案发时间是:2018-04-24T07:04:42

查看/var/log/目录下所有日志

查看各种系统日志都没有发现与案发时间相吻合的记录

最终在 /var/log/alternatives.log 发现如下日志:

update-alternatives 2018-04-24 07:04:40: run with --install /etc/mysql/my.cnf my.cnf /etc/mysql/my.cnf.fallback 100
update-alternatives 2018-04-24 07:04:53: run with --install /etc/mysql/my.cnf my.cnf /etc/mysql/mysql.cnf 200

柳暗花明,接着查看这是谁的日志,通过Google找到 (来源)

/var/log/alternatives.log – Information by the update-alternatives are logged into this log file. On Ubuntu, update-alternatives maintains symbolic links determining default commands.

这是软件的更新记录

然后查看apt更新日志 (/var/log/apt/history.log)

Start-Date: 2018-04-24  07:04:36
Commandline: /usr/bin/unattended-upgrade
Upgrade: mysql-client-5.7:amd64 (5.7.21-0ubuntu0.16.04.1, 5.7.22-0ubuntu0.16.04.1), mysql-server-5.7:amd64 (5.7.21-0ubuntu0.16.04.1, 5.7.22-0ubuntu0.16.04.1), mysql-client-core-5.7:amd64 (5.7.21-0ubuntu0.16.04.1, 5.7.22-0ubuntu0.16.04.1), mysql-common:amd64 (5.7.21-0ubuntu0.16.04.1, 5.7.22-0ubuntu0.16.04.1), mysql-server-core-5.7:amd64 (5.7.21-0ubuntu0.16.04.1, 5.7.22-0ubuntu0.16.04.1)
Error: Sub-process /usr/bin/dpkg returned an error code (1)
End-Date: 2018-04-24  07:04:53

发现的确是因为apt的自动更新导致的mysql shutdown

解决方法:

        1,关闭自动更新(参考文章:http://www.jb51.net/os/Ubuntu/383324.html),

        2,手工启动mysql

猜你喜欢

转载自blog.csdn.net/qq_40312076/article/details/80060966