1、安装libcgroup软件包;

  1. [root@pre-pool1-r6-06-08-18-01 ~]# yum install libcgroup
  2. Loaded plugins: product-id, subscription-manager
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  4. epel | 3.0 kB 00:00
  5. epel/primary_db | 7.9 MB 00:00
  6. rhel-HighAvailability | 3.9 kB 00:00
  7. rhel-HighAvailability/primary_db | 43 kB 00:00
  8. rhel-LoadBalancer | 3.9 kB 00:00
  9. rhel-LoadBalancer/primary_db | 7.0 kB 00:00
  10. rhel-ResilientStorage | 3.9 kB 00:00
  11. rhel-ResilientStorage/primary_db | 47 kB 00:00
  12. rhel-ScalableFileSystem | 3.9 kB 00:00
  13. rhel-ScalableFileSystem/primary_db | 6.8 kB 00:00
  14. rhel-Server | 3.9 kB 00:00
  15. rhel-Server/primary_db | 3.1 MB 00:00
  16. rhel-dvd | 3.9 kB 00:00
  17. rhel-dvd/primary_db | 3.1 MB 00:00
  18. Setting up Install Process
  19. Package libcgroup-0.40.rc1-5.el6.x86_64 already installed and latest version
  20. Nothing to do

2、开启服务;

  1. [root@pre-pool1-r6-06-08-18-01 ~]# service cgconfig restart
  2. Stopping cgconfig service: [ OK ]
  3. Starting cgconfig service: [ OK ]
  4. [root@pre-pool1-r6-06-08-18-01 ~]# chkconfig cgconfig on
  5. [root@pre-pool1-r6-06-08-18-01 ~]# service cgred restart
  6. Stopping CGroup Rules Engine Daemon... [ OK ]
  7. Starting CGroup Rules Engine Daemon: [ OK ]
  8. [root@pre-pool1-r6-06-08-18-01 ~]# chkconfig cgred on

3、修改配置文件

  1. [root@pre-pool1-r6-06-08-18-01 ~]# cat /etc/cgconfig.conf
  2. #
  3. # Copyright IBM Corporation. 2007
  4. #
  5. # Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
  6. # This program is free software; you can redistribute it and/or modify it
  7. # under the terms of version 2.1 of the GNU Lesser General Public License
  8. # as published by the Free Software Foundation.
  9. #
  10. # This program is distributed in the hope that it would be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. # See man cgconfig.conf for further details.
  15. #
  16. # By default, mount all controllers to /cgroup/<controller>
  17. mount {
  18. cpuset = /cgroup/cpuset;
  19. cpu = /cgroup/cpu;
  20. cpuacct = /cgroup/cpuacct;
  21. memory = /cgroup/memory;
  22. devices = /cgroup/devices;
  23. freezer = /cgroup/freezer;
  24. net_cls = /cgroup/net_cls;
  25. blkio = /cgroup/blkio;
  26. }
  27. group bio-181 {
  28. blkio {
  29. blkio.throttle.write_iops_device="";
  30. blkio.throttle.read_iops_device="";
  31. blkio.throttle.write_bps_device="252:0 209715200";
  32. blkio.throttle.read_bps_device="252:0 209715200";
  33. blkio.reset_stats="";
  34. blkio.weight="500";
  35. blkio.weight_device="";
  36. }
  37. }
  38. [root@pre-pool1-r6-06-08-18-01 ~]# cat /etc/cgrules.conf
  39. # /etc/cgrules.conf
  40. #The format of this file is described in cgrules.conf(5)
  41. #manual page.
  42. #
  43. # Example:
  44. #<user> <controllers> <destination>
  45. #@student cpu,memory usergroup/student/
  46. #peter cpu test1/
  47. #% memory test2/
  48. # End of file
  49. * blkio bio-181/

4、重启服务

  1. [root@pre-pool1-r6-06-08-18-01 ~]# /etc/init.d/cgconfig restart
  2. Stopping cgconfig service: [ OK ]
  3. Starting cgconfig service: [ OK ]
  4. [root@pre-pool1-r6-06-08-18-01 ~]# /etc/init.d/cgred restart
  5. Stopping CGroup Rules Engine Daemon... [ OK ]
  6. Starting CGroup Rules Engine Daemon: [ OK ]

5、测试

  1. [root@pre-pool1-r6-06-08-18-01 tmp]# dd if=/dev/zero of=test bs=512M count=100 conv=fdatasync oflag=direct
  2. 100+0 records in
  3. 100+0 records out
  4. 53687091200 bytes (54 GB) copied, 174.73 s, 307 MB/s