如何在Debian / Ubuntu中启用CFS cgroup支持

我需要在主机上使用最新的Debian(9)或Ubuntu(17.0.4)来限制Docker容器中的CPU。

$ docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 1 Server Version: 17.06.0-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4 init version: 949e6fa Security Options: seccomp Profile: default Kernel Version: 4.9.20-std-1 Operating System: Ubuntu 17.04 OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 7.753GiB ID: 2JJV:EM37:VCY5:HVKQ:MUNV:VV5N:H247:XE5Q:VBFD:6VES:P62H:YXPJ Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false WARNING: No cpu cfs quota support WARNING: No cpu cfs period support 

我环顾四周,但我还没有想出如何在Debian / Ubuntu上实际启用CFS报价/期限支持。 无论何时我尝试使用–cpus或–cpu-shares,我都会遇到一个错误:

 NanoCPUs can not be set, as your kernel does not support CPU cfs period/quota or the cgroup is not mounted. 

主机运行最新的Ubuntu 4.9.20内核,所以它应该有支持。 在Debian 9上是一样的。有关如何安装cgroup的指示或教程?

请参阅CFS带宽控制上的内核文档

要在内核中启用:

 General setup ---> -*- Control Group support ---> -*- CPU controller ---> -*- Group scheduling for SCHED_OTHER [*] CPU bandwidth provisioning for FAIR_GROUP_SCHED 

警告Emptor:在重新编译和安装不是由发行版提供的内核之前,确保你知道你在做什么。 考虑一下UEFI安全启动,并从当前的.config启动。

Interesting Posts