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

Posted 柏金斗牛犬

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了中间件服务器内核参数优化相关的知识,希望对你有一定的参考价值。

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:

 

以上是关于中间件服务器内核参数优化的主要内容,如果未能解决你的问题,请参考以下文章

从 TCP/IP 协议谈 Linux 内核参数优化

Linux服务器内核参数优化

linux内核优化参数

linux内核参数优化

从TCP/IP协议谈Linux内核参数优化(值得收藏)

[记录]优化Linux 的内核参数来提高服务器并发处理能力