Linux - 在 CentOS 7 上部署 Google BBR

BBR(Bottleneck Bandwidth and RTT)是一种新的拥塞控制算法,由Google开发。有了BBR,Linux服务器可以显着提高吞吐量并减少连接延迟。

Step 1: Upgrade the kernel using the ELRepo RPM repository

查看当前内核版本:

uname -r

安装 ELRepo 源:

sudo rpm --import <https://www.elrepo.org/RPM-GPG-KEY-elrepo.org>
sudo rpm -Uvh <http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm>

从 ELRepo 源安装最新版内核 :

sudo yum --enablerepo=elrepo-kernel install kernel-ml -y

查看已安装的内核列表:

rpm -qa | grep kernel

显示所有 grub2 menu 项:

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

设置开机默认 grub2 项(上面的菜单列表标记从0开始)

sudo grub2-set-default 0

重启系统:

sudo shutdown -r now

确认内核已经切换到最新版本:

uname -r

Step 2: Enable BBR

修改并保存 sysctl 配置:

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 已启用:

sudo sysctl net.ipv4.tcp_available_congestion_control

如果结果如下,则说明配置成功。

net.ipv4.tcp_available_congestion_control = bbr cubic reno

下一个验证:

sudo sysctl -n net.ipv4.tcp_congestion_control

最后检查内核模块一启用:

lsmod | grep bbr

显示如下:

tcp_bbr                16384  0

Step 3 (optional): Test the network performance enhancement

In order to test BBR's network performance enhancement, you can create a file in the web server directory for download, and then test the download speed from a web browser on your desktop machine.

sudo yum install httpd -y
sudo systemctl start httpd.service
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload
cd /var/www/html
sudo dd if=/dev/zero of=500mb.zip bs=1024k count=500

Finally, visit the URL <http://[your-server-IP]/500mb.zip> from a web browser on your desktop computer, and then evaluate download speed.

参考

How to Deploy Google BBR on CentOS 7

posted @ 2019-02-20 15:24  郑大峰  阅读(529)  评论(0编辑  收藏  举报