Newark的主机最近变得很慢,想装serverspeeder,但是网上找了下,发现已经停止开发了。看到Google在2016年10月发布的BBR算法,就决定尝试一下。
检查内核
linux内核版本4.9以上都内置了bbr算法
通过以下命令查看内核版本
1 |
uname -r |
或者在linode后台查看
更换内核
1 |
wget + 内核下载地址 |
内核下载地址,目前最新为4.10.15
1 |
http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb |
下载内核
1 |
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb |
输出
1 2 3 4 5 6 7 8 9 10 |
--2017-05-12 12:35:16-- http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb Resolving kernel.ubuntu.com (kernel.ubuntu.com)... 91.189.94.216 Connecting to kernel.ubuntu.com (kernel.ubuntu.com)|91.189.94.216|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 49406344 (47M) [application/x-debian-package] Saving to: ‘linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb’ linux-image-4.10.15-041015- 100%[===========================================>] 47.12M 26.9MB/s in 1.7s 2017-05-12 12:35:18 (26.9 MB/s) - ‘linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb’ saved [49406344/49406344] |
安装内核
1 |
dpkg -i linux-image-4.*.deb |
输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Selecting previously unselected package linux-image-4.10.15-041015-generic. (Reading database ... 32722 files and directories currently installed.) Preparing to unpack linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb ... Done. Unpacking linux-image-4.10.15-041015-generic (4.10.15-041015.201705080411) ... Setting up linux-image-4.10.15-041015-generic (4.10.15-041015.201705080411) ... Running depmod. update-initramfs: deferring update (hook will be called later) Examining /etc/kernel/postinst.d. run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.10.15-041015-generic /boot/vmlinuz-4.10.15-041015-generic run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.10.15-041015-generic /boot/vmlinuz-4.10.15-041015-generic update-initramfs: Generating /boot/initrd.img-4.10.15-041015-generic run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.10.15-041015-generic /boot/vmlinuz-4.10.15-041015-generic Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.10.15-041015-generic Found initrd image: /boot/initrd.img-4.10.15-041015-generic Found linux image: /boot/vmlinuz-3.16.0-4-amd64 Found initrd image: /boot/initrd.img-3.16.0-4-amd64 done |
查看所有已安装内核
1 |
dpkg -l|grep linux-image |
输出
1 2 3 |
ii linux-image-3.16.0-4-amd64 3.16.43-2 amd64 Linux 3.16 for 64-bit PCs ii linux-image-4.10.15-041015-generic 4.10.15-041015.201705080411 amd64 Linux kernel image for version 4.10.15 on 64 bit x86 SMP ii linux-image-amd64 3.16+63 amd64 Linux for 64-bit PCs (meta-package) |
删除多余内核
1 |
apt-get purge + 旧内核 |
1 |
apt-get purge linux-image-3.16.0-4-amd64 |
输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libuuid-perl linux-base Use 'apt-get autoremove' to remove them. The following packages will be REMOVED: linux-image-3.16.0-4-amd64* linux-image-amd64* 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. After this operation, 164 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 38812 files and directories currently installed.) Removing linux-image-amd64 (3.16+63) ... Removing linux-image-3.16.0-4-amd64 (3.16.43-2) ... /etc/kernel/postrm.d/initramfs-tools: update-initramfs: Deleting /boot/initrd.img-3.16.0-4-amd64 /etc/kernel/postrm.d/zz-update-grub: Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.10.15-041015-generic Found initrd image: /boot/initrd.img-4.10.15-041015-generic done The link /vmlinuz.old is a damaged link Removing symbolic link vmlinuz.old You may need to re-run your boot loader The link /initrd.img.old is a damaged link Removing symbolic link initrd.img.old You may need to re-run your boot loader Purging configuration files for linux-image-3.16.0-4-amd64 (3.16.43-2) ... |
更新 grub 系统引导文件
1 |
update-grub |
输出
1 2 3 4 |
Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.10.15-041015-generic Found initrd image: /boot/initrd.img-4.10.15-041015-generic done |
更换linode后台系统内核类型为(GRUB 2)
重启主机
写入系统配置
检查系统内核版本
1 |
uname -r |
输出
1 |
4.10.15-041015-generic |
检查BBR模块
1 |
lsmod | grep bbr |
输出
1 |
tcp_bbr 20480 4 |
写入系统配置文件
1 2 |
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf |
保存系统配置文件
1 |
sysctl -p |
检查系统配置文件
1 2 |
sysctl net.ipv4.tcp_available_congestion_control sysctl net.ipv4.tcp_congestion_control |
输出
1 2 |
net.ipv4.tcp_available_congestion_control = bbr cubic reno net.ipv4.tcp_congestion_control = bbr |
All Done!
总结
Linode其实并没有必要更换内核,只要内核版本为4.9以上就行,但是如果使用的是linode的内核,那么 lsmod | grep bbr 就没必要使用,因为linode的内核已经集成了tcp_bbr模块,所以运行该命令是没有输出结果的。只要 sysctl net.ipv4.tcp_congestion_control 输出为bbr就说明开启了。
7 comments