Centos 6 to Centos 7 cgroups
Solution 1
Please try for example
systemctl set-property user-1000.slice CPUShares=100
Assuming you wish to limit the resource for UID 1000 and limit the CPUShares.
Solution 2
After install : yum install libcgroup-tools commands lscgroup and cg*, files /etc/cg* are available.
Related videos on Youtube
Jesús Carrera
Updated on September 18, 2022Comments
-
Jesús Carrera almost 2 years
I'm trying to set up resource limits per user in Centos 7, but I can't find the right commands for the new implementation of cgroups (I did read the documentation but it talks about restricting services not users).
This are the steps in Centos 6
-
Add to
/etc/cgconfig.conf
group mygroup{ cpu { cpu.shares = 200; } memory { memory.limit_in_bytes = 128m; } }
Restart
service cgconfig restart
- Start in system boot:
chkconfig cgconfig on
- Verify groups added correctly:
lscgroup
-
Add the processes for which we wish to limit resources to the cgroups we created: add to
/etc/cgrules.conf
myuser cpu,memory mygroup/
start the cgred service for the cgrules configuration changes to take effect:
service cgred start
- make sure the cgred service is enabled to start on system boot so that our rules persist across reboots:
chkconfig cgred on
What is the equivalent in Centos 7?
-
Michael Hampton over 8 years
-
c4f4t0r over 8 yearsyou can use the cgroup with systemd
-
Jesús Carrera over 8 years@MichaelHampton I did read that documentation but it talks about restricting services, not users.
-
Jesús Carrera over 8 years@c4f4t0r I have no idea how to use the cgroup with systemd to replicate the steps above
-
-
Jesús Carrera over 8 yearsthat method is considered deprecated and I'd like to know the new recommended way to do it in Centos 7