bbr
是一款基于tcp
的拥塞控制驱动,直接的说就是可以抢带宽。目前Centos7
默认是3.10.0
的内核,而要开启bbr
至少在4.9.0
以上内核,所以下面开始安装新内核并开启bbr。
一、安装新内核
首先看看当前启动的内核版本:
1
2
[root@liuquanhao ~]# uname -r
3.10.0-862.14.4.el7.x86_64
我的是3.10.0-xx
的内核。现在安装ELRepo
:
1
2
[root@liuquanhao ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@liuquanhao ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
然后使用上面的ELRepo
安装最新的内核:
1
[root@liuquanhao ~]# yum --enablerepo=elrepo-kernel install kernel-ml -y
装好后验证一下:
1
2
3
4
5
6
7
[root@liuquanhao ~]# rpm -qa | grep kernel
kernel-tools-3.10.0-862.14.4.el7.x86_64
kernel-tools-libs-3.10.0-862.14.4.el7.x86_64
kernel-3.10.0-693.el7.x86_64
kernel-3.10.0-693.11.6.el7.x86_64
kernel-3.10.0-862.14.4.el7.x86_64
kernel-ml-4.18.15-1.el7.elrepo.x86_64
最下面的kernel-ml-4.18.15-1.el7.elrepo.x86_64
就是我新安装的4.18.15
内核。
现在看看安装的内核在grub2.cfg
的什么位置上:
1
2
3
4
5
6
7
[root@liuquanhao ~]# egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
CentOS Linux (4.18.15-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux 7 Rescue f630cedcce5f4a3cbc5dcb5acf68ddd3 (3.10.0-862.14.4.el7.x86_64)
CentOS Linux (3.10.0-862.14.4.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.11.6.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-00a62363617944e08db8db894ba6145e) 7 (Core)
排在第一行,因为位置是从0
开始数,所以它排在第0
位。
现在设置0
位为默认启动内核:
1
[root@liuquanhao ~]# grub2-set-default 0
内核设置好后就可以重启系统了:
1
[root@liuquanhao ~]# reboot
重启完成后我们再登陆服务器,然后看看当前启动的内核版本:
1
2
[root@liuquanhao ~]# uname -r
4.18.15-1.el7.elrepo.x86_64
是新安装的4.18.15
内核了,现在开始配置bbr
。
二、配置bbr
首先配置/etc/sysctl.conf
文件:
1
2
3
4
[root@liuquanhao ~]# cat /etc/sysctl.conf
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
[root@liuquanhao ~]# sysctl -p
现在看看当前内核支持哪些拥塞控制驱动,以及当前使用的是什么驱动:
1
2
3
4
[root@liuquanhao ~]# sysctl -n net.ipv4.tcp_available_congestion_control
reno cubic bbr
[root@liuquanhao ~]# sysctl -n net.ipv4.tcp_congestion_control
bbr
可以看到当前使用的是bbr
,最后还可以确认一下bbr
驱动是不是加载好了:
1
2
[root@liuquanhao ~]# lsmod | grep bbr
tcp_bbr 20480 1
下面看看网络对比,先看看3.10.0
内核的网速:
1
2
3
4
5
6
[root@liuquanhao ~]# uname -r
3.10.0-693.el7.x86_64
[root@liuquanhao ~]# sysctl -n net.ipv4.tcp_available_congestion_control
cubic reno
[root@liuquanhao ~]# sysctl -n net.ipv4.tcp_congestion_control
cubic
再看看4.18.15
内核的网速:
1
2
3
4
[root@liuquanhao ~]# sysctl -n net.ipv4.tcp_available_congestion_control
reno cubic bbr
[root@liuquanhao ~]# sysctl -n net.ipv4.tcp_congestion_control
bbr
好了,现在就可以体验更快的网络了。
参考链接:Centos7部署Google bbr