cgroup限制内存的脚本(cgroup_mem.sh)如下:
yum install -y libcgroup-tools
echo "group users_mem_limit { memory { memory.limit_in_bytes = ${1}000000000; } }" > /etc/cgconfig.conf
echo "@user_count memory users_mem_limit/" > /etc/cgrules.conf
cgconfigparser -l /etc/cgconfig.conf
cgrulesengd
执行方式: sudo sh cgroup_mem.sh 15 ,表示限制user_count的内存为15G