編譯新的TCP擁塞控制算法-BBR

最近Google新出的玩物,大家都很開心的在玩,這邊在回國之後也坐下來玩了一下。

本文章基於本人在Linode運行的服務器,系統為CentOS 7。

這裡有一個問題就是大家都以為Linode上了4.9.0內核,理所當然內置BBR了,但Linode官方其實沒有編譯進去,我們還是得自己編譯內核。

本文大部分參考了 https://blog.linuxeye.com/452.html ,Please check them out。

    1. 安裝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

    1. 平行安裝帶有BBR的4.9內核以及GRUB2

注意:GRUB2只是給KVM用的,Xen用戶請照常使用 /boot/grub/menu.lst 來引導啟動。

yum -y install kernel-ml grub2

    1. 檢查內核是否安裝成功

[root@localhost ~]# ls -l /boot/vmlinuz*
-rwxr-xr-x 1 root root 6037696 Dec 29 12:47 /boot/vmlinuz-0-rescue-72863e389b584a4dab36fae7f3bffda2
-rwxr-xr-x 1 root root 6037696 Dec 11 21:37 /boot/vmlinuz-4.9.0-1.el7.elrepo.x86_64

    1. 設置內核(Linode-KVM篇):

[root@localhost ~]# mkdir /boot/grub
[root@localhost ~]# 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的面板配置文件中選擇使用 GRUB 2 啟動即可。

    1. 設置內核(非Linode-KVM篇):

[root@localhost ~]# 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-327.36.3.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-153a217486fe4be8a8dbd28db67ed581) 7 (Core)
[root@localhost ~]# grub2-set-default 0

  1. 設置內核(Linode-Xen篇):

編輯 /boot/grub/menu.lst :

timeout 5
title CentOS (4.9.0-1.el7.elrepo.x86_64)
root (hd0)
kernel /boot/vmlinuz-4.9.0-1.el7.elrepo.x86_64 root=/dev/xvda
initrd /boot/initramfs-4.9.0-1.el7.elrepo.x86_64.img

然後在Linode的面板配置文件中選擇 pv-grub-x86_64 啟動方式。

注意:以上更換內核方式均需重啟。

最後,配置使用BBR:

cat >>/etc/sysctl.conf << EOF
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
EOF

sysctl -p

查看BBR是否生效:

[root@localhost ~]# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = bbr cubic reno
[root@localhost ~]# lsmod | grep bbr
tcp_bbr 16384 16

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据