Trying to use cgroups in debian wheezy and no daemons
Asked Answered
S

2

5

I'm trying to follow guides about cgroups, like this one as example. I'm not really sure to clearly understand how cgroups is supposed to work currently. But I'm sure of one thing: all the guides I find document the usages of /etc/cgconfig.conf and /etc/cgrules.conf. Those files are supposed to be loaded by two daemons which I think should be named cgred and cgconfig.

Under Debian Squeeze, it seems like those two daemons where automatically installed by installing cgroup-bin. But in Wheezy, those daemons do not exist anymore in the package: http://packages.debian.org/fr/wheezy/amd64/cgroup-bin/filelist .

I'm simply trying to create some kind of shared hosting solution and I would like to limit the RAM usage of my users. I was told about cgroups and wanted to try it, but I don't understand how to use that version in Wheezy, and I can't find any documentation to help me.

Could someone tell me what to do? Is that package broken? Is there some completely new (and undocumented) way to configure cgroups?

Sharronsharyl answered 24/1, 2014 at 16:23 Comment(1)
The init-scripts are missing. There is one provided in /usr/share/doc/cgroup-bin/cgred for the cgrulesengined daemon, but it is broken as it is. The other one is probably not a daemon, but just the cgconfigparser that should be run at startup to create your cgroups. When I have a solution, I will likely post it to you here.Loiretcher
L
8

As an alternative to using cgroup-bin look at systemd, it uses cgroups to group/separate processes of users and usage of resource controllers should be fine.

However, in the following I will try to answer your original question on cgroup-bin

Since there are multiple issues with this, I step through:

The init-scripts are missing in the packages. There is however /usr/share/doc/cgroup-bin/examples/cgred which works partially (starts up cgrulesengd for me at system boot, but does not restart the daemon yet). Remove the line sourcing some init-functions that do not exist in debian before using it. You can however also start it via /etc/rc.local.

I have the following cgconfig.conf

mount {
  cpu    = /sys/fs/cgroup ;
  cpuset = /sys/fs/cgroup ;
  memory = /sys/fs/cgroup ;
}

group users {
  memory {
    memory.soft_limit_in_bytes = 512M;
    memory.limit_in_bytes = 1G;
  }

# cpuset seems to be obligatory, adjust the parameters
  cpuset {
    cpuset.cpus = 0-7 ;
    cpuset.mems = 0 ;
  }
}

To load cgconfig.conf execute cgconfigparser -l /etc/cgconfig.conf. You can do this in /etc/rc.local at startup.

Debian disables the memory subsystem by default in the kernel, so you need to activate it if you need it: set the kernel command line in /etc/default/grub to load the memory subsystem: GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory". Call update-grub and reboot.

You should now have a mounted cgroup file system in /sys/fs/cgroup with a users directory inside.

Try cgexec -g memory,cpuset:users <command> and watch the syslog for errors.

Loiretcher answered 28/1, 2014 at 17:8 Comment(0)
H
0

Fully LSB compatible init scripts for cgconfig and cgred can be found here:

https://gist.github.com/divanikus/99d80a04073833ea8389

Hypotrachelium answered 20/3 at 16:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.