MySQL自动停机的问题处理实战记录
最近帮别人做的一个项目机器上面跑mysql老是隔一段时间就自动停了。刚开始以为是以外停止,也没注意,就手动再启动。可是过了没两天又停止了。
后来仔细查了查mysqld的日志:
2020-05-27t10:15:12.569342z 0 [system] [my-010116] [server] /usr/libexec/mysqld (mysqld 8.0.17) starting as process 19493
2020-05-27t10:15:14.448256z 0 [system] [my-010229] [server] starting crash recovery...
2020-05-27t10:15:14.475411z 0 [system] [my-010232] [server] crash recovery finished.
2020-05-27t10:15:14.691345z 0 [warning] [my-010068] [server] ca certificate ca.pem is self signed.
2020-05-27t10:15:15.677386z 0 [system] [my-010931] [server] /usr/libexec/mysqld: ready for connections. version: '8.0.17' socket: '/var/lib/mysql/mysql.sock' port: 3306 source distribution.
2020-05-27t10:15:15.951210z 0 [system] [my-011323] [server] x plugin ready for connections. socket: '/var/lib/mysql/mysqlx.sock' bind-address: '::' port: 33060
2020-05-27t11:26:19.955004z 0 [system] [my-010116] [server] /usr/libexec/mysqld (mysqld 8.0.17) starting as process 19757
2020-05-27t11:26:20.181302z 0 [error] [my-012681] [innodb] mmap(137363456 bytes) failed; errno 12
2020-05-27t11:26:20.181360z 1 [error] [my-012956] [innodb] cannot allocate memory for the buffer pool
2020-05-27t11:26:20.181379z 1 [error] [my-012930] [innodb] plugin initialization aborted with error generic error.
2020-05-27t11:26:20.181401z 1 [error] [my-010334] [server] failed to initialize dd storage engine
2020-05-27t11:26:20.181543z 0 [error] [my-010020] [server] data dictionary initialization failed.
2020-05-27t11:26:20.183642z 0 [error] [my-010119] [server] aborting
2020-05-27t11:26:20.184163z 0 [system] [my-010910] [server] /usr/libexec/mysqld: shutdown complete (mysqld 8.0.17) source distribution.
上面显示是cannot allocate memory for the buffer pool
,无法分配内存给缓存池。马上想到是内存不足,这台机器是1gb的内存,还跑着 nginx 和 php-fpm 。
使用 top 看了看 mysqld 占用的内存达到了48% 。内存占用还是蛮高的。
当然了升级机器配置是比较好的办法,但是毕竟经费有限。所以我们先给它加个swap交换空间:
dd if=/dev/zero of=/swapfile bs=1m count=2048 mkswap /swapfile swapon /swapfile systemctl restart mysqld
上面我们加了2gb的交换空间给机器。然后重启 mysqld。再使用top看了看,发现交换空间渐渐被使用了。
睡了一觉起来一看,mysqld服务没有再自动停止,内存占用已经下降到22%,看了看错误日志,也是空的。
嗯,看来还不错嘛。再观察个几天看看,没问题的话应该就好了????????????。
好了,到此这篇关于mysql自动停机的问题处理的文章就介绍到这了,更多相关mysql自动停机处理内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
上一篇: 八皇后问题独立解Python代码
下一篇: Nginx 代理与负载均衡详解