加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

使用cgroup限制普通用户资源

发布时间:2020-12-15 23:04:03 所属栏目:安全 来源:网络整理
导读:#安装cgroup yum install -y libcgroup-tools.x86_64 libcgroup #配置cgconfig vim /etc/cgconfig.conf #增加 group JstormGroup { memory { memory.limit_in_bytes = "85899345920"; memory.swappiness = 0; memory.oom_control = 0; } cpu { cpu.rt_period

#安装cgroup
yum install -y libcgroup-tools.x86_64 libcgroup


#配置cgconfig
vim /etc/cgconfig.conf
#增加
group JstormGroup {
memory {
memory.limit_in_bytes = "85899345920";
memory.swappiness = 0;
memory.oom_control = 0;
}
cpu {
cpu.rt_period_us="1000000";
cpu.rt_runtime_us="0";
cpu.cfs_period_us="100000";
cpu.cfs_quota_us="-1";
cpu.shares="700";
}
}

#配置cgrules
vim /etc/cgrules.conf
#增加
jstorm cpu,memory JstormGroup/

?

systemctl start cgconfig.service
systemctl start cgred.service
systemctl status cgconfig.service
systemctl status cgred.service
systemctl enable cgconfig.service
systemctl enable cgred.service

systemctl restart cgconfig.service
systemctl restart cgred.service

#检查:是否已存在,如果不存在,执行:systemctl restart cgconfig.service systemctl restart cgred.service
ll /sys/fs/cgroup/memory/JstormGroup/memory.usage_in_bytes


注:重启顺序为cgconfig -> cgred ,更改配置文件后两个服务需要重启,且顺序不能错


#启动控制
systemctl status|start|stop|enable|disable cgconfig.service
systemctl status|start|stop|enable|disable cgred.service

运维监控:

#监控已使用内存,换算百分比,/sys/fs/cgroup/memory/JstormGroup/memory.usage_in_bytes#监控最大限制内存/sys/fs/cgroup/memory/JstormGroup/memory.limit_in_bytes

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读