Use cgroups to limit the resource occupation of MySQL Enterprise Backup
Today, I encountered a problem: MySQL Enterprise Backup caused a heavy load on the I/O subsystem, slow application response, and system unavailability. So I want to restrict the mysqlbackup process so that it will not cause more problems.
The mysqlbackup command contains the read, write, and process count settings. The default value is 1 read, 1 write, and 5 threads. Because I use the default settings, there is no need to adjust them.
The ionice tool cannot work because it requires the cfg I/O scheduler.
I found a method in this article. It uses linux cgroups. Previously, when a server on the three platforms was using a very slow CPU, I used cgroups to test the installation of a galera.
# Mkdir/cgroup/blkio
# Mount-t cgroup-o blkio non/cgroup/blkio
# Cgcreate-g blkio:/mysqlbackup
# Ls-lh/dev/mapper/vgdb01-lvdb01
Lrwxrwxrwx 1 root 7 Sep 26/dev/mapper/vgdb01-lvdb01-> ../dm-2
# Ls-lh/dev/dm-2
Brw-rw ---- 1 root disk 253, 2 Sep 26/dev/dm-2
# Cgset-r blkio. throttle. read_iops_device = "253: 2 20" mysqlbackup
# Cgset-r blkio. throttle. write_iops_device = "253: 2 20" mysqlbackup
# Echo $>/cgroup/blkio/mysqlbackup/tasks
# Cat/proc/$/cgroup
1: blkio:/mysqlbackup
# Mysqlbackup -- user = root -- password = xxxxxx -- with-timestamp -- backup-dir =/data/backup
It works exactly the same way as I expected. Read and Write operations are limited to 20 iops.
Later I found it was a storage system problem, so I didn't use this method in the production environment, but I hope this will help others. It may also be useful in other cases.
This article permanently updates the link address: