TCP BBR是Bottleneck Bandwidth and Round-trip propagation time的简写,可以加速你的Linux VPS网页加载速度.
目前很多VPS商家已经集成了TCP BBR,比如: 狗云(DogYun):狗云VPS怎么样?狗云服务器好不好?
Linux VPS服务器距离访客远,路由复杂,Linux VPS服务器线路经常变动的服务器.
国内阿里云等优质商家的VPS服务器无需安装BBR.
wget https://img.vpsyi.com/xiazai/tcp_bbr_2019.sh chmod +x tcp.sh ./tcp.sh
wget https://img.vpsyi.com/xiazai/tcp_bbr_2020.sh chmod +x tcp.sh ./tcp.sh
github项目:https://github.com/cx9208/Linux-NetSpeed
bbrplus介绍:https://www.hostloc.com/thread-507165-1-1.html
作者的bbr网站介绍页面: https://www.94ish.me/1635.html
wget https://github.com/chiakge/Linux-NetSpeed/raw/master/tcp.sh chmod +x tcp.sh ./tcp.sh
如果是国外的大VPS商家,使用BBR魔改版与BBR PLUS可能会被封禁,谨慎使用.
Linux内核从4.9开始已经用上了该算法,并且对于QUIC可用。
如果想在Linux VPS使用BBR,那么先就是判断内核版本是否大于4.9,如果符合版本标准,那么直接启动BBR就可以了,如果低于4.9,升级内核之后启动就行了。
在Centos 7, Debian 8/9, Ubuntu 16/18测试通过,不支持ovz
cat /etc/redhat-release
[root@cvm1345 ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)
输入uname -r查看内核版本
uname -r
如果不是Linux内核不是4.9以上需要执行升级命令,因为Linux内核从4.9开始已经用上了该算法
yum update
自动安装BBR,使用一键安装BBR脚本:
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
如果你是精简版的Centos,可能无法执行下面的wget命令,那么需要安装一下wget
yum install wget
使用下面命令安装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
启动TCP BBR。依次执行下面命令就可以了。
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf sysctl -p
开启TCP BBR
vi /etc/sysctl.conf
添加如下内容
net.core.default_qdisc = fq net.ipv4.tcp_congestion_control = bbr
加载系统参数(正常情况下会输出我们之前加入的内容)
sysctl -p
输入下面的命令:
sysctl net.ipv4.tcp_available_congestion_control 如果输出为下面的表示bbr安装成功并开启了.
[root@cvm1345 ~]# sysctl net.ipv4.tcp_available_congestion_control net.ipv4.tcp_available_congestion_control = reno cubic bbr
输入lsmod | grep bbr如果输出类似下面的表示bbr安装成功并开启了.
[root@cvm1345 ~]# lsmod | grep bbr tcp_bbr 20480 9
sysctl net.ipv4.tcp_congestion_control
如果输出下面的代码表示TCP BBR安装成功并开启了.
[root@cvm1345 ~]# sysctl net.ipv4.tcp_congestion_control net.ipv4.tcp_congestion_control = bbr