Centos7 开启bbr加速

2020-05-29  本文已影响0人  broeeee
首先我们要知道BBR是什么?

BBR 是 Google 提出的一种新型拥塞控制算法,可以使 Linux 服务器显著地提高吞吐量和减少 TCP 连接的延迟。从 4.9 开始,Linux 内核已经用上了该算法。

查看自己机器内核

uname -r
  1. 手动开启
导入公钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

可能会遇到这类问题

curl: (35) Peer reports incompatible or unsupported protocol version.

curl不兼容,更新一下

yum update -y nss curl libcurl

Centos 7

yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

安装内核

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

查看已安装的内核列表

rpm -qa | grep kernel

如果有大于4.9的说明没问题,但是要应用最新的内核。

查看默认启动内核

grub2-editenv list

应该是3.0左右的版本

查看所有内核

cat /boot/grub2/grub.cfg | grep menuentry

找出大于4.9的内核复制全名

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (5.7.0-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.26.2.el7.x86_64-advanced-dac97e83-6855-4927-a60f-2923f304e4d0' {
menuentry 'CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.26.2.el7.x86_64-advanced-dac97e83-6855-4927-a60f-2923f304e4d0' {
menuentry 'CentOS Linux (3.10.0-514.26.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.26.2.el7.x86_64-advanced-dac97e83-6855-4927-a60f-2923f304e4d0' {
menuentry 'CentOS Linux (0-rescue-2b7d4e5421b745138f5bedc3e9233da3) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-2b7d4e5421b745138f5bedc3e9233da3-advanced-dac97e83-6855-4927-a60f-2923f304e4d0' {

修改默认启动内核

grub2-set-default 'CentOS Linux (5.7.0-1.el7.elrepo.x86_64) 7 (Core)'

重启

reboot

再连接上,复验一下默认启动内核

grub2-editenv list

内核要求满足了,可以开启bbr了。

加入下面两句

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf

加载参数

sysctl -p

查看是否开启成功

sysctl net.ipv4.tcp_available_congestion_control

显示

net.ipv4.tcp_available_congestion_control = reno cubic bbr
或者
net.ipv4.tcp_available_congestion_control = bbr cubic reno
sysctl net.ipv4.tcp_congestion_control

显示

net.ipv4.tcp_congestion_control = bbr
lsmod | grep bbr

显示

tcp_bbr                20480  7
  1. 自动开启

脚本出自作者:秋水逸冰

系统支持:CentOS 6+,Debian 7+,Ubuntu 12+
虚拟技术:OpenVZ 以外的,比如 KVM、Xen、VMware 等
内存要求:≥128M
日期  :2018 年 12 月 14 日

root登录

wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh

安装完成后,脚本会提示需要重启 VPS,输入 y 并回车后重启。

验证是否开启参看上面验证方法。

上一篇 下一篇

猜你喜欢

热点阅读