操作系统版本信息:
[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 框架内部的解决方案。