Linux在4.9版本的内核新增了一款TCP拥塞控制技术:BBR,Linode最新内核也更新到4.9,但是没有把BBR编译进去,下面是教程是替换Linode CentOS7内核,并开启Google TCP-BBR优化算法方法。
注意:Linode、阿里云测试OK,Ucloud测试加载4.9变为只读系统。
1. 安装elrepo提供的kernel4.9
增加elrepo源
- cat > /etc/yum.repos.d/elrepo.repo << EOF
- [elrepo-kernel]
- name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
- baseurl=http://elrepo.org/linux/kernel/el7/\$basearch/
- http://mirrors.coreix.net/elrepo/kernel/el7/\$basearch/
- http://jur-linux.org/download/elrepo/kernel/el7/\$basearch/
- http://repos.lax-noc.com/elrepo/kernel/el7/\$basearch/
- http://mirror.ventraip.net.au/elrepo/kernel/el7/\$basearch/
- enabled=1
- gpgcheck=0
- EOF
可能存在yum更新内核时候找不到升级包,请检查/etc/yum.conf是否过滤了kernel
找到改文件将exclude=kernel* centos-release*注销,再尝试安装
安装elrepo替换4.9内核及grub2
- yum -y install kernel-ml grub2
查看4.9内核是否安装成功
- [root@linode1495332 ~]# ls -l /boot/vmlinuz*
- -rwxr-xr-x 1 root root 6037696 Dec 22 10:16 /boot/vmlinuz-0-rescue-72863e389b584a4dab36fae7f3bffda2
- -rwxr-xr-x 1 root root 6037696 Dec 12 05:37 /boot/vmlinuz-4.9.0-1.el7.elrepo.x86_64
2. 替换CentOS7内核
Linode内核切换方法:
- [root@linode1495332 etc]# mkdir /boot/grub
- [root@linode1495332 etc]# grub2-mkconfig -o /boot/grub/grub.cfg
- Generating grub configuration file …
- Found linux image: /boot/vmlinuz-4.9.0-1.el7.elrepo.x86_64
- Found initrd image: /boot/initramfs-4.9.0-1.el7.elrepo.x86_64.img
- Found linux image: /boot/vmlinuz-0-rescue-72863e389b584a4dab36fae7f3bffda2
- Found initrd image: /boot/initramfs-0-rescue-72863e389b584a4dab36fae7f3bffda2.img
- done
点击Linode后台面板Dashboard,点击Edit按钮:
在Kernel下拉菜单,选择GRUB 2启动:
非Linode切换内核方法:
- [root@oneinstack ~]# awk -F\’ ‘$1==”menuentry ” {print $2}’ /etc/grub2.cfg
- CentOS Linux (4.9.0-1.el7.elrepo.x86_64) 7 (Core)
- CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)
- CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
- CentOS Linux (0-rescue-7d26c16f128042a684ea474c9e2c240f) 7 (Core)
grub2-set-default 0,切换到新内核
- [root@oneinstack ~]# grub2-set-default 0
重启服务器:
- reboot
查看内核版本
- [root@linode1495332 ~]# uname -a
- Linux linode1495332.members.linode.com 4.9.0-1.el7.elrepo.x86_64 #1 SMP Sun Dec 11 15:43:54 EST 2016 x86_64 x86_64 x86_64 GNU/Linux
3. 开启TCP-BBR
- cat >>/etc/sysctl.conf << EOF
- net.core.default_qdisc=fq
- net.ipv4.tcp_congestion_control=bbr
- EOF
内核参数生效:
- sysctl -p
查看bbr是否生效:
- [root@linode1495332 ~]# sysctl net.ipv4.tcp_available_congestion_control
- net.ipv4.tcp_available_congestion_control = bbr cubic reno
- [root@linode1495332 ~]# lsmod | grep bbr
- tcp_bbr 16384 70
Thu Dec 22 11:17:53 CST 2016