Linux: Cgroups Resource Limiting
Jump to navigation
Jump to search
This document describes the process of a basic installation of the arbiter2 tool, that can be used to apply CPU & Memory limits on logged-in Linux users, using cgroups accounting. The official documentation can be found at https://github.com/subfission/arbiter2/blob/master/INSTALL.md
Installing Python
$ sudo yum install python36
Installing external modules
$ python3 -m ensurepip --default-pip $ pip3 install matplotlib toml requests # requests may not be necessary
Acquiring the Arbiter2 source files
$ sudo yum install git # Clone arbiter2 to /etc/arbiter2(recommended) $ git clone https://gitlab.chpc.utah.edu/arbiter2/arbiter2.git optional-destination-directory
Setting up 'arbiter' user to run the script
$ useradd -M -N -r -s /bin/false -c "System account for Arbiter2" arbiter # Create group arbiter $ groupadd arbiter # Add user arbiter to group arbiter $ usermod -a -G arbiter arbiter
Allowing cgroup files to be edited without root via sudo
$ sudo python3 tools/make_sudoers.py -u arbiter -g arbiter > /etc/sudoers.d/arbiter2
Create logs directory
$ mkdir -p arbiter2/logs/`hostname` $ chown arbiter arbiter2/logs/`hostname` $ chmod 773 arbiter2/logs/`hostname` # Make arbiter the owner of cloned arbiter2 directory $ chown -R arbiter /etc/arbiter2
Setup arbiter2 service file
Modify /etc/arbiter2/arbiter2.service file
[Service]
# Username to run the arbiter2 service as. Recommended to run as arbiter.
User=arbiter
# Find arbiter uid with `id -u arbiter`
Slice=user-<ARBITER UID>.slice
# Set arbiter2 directory path
Environment=ARBITER_DIR=/etc/arbiter2
WorkingDirectory=/etc/arbiter2
ExecStart=<python-absolute-path>/python3.6 ${ARBITER_DIR}/arbiter/arbiter.py -g /etc/arbiter2/etc/config.toml -s
# Copy service file to systemd dir $ cp /etc/arbiter2/arbiter2.service /etc/systemd/system/$service