CGroups内存限制不起作用

我试图限制使用CGroups的LXC容器的内存使用情况,但我不能限制内存。

# lxc-cgroup -n maxdaniel981 memory.limit_in_bytes 134217728 lxc_container: failed to assign '134217728' value to 'memory.limit_in_bytes' for 'maxdaniel981' 

然后我抬头看/proc/cgroups

 # cat /proc/cgroups #subsys_name hierarchy num_cgroups enabled cpuset 2 3 1 cpu 3 3 1 cpuacct 3 3 1 memory 0 1 0 devices 4 3 1 freezer 5 3 1 net_cls 6 3 1 blkio 7 3 1 perf_event 8 3 1 net_prio 6 3 1 

它看起来像禁用了cgroups_memory ,但我启用了/etc/default/grub的内核标志,并使用update-grub

 # cat /etc/default/grub # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="cggroup_enable=memory swapaccount=1" GRUB_CMDLINE_LINUX="cggroup_enable=memory swapaccount=1" 

CGroup像这样挂载在/etc/fstab ;

 cgroup /sys/fs/cgroup cgroup defaults 0 0 

有人可以帮我解决这个问题吗? 我正在使用Debian Jessie,我的内核版本是3.16.0-4-amd64。

在你的GRUBconfiguration中有一个小的错字。 cgroupcggroup应该做的伎俩:

 GRUB_CMDLINE_LINUX_DEFAULT =“cgroup_enable =内存swapaccount = 1”