CentOS6 更换最新版内核 & 开启 BBR 优化算法

kevin.Zhu 发布于:2018-1-3 10:20 分类:文摘  有 7 人浏览,获得评论 0 条  

https://www.hilinux.cn/archives/google-bbr.html

开源地址

https://github.com/google/bbr

一、更换内核

参考网址:http://elrepo.org/tiki/tiki-index.php
导入 Public Key

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 

安装 ELRepo 源

rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm 

请在安装该源之前,确保你的系统已经安装了 yum-plugin-fastestmirror,一般的都已经安装,毕竟装机十几台都没遇到
安装完以后,这里有两步
1、直接更新到最新版的内核

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

2、根据需求,安装特定版本的内核
打开内核下载页:http://elrepo.org/linux/kernel/el6/x86_64/RPMS/
将选定的版本内核 wget 到服务器上,然后安装对应的 RPM 包,如

rpm -Uvh kernel-ml-4.10.0-1.el6.elrepo.x86_64.rpm 

查看当前机器内核

ls -l /boot 

输入后显示如下内容

[root@tw-3 ~]# ls -l /boot total 93576 -rw-r--r--. 1 root root 107134 Jul 23 2015 config-2.6.32-573.el6.x86_64 -rw-r--r--. 1 root root 108108 Jan 11 21:02 config-2.6.32-642.13.1.el6.x86_64 -rw-r--r--. 1 root root 182745 Feb 20 02:47 config-4.10.0-1.el6.elrepo.x86_64 drwxr-xr-x. 3 root root 4096 Jan 24 19:55 efi drwxr-xr-x. 2 root root 4096 Feb 22 06:48 grub -rw-------. 1 root root 24036511 Jan 24 19:57 initramfs-2.6.32-573.el6.x86_64.img -rw-------. 1 root root 21949645 Jan 24 20:00 initramfs-2.6.32-642.13.1.el6.x86_64.img -rw-------. 1 root root 25269845 Feb 22 06:48 initramfs-4.10.0-1.el6.elrepo.x86_64.img -rw-r--r--. 1 root root 205998 Jul 23 2015 symvers-2.6.32-573.el6.x86_64.gz -rw-r--r--. 1 root root 215528 Jan 11 21:02 symvers-2.6.32-642.13.1.el6.x86_64.gz -rw-r--r--. 1 root root 341801 Feb 20 02:48 symvers-4.10.0-1.el6.elrepo.x86_64.gz -rw-r--r--. 1 root root 2585052 Jul 23 2015 System.map-2.6.32-573.el6.x86_64 -rw-r--r--. 1 root root 2618532 Jan 11 21:02 System.map-2.6.32-642.13.1.el6.x86_64 -rw-------. 1 root root 3417065 Feb 20 02:47 System.map-4.10.0-1.el6.elrepo.x86_64 -rwxr-xr-x. 1 root root 4220560 Jul 23 2015 vmlinuz-2.6.32-573.el6.x86_64 -rwxr-xr-x. 1 root root 4269968 Jan 11 21:02 vmlinuz-2.6.32-642.13.1.el6.x86_64 -rwxr-xr-x. 1 root root 6247904 Feb 20 02:47 vmlinuz-4.10.0-1.el6.elrepo.x86_64 

这里可以发现,我的机器有 3 个内核,分别是 2.6.32-573.el6.x86_64、2.6.32-642.13.1.el6.x86_64、4.10.0-1.el6.elrepo.x86_64
这里,我们只需要 4.10.0-1.el6.elrepo.x86_64 这个最新版的
编辑 menu.lst 文件

nano /boot/grub/menu.lst 

将其中的 default 改成 0,这其中也要看你内核的排序,一般来说最新安装的都是排在最前面的

请输入图片描述

保存文件,并重启吧!
重启完成后,输入uname -r检查内核版本是否为最新

二、开启 BBR 算法优化

开启 BBR,如果/etc/sysctl.conf文件有关于net.ipv4.tcp_congestion_control配置的,请注释掉
再输入

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
如果结果中有 BBR,则内核开启 BBR 算法成功
执行lsmod | grep bbr,看到 tcp_bbr 则说明 BBR 启动成功

请输入图片描述

图片来自 Leonn 的博客