魔改BBR手动安装教程(Debian-南琴浪)

所需环境

Debian 7+
KVM
可以这样查看你的虚拟化技术:

apt-get install -y virt-what
virt-what

安装步骤

如果决定手动安装,请务必严格按照本文所述顺序(不可更改命令执行顺序或省略步骤,会出事的),一步步执行并确保执行无误

更换内核

编译魔改算法需要你安装有 linux-image linux-headers-all linux-headers-$bit 三个内核。

安装新内核
以 mainline v4.10.10 为例。

1
2
确认你的系统是 32 or 64
bit=`uname -m`
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 64
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.10/linux-image-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_amd64.deb
dpkg -i linux-image-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.10/linux-headers-4.10.10-041010_4.10.10-041010.201704120813_all.deb
dpkg -i linux-headers-4.10.10-041010_4.10.10-041010.201704120813_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.10/linux-headers-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_amd64.deb
dpkg -i linux-headers-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_amd64.deb

# 32
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.10/linux-image-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_i386.deb
dpkg -i linux-image-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_i386.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.10/linux-headers-4.10.10-041010_4.10.10-041010.201704120813_all.deb
dpkg -i linux-headers-4.10.10-041010_4.10.10-041010.201704120813_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.10/linux-headers-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_i386.deb
dpkg -i linux-headers-4.10.10-041010-lowlatency_4.10.10-041010.201704120813_i386.deb

删除旧内核

删除除了 v4.10.10 版本以外的所有内核。

1
2
3
4
5
6
7
# 列出所有多余内核
# 返回的一长串就是下面的“内核名”
dpkg -l|grep linux-image | awk '{print $2}' | grep -v "4.10.10"
dpkg -l|grep linux-headers | awk '{print $2}' | grep -v "4.10.10"

# 对上面列出的每个内核都执行一次删除指令
apt-get purge -y “内核名”

检查内核

先运行以下命令:

1
update-grub

执行完毕后,再次检查当前内核是否已安装无误:

1
2
3
4
5
6
7
dpkg -l|grep linux-image   | awk '{print $2}'
dpkg -l|grep linux-headers | awk '{print $2}'

# 返回如下值
linux-image-4.10.10-041010-lowlatency
linux-headers-4.10.10-041010
linux-headers-4.10.10-041010-lowlatency

然后就可以重启你的 VPS 了。开机后进入第二步。

启用算法

经过第一步,已经成功的更换了系统内核。接下来,要启用魔改 BBR,按照顺序执行以下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# dependences
apt-get update && apt-get install -y build-essential

# Makefile
## Debian 7/8
wget -O Makefile https://raw.githubusercontent.com/nanqinlang-tcp/tcp_nanqinlang/master/Makefile/Makefile-Debian7or8
## Debian 9
wget -O Makefile https://raw.githubusercontent.com/nanqinlang-tcp/tcp_nanqinlang/master/Makefile/Makefile-Debian9

# source
wget https://raw.githubusercontent.com/nanqinlang-tcp/tcp_nanqinlang/master/General/Debian/source/kernel-v4.12andbelow/tcp_nanqinlang.c

# make + install
make && make install

# sysctl
echo -e "\nnet.core.default_qdisc=fq" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_congestion_control=nanqinlang\c" >> /etc/sysctl.conf

检查状态

以上过程均完成后,使用以下命令检查是否已成功启用魔改 BBR:

1
2
3
4
5
6
7
sysctl net.ipv4.tcp_available_congestion_control | awk '{print $3}'
# 返回值:
nanqinlang

lsmod | grep nanqinlang
# 返回值(类似于):
tcp_nanqinlang 6053 18

相关 issue
https://github.com/sometimesnaiveorg/mainland/issues/63

-------------���Ľ�����л�����Ķ�-------------
0%