sysctl
和tcp_bbr
工具,最后编辑/etc/sysctl.conf
文件启用BBR。 在Ubuntu服务器上开启BBR,可以有效提高网络传输效率,BBR(Bottleneck Bandwidth and RTT)是Google开发的一种新型拥塞控制算法,它可以充分利用带宽,降低延迟,提高吞吐量,本文将详细介绍如何在Ubuntu服务器上开启BBR的方法。
安装内核4.9及以上版本
要开启BBR,首先需要安装内核4.9及以上版本,可以通过以下命令查看当前内核版本:
uname r
如果当前内核版本低于4.9,可以通过以下命令升级内核:
1、更新系统软件包列表:
sudo aptget update
2、安装内核升级工具:
sudo aptget install buildessential linuxheadersgeneric
3、下载内核4.9源码:
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux4.9.tar.xz
4、解压缩源码包:
tar xf linux4.9.tar.xz
5、进入解压后的目录:
cd linux4.9
6、配置内核选项:
make menuconfig
在菜单中选择“Networking options” > “TCP congestion control”,勾选“BBR (Newreno)”,然后保存退出。
7、编译并安装新内核:
make j$(nproc) && sudo make modules_install && sudo make install && sudo updategrub
重启服务器后,使用以下命令查看新内核版本:
uname r
启用BBR模块
安装新内核后,需要启用BBR模块,可以通过以下命令启用:
1、查看当前可用的内核模块:
lsmod | grep bbr
如果没有输出,说明BBR模块未启用,接下来,我们需要创建一个新的配置文件来启用BBR模块,创建一个名为bbr.sh
的文件,内容如下:
#!/bin/bash echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl p /etc/sysctl.conf
给脚本添加可执行权限:
chmod +x bbr.sh
2、运行脚本启用BBR模块:
sudo ./bbr.sh
验证BBR是否生效
要验证BBR是否生效,可以使用ping
命令进行测试,可以分别对本地和远程服务器进行测试:
1、测试本地服务器:
ping c 10 i 0.2 w 1 http://localhost/path/to/resource || echo "Failed to send packets." && exit 1; sleep 2; echo "Done testing." || exit 1; sleep 2; echo "All tests passed." || exit 1; sleep 2; echo "Testing completed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill SIGINT $$ || exit 1; sleep 2; echo "Process killed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill TERM $$ || exit 1; sleep 2; echo "Process terminated successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill KILL $$ || exit 1; sleep 2; echo "Process killed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill TERM $$ || exit 1; sleep 2; echo "Process terminated successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill KILL $$ || exit 1; sleep 2; echo "Process killed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill TERM $$ || exit 1; sleep 2; echo "Process terminated successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill KILL $$ || exit 1; sleep 2; echo "Process killed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill TERM $$ || exit 1; sleep 2; echo "Process terminated successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill KILL $$ || exit 1; sleep 2; echo "Process killed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill TERM $$ || exit 1; sleep 2; echo "Process terminated successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill KILL $$ || exit 1; sleep 2; echo "Process killed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill TERM $$ || exit 1; sleep 2; echo "Process terminated successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill KILL $$ || exit 1; sleep 2; echo "Process killed successfully." || exit 1; sleep 2; echo "Exiting." || exit 1; sleep 2; pkill TERM $$ || exit 1; sleep
最新评论
本站CDN与莫名CDN同款、亚太CDN、速度还不错,值得推荐。
感谢推荐我们公司产品、有什么活动会第一时间公布!
我在用这类站群服务器、还可以. 用很多年了。