• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Limit some User Memory Resources on CentOS/RHEL using cgroup

by admin

Question: How to limit user “testme” memory resources, for example, the user “testme” will be only able to get 100mb of memory from the System.

ulimit won’t be able to achieve this goal as ulimit limit user memory consumption per process – in this case, the customer would like to set user “testme” memory quota to 100mb.

1. To achieve simple solution of limiting users memory resources is to do:

# vi /etc/cgconfig.conf

Add there:

group memlimit {
memory {
memory.limit_in_bytes = 104857600;
}
}

Above will create cgroup called memlimit where limit is 100mb

2. Now edit another file:

# vi /etc/cgrules.conf

Add there:

testme memory memlimit/

This will tell cgroups that user testme will be added to memlimit cgroup and will be able to take only 100mb from the system.

3. Restart the cgred and cgconfig service and enable them to start at boot with chkconfig:

# service cgred restart
# service cgconfig restart
# chkconfig cgred on
# chkconfig cgconfig on

Above commands will start cgred/cgconfig and make sure that they will also start on boot of the system. Now user testme should be able to take only 100mb from memory resources.

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Linux Command line Basics – Working with Files and Directories
  2. Understanding Samba utilities – nmblookup, smbstatus, smbtar, testparm, wbinfo, smbget
  3. How to set “max_report_luns” and “max_luns” on CentOS/RHEL 6 to scan more than 512 LUNs
  4. BTRFS: too many missing devices, writeable mount is not allowed
  5. How to Install Apache, MariaDB, and PHP (FAMP) stack on FreeBSD 11
  6. Why Does “netstat” Output Show Many Connections in CLOSE_WAIT Status?
  7. How To Check Current Values for Kernel Tuning Parameters in CentOS/RHEL
  8. Understanding The sysfs File System (/sys) in Linux
  9. How to Check Swap Usage Live via the ‘top’ Command in Linux
  10. Xine Multimedia Software – Play audio and video files in Ubuntu Linux

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright