cat /etc/cgconfig.conf
#
# Copyright IBM Corporation. 2007
#
# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See man cgconfig.conf for further details.
#
# By default, mount all controllers to /cgroup/
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
cpuacct = /cgroup/cpuacct;
memory = /cgroup/memory;
devices = /cgroup/devices;
freezer = /cgroup/freezer;
net_cls = /cgroup/net_cls;
blkio = /cgroup/blkio;
}
group shard_0{
blkio{
blkio.throttle.read_iops_device="253:3 16000";
blkio.throttle.write_iops_device="253:3 16000";
blkio.weight="500";
}
}
group shard_1{
blkio{
blkio.throttle.read_iops_device="253:3 16000";
blkio.throttle.write_iops_device="253:3 16000";
blkio.weight="500";
}
}
blkio.throttle.read_iops_device 读iops
blkio.throttle.write_iops_device 写iops
253:3是设备的编号
比如我们要限制进程在flashcache上的iops
[root@test ~]# ls -l /dev/mapper/cachedev
lrwxrwxrwx 1 root root 7 Jan 25 21:16 /dev/mapper/cachedev -> ../dm-3
这里看到只是一个软连接,我们接着找
[root@test~]# ls -l /dev/dm-3
brw-rw---- 1 root disk 253, 3 Jan 25 21:16 /dev/dm-3
因此我们限制某个进程在 flashcache上的iops最高16000就 写成 253:3 16000
启动cgroup
[root@c3-b2c-dba-backend-mysql09 /]# service cgconfig restart
Stopping cgconfig service: [ OK ]
Starting cgconfig service: [ OK ]
然后就可以将进程id写进cgroup 对应的task了
[root@test shard_0]# pwd
/cgroup/blkio/shard_0
[root@test shard_0]# cat tasks
48554
339938
340404
340414
340487
340498
340547
340560
340568
340581
340587
340602
340608
340609
340624
340633
340650
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26250550/viewspace-1417868/ ,如需转载,请注明出处,否则将追究法律责任。