Processing math: 100%

centos 7 开启bbr网络加速

Catalogue
  1. 1. 停掉bbr

转载:https://www.gaoxiaobo.com/web/server/131.html

1、查看当前内核

1
uname -r

2、导入ELRepo公钥

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

3、安装ELRepo

1
yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm -y

4、查看ELRepo提供的内核版本

1
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available

5、安装kernel-ml内核,此步安装时间可能比较长,耐心等待并非卡住了

1
2
3
#kernel-lt:表示longterm,即长期支持的内核;当前为4.4.*。
#kernel-ml:表示mainline,即当前主线的内核;当前为5.2.*
yum --disablerepo='*' --enablerepo=elrepo-kernel install kernel-ml -y

6、设置默认启动为新内核

1
grub2-set-default 0

7、启用BBR

1
2
echo 'net.core.default_qdisc=fq' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' >> /etc/sysctl.conf

8、重启系统

1
reboot

9、检查BBR是否成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
验证当前TCP控制算法的命令:
sysctl -n net.ipv4.tcp_congestion_control
返回值一般为
net.ipv4.tcp_available_congestion_control = bbr cubic reno
或者为
net.ipv4.tcp_available_congestion_control = reno cubic bbr


验证BBR是否已经启动
sysctl net.ipv4.tcp_congestion_control
返回值一般为
net.ipv4.tcp_congestion_control = bbr


lsmod | grep bbr
返回值有 tcp_bbr 模块即说明 bbr 已启动。注意:并不是所有的 VPS 都会有此返回值,若没有也属正常。

停掉bbr

1
2
3
4
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf 
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sysctl -p
reboot