我正在尝试使用cgroups来限制CPU使用率。我正在使用这个指南 https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/sec-cpu_and_memory-use_case.html
我的/etc/cgconfig.conf文件如下:
mount {
cpu = /mnt/cgroup/cpu,cpuacct;
cpuacct = /mnt/cgroup/cpu,cpuacct;
}
group wheel {
cpu {
cpu.shares="800";
}
cpuacct {
cpuacct.usage="0";
}
}
group test1 {
cpu {
cpu.shares="200";
}
cpuacct {
cpuacct.usage="0";
}
}
我的cgrules.conf文件如下:
@wheel cpu,cpuacct wheel
@test1 cpu,cpuacct test1
尽管我尝试运行:
dd if=/dev/zero of=/dev/null bs=1024k
我看到用户组wheel和test1的CPU使用率达到了100%。
我已经使用以下命令检查了服务: service cgconfig status 并且已启动。
Loaded: loaded (/usr/lib/systemd/system/cgconfig.service; disabled)
Active: active (exited) since Mon 2015-03-02 17:29:19 EET; 7min ago
Process: 1240 ExecStop=/usr/sbin/cgclear -l /etc/cgconfig.conf -e (code=exited, status=3)
Process: 56536 ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664 (code=exited, status=0/SUCCESS)
Main PID: 56536 (code=exited, status=0/SUCCESS)
有人能告诉我我做错了什么吗? 非常感谢
dd if=/dev/zero of=/dev/null bs=1024k
的时候添加top
命令的输出吗? - kirill-acgroup
分享才会限制 CPU 资源。例如,在您的示例中,如果test1
需要 CPU 资源,而wheel
没有使用,则没有竞争,test1
可以获得其需要的资源。如果两者都需要资源,则应该看到基于分享的限制生效。 - twalbergdd
命令。我还在上面放置了top命令的结果。您认为我应该尝试使用另一个命令吗? - SteveGr2015