From bc58cd043368663eca8cb6141f0cad0251a984ae Mon Sep 17 00:00:00 2001 From: Peng Zhihui Date: Mon, 19 May 2014 16:25:38 +0800 Subject: [PATCH] set swap and memory limit according to the hdware when starting the service modified: install_shell/cgroup-d5000-install/set_libcgroup.sh --- .../cgroup-d5000-install/set_libcgroup.sh | 50 +------------------ 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/install_shell/cgroup-d5000-install/set_libcgroup.sh b/install_shell/cgroup-d5000-install/set_libcgroup.sh index 0775ca6..2b04cd6 100755 --- a/install_shell/cgroup-d5000-install/set_libcgroup.sh +++ b/install_shell/cgroup-d5000-install/set_libcgroup.sh @@ -6,29 +6,7 @@ if [ -z $1 ];then fi #设置cgconfig和cgred服务的配置文件 -total_mem=`free -m | grep -i "mem" | awk '{print $2}'` -total_swap=`free -m | grep -i "swap" | awk '{print $2}'` - -cpus=`cat /proc/cpuinfo | grep processor | wc -l` -((cpus=cpus-2)) -if [ ${cpus} -lt 0 ]; then - cpus=0 -fi - -numa=`numactl --show` -if [ $? -eq 0 ]; then -# memory_nodes=`numactl --hardware | sed -n '1p' | awk '{print $2}'` - memory_nodes=`numactl --hardware | grep "nodes" | awk '{print $4}' | sed -e "s/(//g" | sed -e "s/)//g"` -else - memory_nodes=0 -fi - -#if [ ${memory_nodes} -ne 0 ]; then -# ((memory_nodes--)) -#fi - echo "Starting set the cgconfig.conf..." - cgconfig="group $1_limits { perm { task { @@ -65,35 +43,9 @@ mount { cgrules="$1: * /$1_limits" - if [ ${total_mem} -le 500 ]; then - mem_root=100 - else - mem_root=$((${total_mem}/10)) - if [ ${mem_root} -lt 100 ]; then - mem_root=100 - elif [ ${mem_root} -ge 100 ] && [ ${mem_root} -le 500 ]; then - mem_root=500 - elif [ ${mem_root} -gt 2000 ]; then - mem_root=2000 - fi - fi - - mem=$((${total_mem}-${mem_root})) - swap=$((${total_swap}/2)) - - sed -i "/^[^#]/d" /etc/cgconfig.conf - sed -i "/^$/d" /etc/cgconfig.conf - - echo "$cgconfig" >> /etc/cgconfig.conf - - sed -i "s/var_cpus/${cpus}/g" /etc/cgconfig.conf - sed -i "s/var_nodes/${memory_nodes}/g" /etc/cgconfig.conf - sed -i "s/var_mem/${mem}/g" /etc/cgconfig.conf - sed -i "s/var_swap/$(($mem+$swap))/g" /etc/cgconfig.conf +echo "$cgconfig" > /etc/cgconfig.conf.tmp echo "Starting set cgrules.conf..." - sed -i "/^[^#]/d" /etc/cgrules.conf sed -i "/^$/d" /etc/cgrules.conf - echo "$cgrules" >> /etc/cgrules.conf