在我的 Debian Stretch 上执行此操作后:
sudo apt install cgroup-bin cgroup-tools cgroupfs-mount libcgroup1
我可以发出这个:
sudo systemctl set-property user-1000.slice CPUQuota=40%
我有 4 个 vCPU 主机,每个 CPU 通过“stress -cpu 4”获得 10% 的命中,但重新启动后,我无法再让“CPUQuota”再次工作。
我已经有了"GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory swapaccount=1"
那么如何让 systemd 资源管理在每次重新启动后正常工作而无需重新发布:
sudo apt --reinstall install cgroup-bin cgroup-tools cgroupfs-mount libcgroup1
答案1
这就是我解决问题的方法。 (由于某种原因,安装cgroupfs-mount后,该文件/lib/systemd/system/cgroupfs-mount.service链接到/dev/空.)
sudo apt --reinstall instll cgroupfs-mount
sudo rm /lib/systemd/system/cgroupfs-mount.service
sudo systemctl daemon-reload
现在创建了systemd服务文件:
sudo nano /lib/systemd/system/cgroupfs-mount.service
[Unit]
Description=CGroups FS Mount
[Service]
Type=oneshot
ExecStart=/etc/init.d/cgroupfs-mount start
ExecStop=/etc/init.d/cgroupfs-mount stop
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
创建文件后,发出:
sudo systemctl daemon-reload
检查状态并在引导期间启用启动:
sudo systemctl status cgroupfs-mount
sudo systemctl enable cgroupfs-mount
现在测试:
sudo systemctl set-property user-1000.slice CPUQuota=40%
sudo systemctl daemon-reload