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

The Geek Diary

CONCEPTS | BASICS | HOWTO

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

How to configure resource groups for MySQL Server running on Linux

By admin

The following provides the procedure for configuring and using resource groups under Linux:

1. To use cgroups, you must install the “libcgroup” package on your system:

# yum install libcgroup

2. Create a config file for cgroups:

# vi /etc/cgconfig.conf

mount {
cpu = /cgroup/cpumem;
cpuset = /cgroup/cpumem;
memory = /cgroup/cpumem;
}

# High priority group
group mysqldb {
cpu {
# Allocate the relative share of CPU resources equal to 75%
cpu.shares="750";
}
cpuset {
# No alternate memory nodes if the system is not NUMA
cpuset.mems="0";
# Allocate CPU cores 2 through 5 to tasks in the cgroup
cpuset.cpus="2-5";
}
memory {
# Allocate at most 8 GB of memory to tasks
memory.limit_in_bytes="8G";
# Allocate at most 16 GB of memory+swap to tasks
memory.memsw.limit_in_bytes="16G";
# Apply a soft limit of 4 GB to tasks
memory.soft_limit_in_bytes="4G";
}
}

3. Create a cgroup rules definition file:

# vi /etc/cgrules.conf

# Assign tasks run by the mysql user to mysqldb
mysql cpu,cpuset,memory mysqldb

4. Start the cgconfig service and configure it to start when the system is booted.

$ service cgconfig start
$ chkconfig cgconfig on

5. At this point, the resource group for mysql is ready and in place. Restart mysqld and it will be allowed resources according to the config and rules provided above.

6. You can find and change the resource group limits during runtime as well.

– To find resource limits:

$ cgget -r memory.stat mysqldb

– To set resource limits:

$ cgset -r blkio.throttle.read_bps_device="8:1 0" iocap1

– To save the current modified config for future use:

$ cgsnapshot -s > current_cgconfig.conf

Filed Under: Linux, mysql

Some more articles you might also be interested in …

  1. Linux OS Service ‘squid’
  2. CentOS / RHEL : How to configure alias (virtual interface) of bond interface (bondx:y)
  3. Starting iptables Fails with Error “Another app is currently holding the xtables lock”
  4. What is Soft Links and Hard Links in Linux File System
  5. CentOS / RHEL 7 : Unable To Start The Samba Service
  6. CentOS / RHEL 6 : How to configure kdump
  7. How to resolve the error “-bash: xclock: command not found” in CentOS / RHEL
  8. CentOS / RHEL 6 : How to Change the Volume Group Name for Root Disk Device
  9. How to Find Number of CPU Sockets on a CentOS/RHEL System
  10. Unmounting a Windows Share Fails in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • How to set the default character set in MySQL and how to propagate it in a master-master replication scenario
  • “Connection reset by peer” – error while ssh into a CentOS/RHEL system with a specific user only
  • MySQL: how to figure out which session holds which table level or global read locks
  • Recommended Configuration of the MySQL Performance Schema
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary