mysql 自动处理_MySQL自动停机怎么办 MySQL自动停机问题处理方法

MySQL自动停机怎么办?本篇文章小编给大家分享一下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%,看了看错误日志,也是空的。

不出意外应该好了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值