Debian/Ubuntu/CentOS手动更换内核并开启BBR拥塞算法

说明

BBRGoogle开源的TCP BBR拥塞控制算法,用于提升网络连接速度,提升空间巨大,优化效果非常明显;
BBR仅支持4.9以上内核Ubuntu 18.04 CentOS 8 Debian 9均为4.9以上内核无需更换内核可以直接开启BBR;

脚本安装

如果不想手动更换可以使用以下一键脚本
BBR 一键脚本:https://sunpma.com/39.html
BBR2 一键脚本:https://sunpma.com/621.html
BBR BBRplus BBR魔改 一键脚本:https://sunpma.com/37.html
内核版本查询:https://kernel.ubuntu.com/~kernel-ppa/mainline

安装内核

更新系统软件包到最新版

apt update && apt upgrade -y

查看系统位数

uname -m

执行后返回x86_64那就是64位系统;如果返回i386或386i686或686那就是32位系统;
下载内核

## 64位系统:

## 4.17.0
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17/linux-headers-4.17.0-041700_4.17.0-041700.201806041953_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17/linux-headers-4.17.0-041700-generic_4.17.0-041700.201806041953_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17/linux-image-unsigned-4.17.0-041700-generic_4.17.0-041700.201806041953_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.17/linux-modules-4.17.0-041700-generic_4.17.0-041700.201806041953_amd64.deb

## 4.19.0
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-headers-4.19.0-041900_4.19.0-041900.201810221809_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-headers-4.19.0-041900-generic_4.19.0-041900.201810221809_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-image-unsigned-4.19.0-041900-generic_4.19.0-041900.201810221809_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-modules-4.19.0-041900-generic_4.19.0-041900.201810221809_amd64.deb

## 5.2.4
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.2.4/linux-headers-5.2.4-050204_5.2.4-050204.201907280731_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.2.4/linux-headers-5.2.4-050204-generic_5.2.4-050204.201907280731_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.2.4/linux-image-unsigned-5.2.4-050204-generic_5.2.4-050204.201907280731_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.2.4/linux-modules-5.2.4-050204-generic_5.2.4-050204.201907280731_amd64.deb

## 5.6.0
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-headers-5.6.0-050600_5.6.0-050600.202003292333_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-headers-5.6.0-050600-generic_5.6.0-050600.202003292333_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-image-unsigned-5.6.0-050600-generic_5.6.0-050600.202003292333_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-modules-5.6.0-050600-generic_5.6.0-050600.202003292333_amd64.deb

## 32位系统:

## 4.19.0
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-headers-4.19.0-041900_4.19.0-041900.201810221809_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-headers-4.19.0-041900-generic_4.19.0-041900.201810221809_i386.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-image-4.19.0-041900-generic_4.19.0-041900.201810221809_i386.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-modules-4.19.0-041900-generic_4.19.0-041900.201810221809_i386.deb

安装内核

dpkg -i *.deb

更新grub系统引导文件

update-grub

重启服务器

reboot

重启后查看系统内核版本,确认是否安装成功

uname -r

CentOS
更换内核

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

yum --enablerepo=elrepo-kernel install kernel-ml -y

查看内核是否安装成功

rpm -qa | grep kernel

更新grub系统引导文件

egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d '

grub2-set-default 0  #default 0表示第一个内核设置为默认运行, 选择最新内核就对了

重启服务器

reboot

开启BBR

删除BBR
为了避免升级内核重复添加BBR开启代码,可以使用以下命令先删除一遍

sed -i '/net.core.default_qdisc=fq/d' /etc/sysctl.conf

sed -i '/net.ipv4.tcp_congestion_control=bbr/d' /etc/sysctl.conf

开启BBR

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf

echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf

使其生效

sysctl -p

查看BBR是否开启成功
执行如下命令,如果返回值中有bbr即说明开启成功

sysctl net.ipv4.tcp_congestion_control

执行如下命令,如果返回值中有tcp_bbr模块,即说明开启成功

lsmod | grep bbr

相关推荐: 使用JSDelivr的全球免费CDN为GitHub提供国内加速服务

前言由于GitHub在国内某些地区无法访问,并且经常出现不稳定的状态,所以在国内体验非常不好;然而jsDelivr在国内却有备案,并且采用了国内CDN加速,所以利用jsDelivr加速GitHub便成了完美的方案;介绍jsDelivr是一个提供含JavaScr…

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 抢沙发

请登录后发表评论