setup-ipsec-vpn/docs/bbr-zh.md
Leo Liu 63133e1de4
Manual for enabling BBR in zh-cn (#1096)
* Manual for enabling BBR in zh-cn
* Update docs linked to bbr manual
2022-02-03 23:10:25 -06:00

3.1 KiB
Raw Blame History

Google BBR

Google BBR是一种由Google开发的拥塞控制算法它能够显著提升服务器吞吐率并降低延迟。

Google BBR已经被内置于Linux Kernel 4.9及更高版本中,但是需要手动开启。

关于Google BBR算法可以在这篇官方博客或者这个官方库中找到更多信息。

准备

可以通过命令 uname -r 来查看当前Linux Kernel版本。版本大于等于4.9时,可以直接参照下方的说明部署BBR。

通常而言Ubuntu 18.04+, Debian 10+CentOS 8+及RHEL 8+的内核版本都大于4.9。但是对于CentOS 7或者Amazon Linux 2需要通过以下的方式更新内核之后才能部署Google BBR。

Amazon Linux 2

Amazon Linux 2提供过经过验证的新版Linux Kernel并可以通过启用预置的Extras库安装。

  1. 启用 kernel-ng Extras 库
    sudo amazon-linux-extras install kernel-ng
    
  2. 更新包
    sudo yum update
    
  3. 重启系统
    sudo reboot
    
  4. 检查Linux Kernel版本
    uname -r
    

CentOS 7

当使用CentOS 7时需要安装由ELRepo Project提供的新版Linux Kernel。可以在这个页面找到有关ELRepo Project提供的Linux Kernel的更多信息。

以下的安装说明,因为缺少可供参考的中文文档,暂仅提供英文版。

  1. Import ELRepo Project's public key.
    sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
    
  2. Install ELRepo for RHEL-7, SL-7 or CentOS-7.
    sudo yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
    
  3. Install kernel-ml.
    sudo yum --enablerepo=elrepo-kernel install kernel-ml
    
  4. Confirm the result.
    rpm -qa | grep kernel
    
    You should see kernel-ml-xxx in output.
  5. Show all entries in the grub2 menu and setup kernel-ml.
    sudo egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
    
    Indexing starts at 0. For example, when the kernel-ml is located at 1, use the command below to activate kernel-ml.
    sudo grub2-set-default 1
    
  6. Reboot.
    sudo reboot
    
  7. Check Linux kernel version.
    uname -r
    

部署Google BBR

在这个部分我们将通过修改配置文件启动Google BBR。

  1. 备份 /etc/sysctl.conf
    sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup
    
  2. 修改/etc/sysctl.conf
    sudo vim /etc/sysctl.conf
    
    在文件中增加以下行
    net.core.default_qdisc = fq
    net.ipv4.tcp_congestion_control = bbr
    
  3. 启用Google BBR
    sudo sysctl -p
    
  4. 检查Google BBR状态
    sudo sysctl net.ipv4.tcp_available_congestion_control
    # net.ipv4.tcp_available_congestion_control = reno cubic bbr
    sudo sysctl -n net.ipv4.tcp_congestion_control
    # bbr
    lsmod | grep bbr
    # tcp_bbr  16384  0