在MySQL innobackupex全备期间,磁盘io基本被打满,设置过 --throttle效果不明显,
--throttle=# This option specifies a number of I/O operations (pairs of read+write) per second. It accepts an integer argument. It is passed directly to xtrabackup‘s --throttle option.
以下是使用cgroup方式进行io读写的限制测试
【centos6】
yum install libcgroup
service cgconfig start
【centos7】
yum install -y libcgroup-tools.x86_64
systemctl start cgconfig
disk_name=‘/dev/vdb‘
io_read_limit=1048576
io_write_limit=1024
#创建控制组
cgcreate -g blkio:test_read
cgcreate -g blkio:test_write
#设置io读取限制策略绑定在指定的磁盘驱动号上
disk_id=$(ls -l ${disk_name} | awk ‘{print $5,$6}‘ | sed ‘s/ //g‘ | tr ‘,‘ ‘:‘)
cgset -r blkio.throttle.read_bps_device="${disk_id} ${io_read_limit}" test_read
cgset -r blkio.throttle.write_bps_device="${disk_id} ${io_write_limit}" test_write
#确认配置的限制策略
cgget -r blkio.throttle.read_bps_device test_read
cgget -r blkio.throttle.write_bps_device test_write
#读测试对比
dd if=/dev/vdb of=/dev/null
cgexec -g blkio:test_read dd if=/dev/vdb of=/dev/null
#写测试对比
dd if=/dev/zero of=/data/testfile bs=512 count=100000 oflag=dsync
cgexec -g blkio:test_write dd if=/dev/zero of=/data/testfile bs=1024 count=1000 oflag=dsync
#把正在执行的进程添加到限制策略里
#比如正在执行的dd命令对应的pid是5306
cgclassify -g blkio:test_write 5306
原文:https://www.cnblogs.com/imdba/p/14010458.html