• 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 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. lynis Command Examples in Linux
  2. if Command Examples in Linux
  3. Understanding The /etc/sysconfig Directory
  4. Recommended Configuration of the MySQL Performance Schema
  5. How to Disable IPv6 in CentOS/RHEL 8
  6. chfn Command Examples in Linux
  7. vim: command not found
  8. Linux interview questions – Special permissions (SUID, SGID and sticky bit)
  9. dkms Command Examples in Linux
  10. mkfs.exfat: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright