在之前的文章《在Linode上应用BBR算法》中,介绍了如何在Linode VPS上更新内核应用BBR算法。那篇文章中使用的是Ubuntu 16.04。这里把CentOS 7该如何操作进行介绍。方法基本相同,所以其中步骤就简单描述了。
首先更新内核(el7地址):
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
在执行最后一条命令时,可能出现如下报错,
grubby fatal error: unable to find a suitable template
但最终会显示安装完成:
Installed: kernel-ml.x86_64 0:4.10.1-1.el7.elrepo Complete!
出现这个错误的原因是grub没有生成对应的配置文件,导致配置出错。只需再执行以下命令即可,命令以及输出如下:
[root@centos ~]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.10.1-1.el7.elrepo.x86_64 Found initrd image: /boot/initramfs-4.10.1-1.el7.elrepo.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-514.10.2.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-514.10.2.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-4f09fa5fdd3642fa85221d7c11370603 Found initrd image: /boot/initramfs-0-rescue-4f09fa5fdd3642fa85221d7c11370603.img done
现在再查看一下现在的grub配置
[root@centos ~]# egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \' CentOS Linux (4.10.1-1.el7.elrepo.x86_64) 7 (Core) CentOS Linux (3.10.0-514.10.2.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core) CentOS Linux (0-rescue-4f09fa5fdd3642fa85221d7c11370603) 7 (Core)
第一个就是刚刚添加的新内核,现在把它设置为默认。
grub2-set-default 0
“0”表示选择第一个配置文件。
接下来,将linode主机中的启动方式修改为grub2,具体的方法在之前的文章里有详细描述,这里就不重复了。重启:
reboot
重启后,查看是否已经更新为新的内核
[root@centos ~]# uname -r 4.10.1-1.el7.elrepo.x86_64
此时,再按照前篇文章所说,执行
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p
确认bbr已经配置成功后,监测是否运行
[root@centos ~]# lsmod |grep bbr tcp_bbr 16384 0
出现以上tcp_bbr服务信息即已成功。
参考: