文章目录
之前本博介绍过 Google BBR 优化算法,实现TCP加速 加速效果还不错。
最近大佬 @Yankee 更新了一份 BBR魔改方案,使得BBR加速效果更明显了。
目前还没有关于CentOS 和 Ubuntu 14 详细安装说明。本文解决这一个空白。
由于本人技术太渣,暂时不提供一键安装方案。
源码对比
左侧为原BBR 右侧为魔改BBR (能看懂的可以瞅瞅)
源码地址:
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/plain/net/ipv4/tcp_bbr.c
https://gist.github.com/anonymous/ba338038e799eafbba173215153a7f3a/raw/55ff1e45c97b46f12261e07ca07633a9922ad55d/tcp_tsunami.c
鉴于之前的那篇文章内核是 4.9的,所以再水一篇文章吧!!
CentOS 6 X64
CentOS系统本文演示使用 4.11.8 内核。如果下面代码中的内核地址失效,请自行搜索最新的内核地址即可。
内核地址:http://elrepo.org/linux/kernel
升级系统内核
1)依次执行以下代码。
1 2 3 4 5 |
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org yum install -y http://elrepo.org/linux/kernel/el6/x86_64/RPMS/kernel-ml-4.11.8-1.el6.elrepo.x86_64.rpm yum remove -y kernel-headers yum install -y http://elrepo.org/linux/kernel/el6/x86_64/RPMS/kernel-ml-headers-4.11.8-1.el6.elrepo.x86_64.rpm yum install -y http://elrepo.org/linux/kernel/el6/x86_64/RPMS/kernel-ml-devel-4.11.8-1.el6.elrepo.x86_64.rpm |
设置启动引导
2)修改启动引导,修改配置文件即可。
执行命令:
1 |
vi /etc/grub.conf |
红框可看见我们新安装的内核。修改 default=0 即可。然后保存。重启服务器。
编译安装
依次执行以下脚本
1 2 3 4 5 6 7 8 9 10 |
yum install -y make gcc wget -O ./tcp_tsunami.c https://gist.github.com/anonymous/ba338038e799eafbba173215153a7f3a/raw/55ff1e45c97b46f12261e07ca07633a9922ad55d/tcp_tsunami.c echo "obj-m:=tcp_tsunami.o" > Makefile make -C /lib/modules/$(uname -r)/build M=`pwd` modules CC=/usr/bin/gcc chmod +x ./tcp_tsunami.ko cp -rf ./tcp_tsunami.ko /lib/modules/$(uname -r)/kernel/net/ipv4 insmod tcp_tsunami.ko depmod -a echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=tsunami" >> /etc/sysctl.conf |
执行完之后 重启一下服务器。
1 |
reboot |
重启成功后,执行以下命令。如果有显示内容说明启动成功。
1 |
lsmod | grep tsunami |
>> tcp_tsunami 6053 5
CentOS 7 X64
由于手头暂时没有CentOS7 系统的服务器。以下代码并没有测试。
升级系统内核,请执行以下代码。其他的请参考 CentOS 6 X64!!
1 2 3 4 5 |
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org yum install -y http://elrepo.org/linux/kernel/el7/x86_64/RPMS/kernel-ml-4.11.8-1.el7.elrepo.x86_64.rpm yum remove -y kernel-headers yum install -y http://elrepo.org/linux/kernel/el7/x86_64/RPMS/kernel-ml-headers-4.11.8-1.el7.elrepo.x86_64.rpm yum install -y http://elrepo.org/linux/kernel/el7/x86_64/RPMS/kernel-ml-devel-4.11.8-1.el7.elrepo.x86_64.rpm |
Debian 8/Ubuntu 14
升级系统内核
分别安装 headers 和 images 即可。
内核地址:http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.9/
你可以选择更高版本的内核试一试,注意自己替换命令中的 v4.10.9
1 2 3 4 5 |
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.9/linux-headers-4.10.9-041009_4.10.9-041009.201704080516_all.deb dpkg -i linux-headers-4.10.9*.deb wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.9/linux-image-4.10.9-041009-generic_4.10.9-041009.201704080516_amd64.deb dpkg -i linux-image-4.10.9*.deb |
设置启动引导
1)查看系统内核列表,执行以下命令
1 |
dpkg -l|grep linux-image |
执行命令后,可见多个内核如下:
1 2 3 |
ii linux-image-3.16.0-4-amd64 3.16.7-ckt9-3~deb8u1 amd64 Linux 3.16 for 64-bit PCs ii linux-image-4.10.9-041009-generic 4.10.9-041009.201704080516 amd64 Linux kernel image for version 4.10.9 on 64 bit x86 SMP ii linux-image-amd64 3.16+63 amd64 Linux for 64-bit PCs (meta-package) |
上面显示的我们需要将 linux-image-3.16.0 这个删除掉。
PS : 如果你显示的是其他的内核版本,那么就删掉它。只保留 4.10.9。
2)删除内核。
1 |
apt-get remove linux-image-3.16.0-4-amd64 |
注意:Debian8 系统会弹出一个提示,直接【Tab】选择 【NO】然后回车。
3)重新生成启动引导。
1 |
update-grub |
4)重启系统。
1 |
reboot |
安装gcc
根据大佬的要求 gcc版本必须 >= 4.9 ,否则无法编译。
我在 Ubuntu 14上安装gcc的时候竟然是 4.8版本,可能是由于 Ubuntu 14版本的问题。
1)查看 gcc 版本 。如果 版本 >= 4.9 可跳过这个步骤了。
1 |
gcc -v |
2) 执行以下命令来安装 gcc-4.9
1 2 3 4 |
apt-get install build-essential add-apt-repository ppa:ubuntu-toolchain-r/test apt-get update apt-get install gcc-4.9 |
编译安装
1)请依次执行以下脚本。执行完重启服务器。
1 2 3 4 5 6 7 8 9 |
apt-get install make gcc-4.9 wget -O ./tcp_tsunami.c https://gist.github.com/anonymous/ba338038e799eafbba173215153a7f3a/raw/55ff1e45c97b46f12261e07ca07633a9922ad55d/tcp_tsunami.c echo "obj-m:=tcp_tsunami.o" > Makefile make -C /lib/modules/$(uname -r)/build M=`pwd` modules CC=/usr/bin/gcc-4.9 install tcp_tsunami.ko /lib/modules/$(uname -r)/kernel cp -rf ./tcp_tsunami.ko /lib/modules/$(uname -r)/kernel/net/ipv4 depmod -a echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=tsunami" >> /etc/sysctl.conf |
2)重启成功后,执行以下命令。如果有显示内容 说明启动成功。
1 |
lsmod | grep tsunami |
>> tcp_tsunami 6053 5
一键安装脚本
对于小白用户,以上手动安装可能有点复杂。那么就推荐你使用大佬的一键脚本吧。
提醒一下几位大佬的一键暂不支持 CentOS系统。大佬们的一键脚本可能在 Ubuntu14 下执行可能出问题。
如果一键出错,那么只能上面的内容手动安装了。
谢谢@Leonn 的博客 收集以下内容。
落雨无声版本
原文地址:https://ylws.me/tech/68.html
注意只支持 Debian8 / Ubuntu16 +
1 |
wget -N --no-check-certificate https://raw.githubusercontent.com/FunctionClub/YankeeBBR/master/bbr.sh && bash bbr.sh install |
Vicer版本
原文地址:https://moeclub.org/2017/06/24/278/
注意只支持 Debian8 / Ubuntu16 +
1 |
wget --no-check-certificate -qO 'BBR_POWERED.sh' 'https://moeclub.org/attachment/LinuxShell/BBR_POWERED.sh' && chmod a+x BBR_POWERED.sh && bash BBR_POWERED.sh |
91Yun版本
原文地址:https://www.91yun.org/archives/16781
注意只支持 Debian8 / Ubuntu16 +
1 2 3 |
wget https://raw.githubusercontent.com/singhigh/502newbbr/master/502newbbr.sh chmod +x 502newbbr.sh ./502newbbr.sh |
特别鸣谢
感谢 Hostloc众多大佬
参考文献:
提示 /lib/modules/4.13.9-1.el7.elrepo.x86_64/build: No such file or directory
但是实际有这个路径, 而且我确实无法cd进去, 是root账户 这是怎么回事?
/usr/linwen/tcp_tsunami.c:67:20: error: field ‘cycle_mstamp’ has incomplete type
struct skb_mstamp cycle_mstamp; /* time of this cycle phase start */
^
/usr/linwen/tcp_tsunami.c: In function ‘bbr_is_next_cycle_phase’:
/usr/linwen/tcp_tsunami.c:387:3: error: implicit declaration of function ‘skb_mstamp_us_delta’ [-Werror=implicit-function-declaration]
skb_mstamp_us_delta(&tp->delivered_mstamp, &bbr->cycle_mstamp) >
^
/usr/linwen/tcp_tsunami.c: In function ‘bbr_reset_lt_bw_sampling_interval’:
/usr/linwen/tcp_tsunami.c:473:43: error: request for member ‘stamp_jiffies’ in something not a structure or union
bbr->lt_last_stamp = tp->delivered_mstamp.stamp_jiffies;
^
/usr/linwen/tcp_tsunami.c: In function ‘bbr_lt_bw_sampling’:
/usr/linwen/tcp_tsunami.c:579:32: error: request for member ‘stamp_jiffies’ in something not a structure or union
t = (s32)(tp->delivered_mstamp.stamp_jiffies - bbr->lt_last_stamp);
经测试4.13的kernel无法编译
CentOS7用CentOS6的步骤测试通过。。alibabacloud的SG。
cenos t x64
(1)过程都是对的,但是重启就是没有加载为何?
重启后
[root@localhost ~]# lsmod | grep tsunami
[root@localhost ~]#
[root@localhost ipv4]# uname -a
Linux localhost.localdomain 4.11.8-1.el7.elrepo.x86_64 #1 SMP Thu Jun 29 10:01:10 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ipv4]# depmod -a
[root@localhost ipv4]# ls
ah4.ko ip_vti.ko tcp_hybla.ko tunnel4.ko
esp4.ko netfilter tcp_illinois.ko udp_diag.ko
esp4_offload.ko raw_diag.ko tcp_lp.ko udp_tunnel.ko
fou.ko tcp_bbr.ko tcp_nv.ko xfrm4_mode_beet.ko
gre.ko tcp_bic.ko tcp_scalable.ko xfrm4_mode_transport.ko
inet_diag.ko tcp_cdg.ko tcp_tsunami.ko xfrm4_mode_tunnel.ko
ipcomp.ko tcp_dctcp.ko tcp_vegas.ko xfrm4_tunnel.ko
ip_gre.ko tcp_diag.ko tcp_veno.ko
ipip.ko tcp_highspeed.ko tcp_westwood.ko
ip_tunnel.ko tcp_htcp.ko tcp_yeah.ko
[root@localhost ipv4]# cat /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=tsunami
[root@localhost ipv4]#
重启后
[root@localhost ~]# lsmod | grep tsunami
[root@localhost ~]#
再次insmod
[root@localhost ~]# insmod tcp_tsunami.ko
[root@localhost ~]# lsmod | grep tsunami
tcp_tsunami 16384 0
[root@localhost ~]#
重启一样没了
什么原因。。cenos 7 x64
Centos6设置启动引导之后重启 就起不动了。
恭喜翻车了
还是用 某速吧 Vicer大佬的和落雨无声大佬的 都卡在更换内核 。91yun的直接没法用
提醒一下几位大佬的一键暂不支持 CentOS系统。大佬们的一键脚本可能在 Ubuntu14 下执行可能出问题。
用大佬的一键脚本我是用的debian8,有问题
然后我用Vicer重装系统的脚本重装了一遍debian8,就可以用了、我觉得可能是系统模板的问题
[root@instance-1 ~]# echo "obj-m:=tcp_tsunami.o" > Makefile
[root@instance-1 ~]# make -C /lib/modules/$(uname -r)/build M=`pwd` modules CC=/usr/bin/gcc
./scripts/gcc-version.sh: line 25: /usr/bin/gcc: No such file or directory
./scripts/gcc-version.sh: line 26: /usr/bin/gcc: No such file or directory
make: /usr/bin/gcc: Command not found
make: Entering directory `/usr/src/kernels/4.11.8-1.el6.elrepo.x86_64'
make: /usr/bin/gcc: Command not found
make: /usr/bin/gcc: Command not found
make: /usr/bin/gcc: Command not found
make: /usr/bin/gcc: Command not found
CC [M] /root/tcp_tsunami.o
/bin/sh: /usr/bin/gcc: No such file or directory
make[1]: *** [/root/tcp_tsunami.o] Error 1
make: *** [_module_/root] Error 2
make: Leaving directory `/usr/src/kernels/4.11.8-1.el6.elrepo.x86_64'
[root@instance-1 ~]# chmod +x ./tcp_tsunami.ko
chmod: cannot access `./tcp_tsunami.ko': No such file or directory
[root@instance-1 ~]# cp -rf ./tcp_tsunami.ko /lib/modules/$(uname -r)/kernel/net/ipv4
cp: cannot stat `./tcp_tsunami.ko': No such file or directory
编译安装部分少一个命令
yum install -y make gcc
已经更新。
指出一个错误,CentOS6 x64的内核安装命令中有个小错误:
yum install -y http://elrepo.org/linux/kernel/el6/x86_64/RPMS/kernel-ml-4.11.8-1.el7.elrepo.x86_64.rpm
^此处应为el6
所以正确的命令是
yum install -y http://elrepo.org/linux/kernel/el6/x86_64/RPMS/kernel-ml-4.11.8-1.el6.elrepo.x86_64.rpm
谢谢已经更正。
4.14以后也boom了
RPM源更新了11的没了,进http://elrepo.org/linux/kernel/el6/x86_64/RPMS/
目录里找最新的就行了A.A
加速效果不如锐速
这个和锐速对比怎么样
这个牛逼
特别鸣谢:马甲大佬