首页 > 其他 > 详细

使用cgroup限制磁盘io读写速率

时间:2020-11-20 15:00:57      阅读:193      评论:0      收藏:0      [点我收藏+]

 

在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

使用cgroup限制磁盘io读写速率

原文:https://www.cnblogs.com/imdba/p/14010458.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!