7

CentOS 7安装TCP BBR

 2 years ago
source link: https://yjyj.net/learn/centos/6204.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CentOS 7安装TCP BBR

2021-05-26

  TCP BBR(Bottleneck Bandwidth and Round-trip propagation time)是由Google设计,于2016年发布的拥塞算法。以往大部分拥塞算法是基于丢包来作为降低传输速率的信号,而BBR则基于模型主动探测。该算法使用网络最近出站数据分组当时的最大带宽和往返时间来创建网络的显式模型。数据包传输的每个累积或选择性确认用于生成记录在数据包传输过程和确认返回期间的时间内所传送数据量的采样率。

  Google在YouTube上应用该算法,将全球平均的YouTube网络吞吐量提高了4%,在一些国家超过了14%。根据实地测试,在部署了最新版内核并开启了 TCP BBR 的机器上,网速甚至可以提升好几个数量级。

  从 4.9 开始,Linux 内核已经用上了该算法,并且对于QUIC可用。如果想在Linux使用BBR,那么首先就是判断内核版本是否大于4.9,如果符合版本标准,那么直接启动BBR就可以了,如果低于4.9,升级内核之后启动就行了。

file
首先将Centos系统更新,更新到7.3版本。

yum update

  查看系统版本,输出的release数值大于7.3即可。

cat /etc/redhat-release

  对于某些机器来说,安装一下wget

yum install wget

  方法1:自动安装,使用一键安装脚本

wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh

  方法2:手动安装

  使用下面命令安装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

  更新grub文件并重启(reboot后,ssh会断开,稍等一会儿重新连接)

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

  开机后查看内核是否已更换为4.9

uname -r

  启动BBR。依次执行下面命令就可以了。

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

  验证bbr是否已经开启

  A,验证当前TCP控制算法的命令:

sysctl net.ipv4.tcp_available_congestion_control

  返回值一般为:net.ipv4.tcp_available_congestion_control = bbr cubic reno 或者为:net.ipv4.tcp_available_congestion_control = reno cubic bbr

  B,验证BBR是否已经启动。

sysctl net.ipv4.tcp_congestion_control

  返回值一般为:net.ipv4.tcp_congestion_control = bbr

lsmod | grep bbr

  返回值有 tcp_bbr 模块即说明 bbr 已启动。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK