Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Red Hat Enterprise Linux 9 Essentials Book now available.

Purchase a copy of Red Hat Enterprise Linux 9 (RHEL 9) Essentials

Red Hat Enterprise Linux 9 Essentials Print and eBook (PDF) editions contain 34 chapters and 298 pages

Preview Book

Chapter 2. Using Control Groups

The easiest way to work with control groups is to install the libcgroup package, which contains a number of cgroup-related command line utilities and their associated man pages. It is possible to mount hierarchies and set cgroup parameters (non-persistently) using shell commands and utilities available on any system. However, using the libcgroup-provided utilities simplifies the process and extends your capabilities. Therefore, this guide focuses on libcgroup commands throughout. In most cases, we have included the equivalent shell commands to help describe the underlying mechanism. However, we recommend that you use the libcgroup commands wherever practical.

Note: Installing the libcgroup package

In order to use cgroups, first ensure the libcgroup package is installed on your system by running, as root:
~]# yum install libcgroup

2.1. The cgconfig Service

The cgconfig service installed with the libcgroup package provides a convenient way to create hierarchies, attach subsystems to hierarchies, and manage cgroups within those hierarchies. We recommend that you use cgconfig to manage hierarchies and cgroups on your system.
The cgconfig service is not started by default on Red Hat Enterprise Linux 6. When you start the service with chkconfig, it reads the control group configuration file — /etc/cgconfig.conf. Control groups are therefore recreated from session to session and become persistent. Depending on the contents of the configuration file, cgconfig can create hierarchies, mount necessary file systems, create control groups, and set subsystem parameters for each group.
The default cgconfig.conf file installed with the libcgroup package creates and mounts an individual hierarchy for each subsystem, and attaches the subsystems to these hierarchies.
If you stop the cgconfig service (with service cgconfig stop), it unmounts all the hierarchies that it mounted.

2.1.1. The cgconfig.conf File

The cgconfig.conf file contains two major types of entry — mount and group. Mount entries create and mount hierarchies as virtual filesystems, and attach subsystems to those hierarchies. For example:
mount {
    cpuset = /cgroup/cpuset;
}
creates a hierarchy for the cpuset subsystem, the equivalent of the shell commands:
        mkdir /cgroup/cpuset
        mount -t cgroup -o cpuset cpuset /cgroup/cpuset
Group entries create control groups and set subsystem parameters. For example:
group daemons/sql {
    perm {
        task {
            uid = root;
            gid = sqladmin;
        } admin {
            uid = root;
            gid = root;
        }
    } cpuset {
        cpuset.cpus = 0-3;
    }
}
creates a control group for sql daemons, with permissions for users in the sqladmin group to add tasks to the control group and the root user to modify subsystem parameters. When combined with the example of the mount entry above, the equivalent shell commands are:
mkdir -p /cgroup/cpu/daemons/sql
chown root:root /cgroup/cpu/daemons/sql/*
chown root:sqladmin /cgroup/cpu/daemons/sql/tasks
echo 0-3 > /cgroup/cpu/daemons/sql/cpuset.cpus
When you install cgroups, a sample config file is written to /etc/cgconfig.conf. The # symbols at the start of each line comment that line out and make it invisible to the cgconfig service.

 
 
  Published under the terms of the Creative Commons License Design by Interspire