1安装
yum install libcgroup
/etc/init.d/cgconfig restart
2 默认配置,不用更改
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/<controller>
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;
}
3 使用
限制磁盘IO
建立文件夹
mkdir -p /cgroup/blkio/testlsh
会自动出现很多文件
然后往文件里面追加东西
追加的东西有
1设备号
ls /dev/sda
2进程pid
ps -ef|grep …
echo '8:0 10485760' > /cgroup/blkio/testlsh/blkio.throttle.read_bps_device
echo 30863 > /cgroup/blkio/testlsh/tasks
用iotop看一下,还是没有起作用,原因是
我这里用的是lvm,需要将设备号换成lvm的
查找对应分区的
]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg-lv1 493G 172G 296G 37% /
tmpfs 63G 320K 63G 1% /dev/shm
/dev/sda1 976M 41M 885M 5% /boot
/dev/mapper/vg-lv_data
49T 23T 24T 50% /opt/lv_data
找出vg-lv_data的 设备号
[root@jxq-10-0-0-94 ~]# ls -l /dev/mapper/vg-lv_data
lrwxrwxrwx. 1 root root 7 Mar 15 2016 /dev/mapper/vg-lv_data -> ../dm-2
[root@jxq-10-0-0-94 ~]# ls -l /dev/dm-2
brw-rw—-. 1 root disk 253, 2 Mar 15 2016 /dev/dm-2
[root@jxq-10-0-0-94 ~]#