如果输入命令docker ps -a,对应的docker退出状态显示为类似下图:
那么一般是由于mysql使用的内存过多,导致系统杀死了对应的进程,具体日志如下:
[root@hwsrv-660820 ~]# dmesg | grep mysql
[2385711.565861] [18140] 999 18140 345829 99076 280 0 0 mysqld
[2385712.140775] Out of memory: Kill process 18140 (mysqld) score 391 or sacrifice child
[2385712.144326] Killed process 18140 (mysqld) total-vm:1383316kB, anon-rss:396304kB, file-rss:0kB, shmem-rss:0kB
[2395985.302167] [21948] 999 21948 349640 101803 287 0 0 mysqld
[2395985.355604] Out of memory: Kill process 21948 (mysqld) score 401 or sacrifice child
[2395985.359331] Killed process 21948 (mysqld) total-vm:1398560kB, anon-rss:407212kB, file-rss:0kB, shmem-rss:0kB
[2439399.422277] [27375] 999 27375 349640 101778 284 0 0 mysqld
[2439399.439670] Out of memory: Kill process 27375 (mysqld) score 401 or sacrifice child
[2439399.443138] Killed process 27375 (mysqld) total-vm:1398560kB, anon-rss:407112kB, file-rss:0kB, shmem-rss:0kB
[2442731.234931] [27807] 999 27807 349640 101851 288 0 0 mysqld
[2442731.274965] Out of memory: Kill process 27807 (mysqld) score 402 or sacrifice child
[2442731.278334] Killed process 27807 (mysqld) total-vm:1398560kB, anon-rss:407404kB, file-rss:0kB, shmem-rss:0kB
可以看到虽然反复启动多次 但不一会儿就自动结束了
解决方法有2种
1.升级服务器内存容量
2.配置mysql,限制其内存占用,具体怎么做可以百度