Update CentOS kernel for deploy Google BBR

BBR (Bottleneck Bandwidth and RTT) is a new congestion control algorithm which is contributed to the Linux kernel TCP stack by Google. With BBR in place, a Linux server can get significantly increased throughput and reduced latency for connections. Besides, it’s easy to deploy BBR because this algorithm requires only updates on the sender side, not in the network or on the receiver side.

#!/usr/bin/env bash
if [ "$(whoami)" != "root" ]; then
SUDO=sudo
fi
if ! $(type lsb_release > /dev/null 2>&1) ; then
${SUDO} yum install -y redhat-lsb-core
fi
majversion=$(lsb_release -rs | cut -f1 -d.)
# Import the ELRepo GPG Key
${SUDO} rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
${SUDO} yum insall -y yum-plugin-fastestmirror
# Install latest kernel using the ELRepo repository:
if [ ${majversion} == 6 ]; then
# CentOS 6
${SUDO} yum install -y https://www.elrepo.org/elrepo-release-6-9.el6.elrepo.noarch.rpm
${SUDO} yum –enablerepo=elrepo-kernel install -y kernel-lt kernel-lt-devel
elif [ ${majversion} == 7 ]; then
# CentOS 7
${SUDO} yum install -y https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
${SUDO} yum –enablerepo=elrepo-kernel install -y kernel-ml kernel-ml-devel
elif [ ${majversion} == 8 ]; then
# CentOS 8
${SUDO} yum install -y https://www.elrepo.org/elrepo-release-8.0-2.el8.elrepo.noarch.rpm
${SUDO} yum –enablerepo=elrepo-kernel install -y kernel-ml kernel-ml-devel
else
echo "Not support version"
exit 1
fi
# Check all entries in the grub2 menu
if [ ${majversion} == 6 ]; then
${SUDO} egrep ^menuentry /etc/grub.conf | cut -f 2 -d \'
# Set the default boot entry
${SUDO} sed -i "s/default=[0-9]/default=0/g" /etc/grub.conf
else
${SUDO} egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
# Set the default boot entry
${SUDO} grub2-set-default 0
fi
# Set BBR TCP congestion control
# Or use zercle's sysctl script
# https://gist.github.com/bouroo/bc52ad58a6e75d44e5235b229e9ca988
echo '# Fallback if BBR not support' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=cubic' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.core.default_qdisc=fq' | ${SUDO} tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_notsent_lowat = 16384' | ${SUDO} tee -a /etc/sysctl.conf
${SUDO} sysctl -p
# After reboot check kernel and remove normal kernel
# uname -a
# if using kernel-ml
# yum remove kernel
exit 0

view raw
centos-ml-kernel.sh
hosted with ❤ by GitHub

โซเชียล

Leave a Reply