使用cgroup限制普通用户资源

#安装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

 

转载于:https://www.cnblogs.com/water-sky/p/10237172.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值