使用TCP BBR 拥塞控制算法,能够使Linux服务器更高效的利用带宽、增加吞吐量并减少连接的延迟。
升级内核
查看当前的内核
1 2 3
| uname -r 输出... 3.10.0-514.2.2.el7.x86_64
|
这里我们看到当前内核是3.10.0-514.2.2.el7.x86_64,这个内核是不可以安装BBR的。
安装内核
1 2 3
| sudo rpm --import https: sudo rpm -Uvh http: sudo yum --enablerepo=elrepo-kernel install kernel-ml -y
|
查看已安装内核
1
| sudo egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
|
结果应该类似于:
1 2 3 4
| CentOS Linux (4.9.0-1.el7.elrepo.x86_64) 7 (Core) CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core) CentOS Linux (0-rescue-bf94f46c6bd04792a6a42c91bae645f7) 7 (Core)
|
设置默认的grub2引导项来启用4.9.0内核
由于行计数从0开始,4.9.0内核CentOS Linux (4.9.0-1.el7.elrepo.x86_64) 7 (Core)条目位于第二行,因此将默认启动项设置为1:
1 2
| sudo grub2-set-default grub2-mkconfig /boot//grub.cfg
|
重启系统
查看内核
1 2 3
| uname -r 输出... 4.9.0-1.el7.elrepo.x86_64
|
激活 BBR
1 2 3
| 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
|
查看启用tcp_bbr模块
1 2
| lsmod | grep tcp_bbr tcp_bbr 20480 1
|
验证生效
1 2 3
| sudo sysctl -n net.ipv4.tcp_congestion_control 输出... bbr
|
测试网络性能提升
为了测试BBR的网络性能增强,您可以在Web服务器目录中创建一个文件进行下载,然后从台式机上的Web浏览器测试下载速度。
1 2 3 4 5
| sudo systemctl stop firewalld sudo yum install nginx cd /usr/share/nginx/html sudo dd if=/dev/zero of=1000MB bs=16k count=64k sudo systemctl start nginx
|
最后,从桌面计算机上的Web浏览器访问URL http://[your-server-IP]/1000MB,测试下载速度。
https://www.vultr.com/docs/how-to-deploy-google-bbr-on-centos-7