Dragon
主机之家测评主机之家测评  2020-07-20 11:19 主机之家测评 隐藏边栏 |   抢沙发  31 
文章评分 0 次,平均分 0.0

CentOS 7/Debian 9 等新内核均已自带 BBR,直接启用,安全。

一、CentOS 7 启用原生Google BBR

(一)更新 CentOS 7 内核为支持 BBR 的内核

1、查看 Centos 内核

uname -r

2、如果低于 4.10,则更新内核

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

3、安装完成后,查看已安装的内核:

rpm -qa | grep kernel

如果看到 kernel-ml-5.3.5-1.el7.elrepo.x86_64 字样的,即是成功。
4、更新开机启动

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

会看到类似这样的

CentOS Linux (5.3.5-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-96820b9851c24560b5f942f2496b9aeb) 7 (Core)

设置 CentOS Linux (5.3.5-1.el7.elrepo.x86_64) 7 (Core)为第一启动顺序(因为启动是从 0 开始计算)

grub2-set-default 0

5、重启系统

reboot

(二)CentOS 7 启用 BBR

1、执行

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
sysctl -p

2、查看内核是否已开启 BBR

sysctl net.ipv4.tcp_available_congestion_control

lsmod | grep bbr

如果均显示 BBR 字样的,表示开启 BBR 成功。

二、Debian 9 启用原生Google BBR

1、修改系统变量

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

2、保存生效

sysctl -p

3、查看内核是否已开启 BBR

sysctl net.ipv4.tcp_available_congestion_control

显示如下内容表示开启:

sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = bbr cubic reno

4、通过上面的操作应该已经启动了 BBR。再看下 BBR 是否启动。

lsmod | grep bbr

显示以下即启动成功:

lsmod | grep bbr
tcp_bbr                20480  14

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

发表评论

扫一扫二维码分享