Linux运维知识之利用cgroup限制instance磁盘io资源使用
小标 2019-03-15 来源 : 阅读 2004 评论 0

摘要:本文主要向大家介Linux运维知识之利用cgroup限制instance磁盘io资源使用绍了,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助。

本文主要向大家介Linux运维知识之利用cgroup限制instance磁盘io资源使用绍了,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助。

Linux运维知识之利用cgroup限制instance磁盘io资源使用

1、安装libcgroup软件包;


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


2、开启服务;


[root@pre-pool1-r6-06-08-18-01 ~]# service cgconfig restart
Stopping cgconfig service:                                 [  OK  ]
Starting cgconfig service:                                 [  OK  ]
[root@pre-pool1-r6-06-08-18-01 ~]# chkconfig cgconfig on

[root@pre-pool1-r6-06-08-18-01 ~]# service cgred restart
Stopping CGroup Rules Engine Daemon...                     [  OK  ]
Starting CGroup Rules Engine Daemon:                       [  OK  ]
[root@pre-pool1-r6-06-08-18-01 ~]# chkconfig cgred on


3、修改配置文件


[root@pre-pool1-r6-06-08-18-01 ~]# 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;
}

group bio-181 {
        blkio {
                blkio.throttle.write_iops_device="";
                blkio.throttle.read_iops_device="";
                blkio.throttle.write_bps_device="252:0 209715200";
                blkio.throttle.read_bps_device="252:0 209715200";
                blkio.reset_stats="";
                blkio.weight="500";
                blkio.weight_device="";
        }
}

[root@pre-pool1-r6-06-08-18-01 ~]# cat /etc/cgrules.conf
# /etc/cgrules.conf
#The format of this file is described in cgrules.conf(5)
#manual page.
#
# Example:
#<user>                <controllers>        <destination>
#@student        cpu,memory        usergroup/student/
#peter                cpu                test1/
#%                memory                test2/
# End of file
*               blkio           bio-181/


4、重启服务


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

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注系统运维Linux频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程