在RHEL 6上Docker Cgroup挂载失败

13

我正在尝试理解一个在Centos+Vagrant上运行正常,在我们提供的RHEL(Red Hat Enterprise Linux Server release 6.5 (Santiago))上却无法工作的问题。执行sudo service docker restart命令时,出现以下信息:

Stopping docker:                                             [  OK  ]
Starting cgconfig service: Error: cannot mount cpuset to /cgroup/cpuset: Device or resource busy
/sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed
Failed to parse /etc/cgconfig.conf                           [FAILED]

Starting docker:                                              [  OK  ]
服务启动还算正常,但是图片无法运行。当我尝试时会显示挂载失败的错误信息。同时,启动日志也会给出一两个警告。关于内核警告,CentOS 给出了相同的警告信息,但并没有出现问题,因为 Epel 应该能够解决这个问题。

The service starts okey enough, but images cannot run. A mounting failed error is shown when I try. And the startup-log also gives a warning or two. Regarding the kernelwarning, centos gives the same and has no problems as Epel should resolve this:

WARNING: You are running linux kernel version 2.6.32-431.17.1.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.8.0.
2014/08/07 08:58:29 docker daemon: 1.1.2 d84a070; execdriver: native; graphdriver:
[1233d0af] +job serveapi(unix:///var/run/docker.sock)
[1233d0af] +job initserver()
[1233d0af.initserver()] Creating server
2014/08/07 08:58:29 Listening for HTTP on unix (/var/run/docker.sock)
[1233d0af] +job init_networkdriver()
[1233d0af] -job init_networkdriver() = OK (0)
2014/08/07 08:58:29 WARNING: mountpoint not found

有人成功地克服了这个问题吗?还是我应该放弃并等待供应商升级到RHEL 7?


也许这更适合在服务器故障问题上提问? - judoole
你最终解决了这个问题吗? - Cam Jackson
1
是的,抱歉没有在这里发布答案@CamJackson。现在已经做到了 :) - judoole
7个回答

7

我有同样的问题。

enter image description here

(1) 检查cgconfig状态

# /etc/init.d/cgconfig status

如果它已停止,请重新启动

# /etc/init.d/cgconfig restart

检查cgconfig是否正在运行

enter image description here

(2) 检查cgconfig是否打开

# chkconfig --list cgconfig

cgconfig 0:off 1:off 2:off 3:off 4:off 5:off 6:off

如果cgconfig处于关闭状态,请将其打开

enter image description here

(3) 如果仍然无法正常工作,则可能缺少某些cgroups模块。在内核 .config 文件中,使用 make menuconfig 添加这些模块到内核中并重新编译和重启

之后,应该正常工作

enter image description here


1
我该如何做(3)?你能详细说明一下吗? - codecowboy
非常有帮助。谢谢! - PRIHLOP
将此更改为被接受的答案,因为它更具描述性并获得了更多的赞同。 - judoole

1

看起来cgconfig服务没有运行,所以请检查一下!

# /etc/init.d/cgconfig status
# mkdir -p /cgroup/cpuacct /cgroup/memory /cgroup/devices /cgroup/freezer net_cls /cgroup/blkio
# cat /etc/cgconfig.conf |tail|grep "="|awk '{print "mount -t cgroup -o",$1,$1,$NF}'>cgroup_mount.sh
# sh ./cgroup_mount.sh
# /etc/init.d/cgconfig restart
# /etc/init.d/docker restart

1

我最终在Google Groups上问了同样的问题,并最终在一些帮助下找到了解决方案。对我有效的是这个:

umount cgroup
sudo service cgconfig start

制作Docker的工程被搁置了。后来出现了容器的网络连接问题,解决起来耗费了太多时间,不得不放弃。

1
是的,我也在那里找到了你的帖子,并尝试了这个解决方案。不幸的是,它对我没有起作用 :( 我得到了 umount: cgroup: not found,接着是 cannot mount cpuset to /cgroup/cpuset: No such file or directory,然后是 error loading /etc/cgconfig.conf(还有其他消息)。完整的日志可以在这里看到(在底部)。该构建实际上是在CentOS上进行的,而不是RHEL。不确定这会有多大的区别。 - Cam Jackson
3
我以为CentOS会更简单,但也许不是这样 :) - judoole
看起来不错!也许在Vagrant上启动一个纯净的CoreOS并尝试同样的操作可能会得到一些答案,或者无论如何看看它是否能正常工作。我之前在尝试部署到Rhel6之前使用过Vagrant中的CoreOS,实际上那个很好用。当然,你也可以直接问他们Docker是否可行 :) - judoole
@CamJackson,你解决了吗?我也遇到了同样的问题。 - ton
@ton 你是指在SnapCI上吗?不是的。我被告知他们还不支持docker,所以现在我只是使用内置的Heroku部署机制。如果将来我真的想构建docker镜像,我可能会在EC2上设置一个GoCD服务器。 - Cam Jackson
显示剩余2条评论

1

1
在我的情况下
/etc/rc.d/rc.cgconfig start

正在生成

启动cgconfig服务:错误:无法将cpu、cpuacct、memory挂载到/cgroup/cpu_and_mem:设备或资源忙 /usr/sbin/cgconfigparser;加载/etc/cgconfig.conf时出错:Cgroup挂载失败 解析/etc/cgconfig.conf失败

我不得不使用:

/etc/rc.d/rc.cgconfig restart

and it automagically unmounted and mounted groups
停止cgconfig服务:启动cgconfig服务:

0

cgconfig服务的启动需要使用mountumount,这需要docker额外提升权限。

查看此处--privileged=true标志以获取更多信息。

我能够通过以下方式解决这个问题:
docker run -it --privileged=true my-image

在Centos6、Centos6.5中测试过。


0
当内核使用 cgroup_disable=memory 启动并且 /etc/cgconfig.conf 包含 memory = /cgroup/memory; 时,会出现这种情况;这将导致仅挂载 /cgroup/cpuset 而非完整集合。
解决方法:从内核启动选项中删除 cgroup_disable=memory 或在 cgconfig.conf 中注释掉 memory = /cgroup/memory;。

很不幸,我现在无法测试这个了,但如果大家认为这是一个更好的选择,我很乐意接受它作为答案。 - judoole
这需要重新启动吗?在内存注释 = /cgroup/memory 对我不起作用。 - codecowboy

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