码迷,mamicode.com
首页 > 其他好文 > 详细

中间件服务器内核参数优化

时间:2019-10-16 13:07:02      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:cat   roc   local   else   page   conf   off   sysctl   max   

Redis:

echo "1" > /proc/sys/vm/overcommit_memory
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
centos_kernel=`uname -r | awk -F "." {print $1$2}`
if [ $centos_kernel == 26 ];then
    echo "kernel_veriosn:" $centos_kernel
    sysctl -w vm.swappiness=0
    cat /etc/sysctl.conf | grep vm.swappiness=
    if [ $? == "0" ];then
        sed -i s/^vm.swappiness.*//g /etc/sysctl.conf
        echo vm.swappiness=0 >> /etc/sysctl.conf
        sed -i /^$/d /etc/sysctl.conf
    else
        echo vm.swappiness=0 >> /etc/sysctl.conf
    fi
elif [ $centos_kernel == 310 ];then
    echo "kernel_veriosn:" $centos_kernel
    sysctl -w vm.swappiness=1
    cat /etc/sysctl.conf | grep vm.swappiness=
    if [ $? == "0" ];then
        sed -i s/^vm.swappiness.*//g /etc/sysctl.conf
        echo vm.swappiness=1 >> /etc/sysctl.conf
        sed -i /^$/d /etc/sysctl.conf
    else
        echo vm.swappiness=1 >> /etc/sysctl.conf
    fi
else
    echo "kernel_veriosn:" $centos_kernel
    exit 1
fi
over_memory=`cat /proc/sys/vm/overcommit_memory`
echo "overcommit_memory:" $over_memory
defrag=`cat /sys/kernel/mm/transparent_hugepage/defrag`
echo "defrag:" $defrag
cat /etc/sysctl.conf | grep vm.swappiness=

ES:

cat /etc/sysctl.conf | grep "vm.max_map_count" 
if [ $? -ne 0 ];then
    sudo sed -i s/^vm.max_map_count.*//g /etc/sysctl.conf
    sudo echo "vm.max_map_count=262144" >> /etc/sysctl.conf
    sudo sed -i /^$/d /etc/sysctl.conf
fi

cat /etc/sysctl.conf | grep "vm.swappiness" 
if [ $? -ne 0 ];then
    sudo sed -i s/^vm.swappiness.*//g /etc/sysctl.conf
    suso echo vm.swappiness=0 >> /etc/sysctl.conf
    sudo sed -i /^$/d /etc/sysctl.conf
fi
sudo echo "*    soft    nproc    524288" >> /etc/security/limits.d/90-nproc.conf
sudo swapoff -a
sudo sh -c "echo ‘swapoff -a‘ >>/etc/rc.local"
sudo sysctl -p

Kafka:

 

中间件服务器内核参数优化

标签:cat   roc   local   else   page   conf   off   sysctl   max   

原文地址:https://www.cnblogs.com/lwhctv/p/11684547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!