0

操作系统版本信息:

[root@localhost system]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

test.slice 的配置如下:

[root@localhost system]# cat test.slice 

[Unit]
Description=Test Slice
Documentation=man:systemd.special(7)
DefaultDependencies=no
Before=slices.target
Wants=-.slice
After=-.slice

[Slice]
CPUAccounting=on
CPUShares=1024

我像这样创建了另一个文件(称为 testhigh.slice)并给它 CPU 份额 = 128。当我在任一切片中启动 CPU 饥饿进程时,我看到 CPU 按比例分配,正如预期的那样。

但是,似乎没有办法实际将一个切片的 CPU 限制为一个常数,例如 10%。systemd无法识别 CPUQuota 选项:

Apr 23 21:34:00 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/test.slice:22] Unknown lvalue 'CPUQuota' in section 'Slice'

原则上,能够精确地分配资源会很棒,但现在我无法让它发挥作用。请帮忙; 如果可能的话,我想要一个来自 systemd 框架内部的解决方案。

4

1 回答 1

0

与 RHEL/Centos 7 一起发布的 systemd 基于版本 208。该 CPUQuota 支持似乎直到 213 才包含在内。

您应该可以通过在所需的切片/范围中运行进程然后直接修改 /sys/fs/cgroup/cpu/ 下的 cpu.cfs_{quota,period}_us 比率来进行实验...我希望您在那里设置任何内容只要没有任何系统活动会导致它重新写入文件,就坚持一段时间。

于 2015-04-24T20:24:43.163 回答