BBR加速 Centos
BBR是什么
BBR 是 Google 提出的一种新型拥塞控制算法,可以使 Linux 服务器显著地提高吞吐量和减少 TCP 连接的延迟。
BBR项目地址
https://github.com/google/bbr
手动安装,升级内核
开启 BBR 要求 4.10 以上版本 Linux 内核,可使用如下命令查看当前内核版本
uname -r
3.10.0-514.10.2.el7.x86_64
如果当前内核版本低于 4.10,可使用 ELRepo 源更新:
https://elrepo.org/tiki/tiki-index.php
- 导入公钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
要为RhEL-安装ELRepo 7,SL- 7或CentOS- 7:
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm</font>
要为RhEL-安装ELRepo 6,SL- 6或CentOS- 6:
rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
要使用ELRepo的镜像系统,请同时安装yum-plugin-fastermirror。
- 安装内核
yum --enablerepo=elrepo-kernel install kernel-ml -y
安装完成后,查看已安装的内核:
rpm -qa | grep kernel
kernel-tools-3.10.0-957.1.3.el7.x86_64
kernel-3.10.0-957.1.3.el7.x86_64
kernel-3.10.0-957.el7.x86_64
kernel-tools-libs-3.10.0-957.1.3.el7.x86_64
kernel-ml-4.20.0-1.el7.elrepo.x86_64
在输出中看到类似kernel-ml-4.20.0-1.el7.elrepo.x86_64的内容,表示安装成功。
- 修改grub2引导
egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d '
CentOS Linux (4.20.0-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-40b6222317d24a7690053e4070fadddb) 7 (Core)
由于序号从0开始,设置需要的内核为启动项
grub2-set-default 0
reboot
重启完成后,重新登录并重新运行uname命令来确认你是否使用了正确的内核:
uname -r
得到如下结果则升级成功:
4.20.0-1.el7.elrepo.x86_64
开启BBR
echo 'net.core.default_qdisc=fq' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' >> /etc/sysctl.conf
sysctl -p
脚本自动安装
BBR脚本链接 https://raw.githubusercontent.com/teddysun/across/master/bbr.sh
curl -O https://raw.githubusercontent.com/teddysun/across/master/bbr.sh && sh bbr.sh
验证
查看可以用的拥塞控制算法
sysctl net.ipv4.tcp_available_congestion_control
得到结果
net.ipv4.tcp_available_congestion_control = reno cubic bbr
查看现在使用的拥塞控制算法
sysctl net.ipv4.tcp_congestion_control
得到结果
net.ipv4.tcp_congestion_control = bbr
检查BBR是否正常运行
lsmod | grep tcp_bbr
tcp_bbr 20480 1
速度测试
创建一个文件,搭建https服务
dd if=/dev/zero of=500mb.zip bs=1024k count=500
访问 https://[your-server-IP]/500mb.zip 来测试下载速度~
BBR acceleration Centos
What is BBR
BBR is a new congestion control algorithm proposed by Google, which enables Linux servers to significantly increase throughput and reduce the delay of TCP connections.
BBR project address
https://github.com/google/bbr
Manual installation, upgrade the kernel
Enabling BBR requires Linux kernel version 4.10 or higher. You can use the following command to view the current kernel version
uname -r
3.10.0-514.10.2.el7.x86_64
If the current kernel version is lower than 4.10, you can use ELRepo source update:
https://elrepo.org/tiki/tiki-index.php
Import public key
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
To install ELRepo 7, SL-7 or CentOS-7 for RhEL-:
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm</font>
To install ELRepo 6, SL-6 or CentOS-6 for RhEL-:
rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
To use ELRepo's mirroring system, please install yum-plugin-fastermirror at the same time.
Install the kernel
yum --enablerepo=elrepo-kernel install kernel-ml -y
After the installation is complete, check the installed kernel:
rpm -qa | grep kernel
kernel-tools-3.10.0-957.1.3.el7.x86_64
kernel-3.10.0-957.1.3.el7.x86_64
kernel-3.10.0-957.el7.x86_64
kernel-tools-libs-3.10.0-957.1.3.el7.x86_64
kernel-ml-4.20.0-1.el7.elrepo.x86_64
Seeing something similar to kernel-ml-4.20.0-1.el7.elrepo.x86_64 in the output indicates that the installation was successful.
Modify grub2 boot
egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d '
CentOS Linux (4.20.0-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-40b6222317d24a7690053e4070fadddb) 7 (Core)
Since the serial number starts from 0, set the required kernel as a startup item
grub2-set-default 0
reboot
After the restart is complete, log in again and rerun the uname command to confirm whether you are using the correct kernel:
uname -r
The upgrade is successful if the following results are obtained:
4.20.0-1.el7.elrepo.x86_64
Turn on BBR
echo'net.core.default_qdisc=fq' >> /etc/sysctl.conf
echo'net.ipv4.tcp_congestion_control=bbr' >> /etc/sysctl.conf
sysctl -p
Script automatic installation
BBR script link https://raw.githubusercontent.com/teddysun/across/master/bbr.sh
curl -O https://raw.githubusercontent.com/teddysun/across/master/bbr.sh && sh bbr.sh
verification
View available congestion control algorithms
sysctl net.ipv4.tcp_available_congestion_control
got the answer
net.ipv4.tcp_available_congestion_control = reno cubic bbr
View current congestion control algorithms
sysctl net.ipv4.tcp_congestion_control
got the answer
net.ipv4.tcp_congestion_control = bbr
Check if BBR is operating normally
lsmod | grep tcp_bbr
tcp_bbr 20480 1
Speed test
Create a file and build https service
dd if=/dev/zero of=500mb.zip bs=1024k count=500
Visit https://[your-server-IP]/500mb.zip to test the download speed~