我一直在使用服务单元bellow来启动两个进程,这些进程在运行时碰巧占用了较高的CPU和磁盘带宽。
由于我想要限制的进程没有方法来指示它们应该占用多少资源,所以我一直在使用CGroups来控制它们应该占用多少可用资源。
问题是,如果CGroups失败,系统就会变得没有响应性,需要重新启动,所以我想有一种方法来停止这种情况下的进程。
CGroups的服务单元应该在出现故障时重新启动服务,但由于某些原因,它没有重新启动,这可能是因为系统变得没有响应。
我也没有日志,因为系统由于资源使用率高而关闭,在管理员删除挂起之前,我无法访问这些信息。
[Unit]
Description=HIGH RESOURCES USAGE daemon
After=cgroups.service network.target
[Service]
User=myuser
Group=myuser
ExecStart=/usr/bin/xxxxxxxx
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/xxxxxxxx
WorkingDirectory=/home/myuser
[Install]
WantedBy=multi-user.target[Unit]
Description=Load cgroup configs
After=remote-fs.target
[Service]
Type=forking
ExecStartPre=/bin/echo "Processing /etc/cgconfig.conf..."
ExecStartPre=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf
ExecStartPre=/bin/echo "Processing /etc/cgrules.conf..."
ExecStart=/usr/sbin/cgrulesengd --logfile=/var/log/cgrulesengd.log
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetgroup app_limit {
cpu {
cpu.cfs_quota_us = 200000
cpu.cfs_period_us = 1000000
}
blkio {
blkio.throttle.read_iops_device = "253:0 35";
blkio.throttle.write_iops_device = "253:0 35";
blkio.throttle.write_bps_device = "253:0 262144000";
}
}myuser cpu,blkio app_limit/发布于 2018-11-20 14:31:20
现在看来,您正在尝试使用旧的东西来管理cgroup,而systemd已经将所有的内容都嵌入其中了。不推荐使用cgconfig,系统d运行时不能使用cgconfig。
你应该看看https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html
总之,只要在服务部分中添加精确的重新源控制关键字,并删除cgroup服务单元,您就可以做您想做的事情。
https://serverfault.com/questions/940748
复制相似问题