ubuntu20开启bbr
- 行业动态
- 2024-04-22
- 3694
在Ubuntu 20上开启BBR,首先更新系统,然后安装 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
本站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本站,有问题联系侵删!
本文链接:http://www.xixizhuji.com/fuzhu/229113.html