• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

MySQL自动停机的问题处理实战记录

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

最近帮别人做的一个项目机器上面跑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自动停机处理内容请搜索极客世界以前的文章或继续浏览下面的相关文章希望大家以后多多支持极客世界!


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
postgresql coalesce函数数据转换方式发布时间:2022-02-08
下一篇:
Oracle判断指定列是否全部为数字的sql语句发布时间:2022-02-08
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap