Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to use cgroups in debian wheezy and no daemons

Tags:

debian

cgroups

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?

like image 300
nicolas-van Avatar asked Jan 24 '14 16:01

nicolas-van


1 Answers

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.

like image 119
Hannes Avatar answered Nov 15 '22 10:11

Hannes