说明
BBR 是 Google 开源的 TCP BBR 拥塞控制算法,用于提升网络连接速度,提升空间巨大,优化效果非常明显; BBRUbuntu 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或386或i686或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