最近有一台VM上的mariadb总是无故crash,在stackoverflow上搜了一下,发现了一些简单的debug方法。
其实对于大部分的mariadb无故crash来说,基本都是内存满了.
1 先检查mariadb状态, 这个不用说大家都会
systemctl status mariadb
2 如果出现了SIGKILL,那基本上都是OOM Killer干掉了, 那你就可以通过如下命令来查看是哪个process被干掉了
dmesg -T | egrep -i 'killed process'
也可以通过下面的命令来查看全部log
dmesg -T | less
Stackoverflow上的其他辅助回答:
The first is to look at your configuration for your webserver and the database (and presumably there some application tier in here as well) to ensure that they don’t try to use up more RAM than you have available. Since you didn’t tell us about the application server nor the webserver I can’t really advise (but here’s a hint for pre-fork Apache, optionally with PHP). As for Mariadb – go get a copy of mysqltuner.pl and run it against your installation.
That should prevent you running out of memory most of the time, but you should also reduce the amount of non-existent memory the kernel will hand out:
sysctl vm.overcommit_memory=2 sysctl vm.overcommit_ratio=20
and try lower values for the ratio if you are still seeing OOM killer.