安装新内核并启用Google BBR教程

本教程基于Cent OS 7,在 Vultr 主机上正常运行。

BBR 是一种新的拥塞控制算法,支持 KVM、Xen 和 VMware,不支持 openVZ VPS,在安装之前,可以使用 virt-what 检测一下主机的虚拟化类型。

google bbr应用与未应用的对比

安装新内核

Google BBR 需要 4.9.0 以上版本的内核,如果已经更新过内核,并且是 4.9.0 以上的版本,可以跳过此步骤。可以使用 uname -r 命令查看内核的版本。如果 VPS 使用的是 4.9.0 以下的版本,可以根据本教程一步一步安装。

安装ELRepo

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,如果出现大于 4.9.0 的内核(教程写于一年前,现在应该是 5.0 以上的内核版本了),就说明安装成功。

kernel-3.10.0-693.2.2.el7.x86_64
kernel-ml-4.13.11-1.el7.elrepo.x86_64
kernel-headers-3.10.0-693.2.2.el7.x86_64
kernel-tools-libs-3.10.0-693.2.2.el7.x86_64
kernel-tools-3.10.0-693.2.2.el7.x86_64
kernel-3.10.0-514.26.2.el7.x86_64
kernel-3.10.0-514.el7.x86_64

启用新内核

运行以下命令:

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

查看输出

CentOS Linux (4.13.11-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux 7 Rescue dc7e1e78eb3e4511ae247fc8b84d2c16 (3.10.0-693.2.2.el7.x86_64)
CentOS Linux (3.10.0-693.2.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-514.26.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-96aa007d97204c57aebfaf6879824e56) 7 (Core)

第一行为0行,看看新内核在第几行,本示例为第0行,所以下面这台命令最后一个参数填0。

grub2-set-default 0

执行 shutdown -r now 重启之后,再运行一下 uname -r 看看新内核是不是已经成功安装并启用。

如果系统为CentOS 6的话,执行以下命令启用新内核:

sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf

启用 Google BBR

运行以下命令启用 Google BBR :

echo 'net.core.default_qdisc=fq' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

接下来就是查看BBR是否启用成功:

输入

sysctl net.ipv4.tcp_available_congestion_control

有类似的输出

net.ipv4.tcp_available_congestion_control = bbr cubic reno

输入

sysctl -n net.ipv4.tcp_congestion_control

输出

bbr

最后检查内核模块是否已加载,输入

lsmod | grep bbr

有类似的输出

tcp_bbr 16384 0

如果三个输入和输出测试都通过了,那么说明 BBR 已成功启用。

扩展阅读:

1、 How to Deploy Google BBR on CentOS 7

2、 TCP BBR congestion control comes to GCP – your Internet just got faster

3、 Google BBR on Github

4、 BBR: Congestion-Based Congestion Control

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>