Docker容器无法使用MySQL Docker镜像启动

4
我使用带有mysql官方镜像的docker容器来创建超过11个数据库容器(container1到container11)。设置完成后,所有容器都正常运行,直到container9。在container10上,它只能启动约1分钟,然后再次停止。使用docker日志检查容器,但我没有看到任何内容。停止container9,然后重新启动container10。它再次运行良好。这种情况似乎只会发生在我有9个mysql容器并尝试提高第10个容器时。如果我停止其中一个,然后再次启动它,那么就没有问题。这是一个bug吗?还是我遗漏了docker桥接的某些设置?
root@ec8dcb82f64d:/dev/shm# docker restart f4801b57c4cc
f4801b57c4cc
root@ec8dcb82f64d:/dev/shm# docker ps -a | grep f4801b57c4cc
f4801b57c4cc        mysql/mysql-server:5.7             "/entrypoint.sh my..."   2 weeks ago         Exited (1) 3 seconds ago                                                             db
root@ec8dcb82f64d:/dev/shm# docker logs f4801b57c4cc
Initializing database
Database initialized
MySQL init process in progress...
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.

/entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*


MySQL init process done. Ready for start up.

root@ec8dcb82f64d:/dev/shm#

你的系统有多少内存? - Tarun Lalwani
是的,当我在我的AWS EC2上启动Docker时也会发生这种情况。 - jacobcan118
我在/dev下有大约32G的可用空间,在/run下有6.3G,在/下有404G。 - jacobcan118
以调试模式运行您的Docker守护程序并获取服务日志。 - Tarun Lalwani
让我们在聊天中继续这个讨论 - jacobcan118
显示剩余3条评论
2个回答

15

虽然我不太理解发生了什么,但经过一周的尝试,我认为我找到了解决方案。以下是我所尝试的内容,目前为止我可以启动20个mysql容器而没有任何问题。

1:尝试创建一个用于测试的虚拟mysql容器。

$ docker run -e MYSQL_ROOT_PASSWORD=password mysql
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
...
Initializing database
2017-08-09T17:58:30.034595Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-09T17:58:30.039274Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2017-08-09T17:58:30.039294Z 0 [Warning] InnoDB: io_setup() attempt 1.
2017-08-09T17:58:30.539495Z 0 [Warning] InnoDB: io_setup() attempt 2.
2017-08-09T17:58:31.039701Z 0 [Warning] InnoDB: io_setup() attempt 3.
2017-08-09T17:58:31.539902Z 0 [Warning] InnoDB: io_setup() attempt 4.
2017-08-09T17:58:32.040115Z 0 [Warning] InnoDB: io_setup() attempt 5.
2017-08-09T17:58:32.540330Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2017-08-09T17:58:32.540378Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2017-08-09T17:58:32.540390Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-08-09T17:58:32.540401Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-08-09T17:58:32.540408Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-08-09T17:58:32.540412Z 0 [ERROR] Failed to initialize plugins.
2017-08-09T17:58:32.540415Z 0 [ERROR] Aborting

并且遇到了 io_setup() 失败,错误代码为 EAGAIN

2:检查 aio-max-nr 的当前值

$ sysctl fs.aio-max-nr
fs.aio-max-nr = 65536

3:将aio-max-nr的值增加到2097152

$ sudo sysctl -w fs.aio-max-nr=2097152

3:启动mysql服务

4:尝试创建更多的mysql容器并且没有问题地运行原始容器


你刚刚救了我的命!非常感谢! - Jim Bantanis-Kapirnas

0
在后台运行docker events,然后尝试启动第10个容器。你肯定会看到出了什么问题。以下是一个启动已退出容器并在启动时出错的示例。按照以下命令顺序执行:
~$ sudo docker events &
[1] 9414

~$ sudo docker start 48137950f1b7
2017-08-03T00:01:18.971406558+05:30 network connect c79096ff0fef046d24b2a23907b3cc82c4df0838db2475909f8fa9f796a0418e (container=48137950f1b714797143529d63ec7221d3cbcd38bb6c8d20a241b06ddbd3d27a, name=bridge, type=bridge)
2017-08-03T00:01:19.305063392+05:30 container start 48137950f1b714797143529d63ec7221d3cbcd38bb6c8d20a241b06ddbd3d27a (image=ubuntu, name=modest_northcutt)
48137950f1b7
2017-08-03T00:01:19.305915636+05:30 container die 48137950f1b714797143529d63ec7221d3cbcd38bb6c8d20a241b06ddbd3d27a (exitCode=0, image=ubuntu, name=modest_northcutt)

希望你能够想出来。

网络连接 0303...dec (容器=<容器 ID>,名称=bridge,类型=bridge) 挂载卷 5a...117 (容器=<容器 ID>,目标=/var/lib/mysql,驱动程序=local,传播方式=,读/写=true) 启动容器 <容器 ID> (镜像=mysql/mysql-server:5.7,名称=<容器名称>) 停止容器 <容器 ID> (退出代码=1,镜像=mysql/mysql-server:5.7,名称=<容器名称>) 断开网络连接 0303...dec (容器=<容器 ID>,名称=bridge,类型=bridge) 卸载卷 5a...117 (容器=<容器 ID>,驱动程序=local) 除了所有进程,我看不到任何进一步的信息 - jacobcan118

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接