BBR is a TCP network congestion optimization algorithm open-sourced by Google, which can accelerate the access speed of visitors to your server. Especially for overseas servers, enabling the BBR algorithm can be
Website OptimizationIt is somewhat helpful. Here, Naiba will use the CentOS7 system to demonstrate how to install the new kernel version (because BBR requires kernel 4.9 or higher) and enable BBR acceleration.
Steps to Install the New Kernel on CentOS7
First, check the current server's kernel version.
uname -sr
The uname command is used to print information about the current system (kernel version, hardware architecture, hostname, and operating system type, etc.).
-a或--all:显示全部的信息;
-m或--machine:显示电脑类型;
-n或-nodename:显示在网络上的主机名称;
-r或--release:显示操作系统的发行编号;
-s或--sysname:显示操作系统名称;
-v:显示操作系统的版本;
-p或--processor:输出处理器类型或"unknown";
-i或--hardware-platform:输出硬件平台或"unknown";
-o或--operating-system:输出操作系统名称;
--help:显示帮助;
--version:显示版本信息。
The BBR kernel requirement is 4.9+. Typically, the kernel version you get from the above command is around 3.x. Next, enable the ELRepo repository.
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

Then install the new stable version of the kernel.
yum --enablerepo=elrepo-kernel install kernel-ml -y
After installation, use the following command to check if the installation was successful.
rpm -qa | grep kernel
My display is as follows:
kernel-3.10.0-862.14.4.el7.x86_64
kernel-ml-5.3.8-1.el7.elrepo.x86_64
kernel-3.10.0-1062.4.1.el7.x86_64
kernel-headers-3.10.0-1062.4.1.el7.x86_64
kernel-3.10.0-957.5.1.el7.x86_64
kernel-3.10.0-1062.1.2.el7.x86_64
kernel-tools-3.10.0-1062.4.1.el7.x86_64
kernel-tools-libs-3.10.0-1062.4.1.el7.x86_64
kernel-3.10.0-957.1.3.el7.x86_64
Among them, kernel-ml-5.3.8-1.el7.elrepo.x86_64 is the newly installed kernel version (the kernel version may have changed by the time you read this tutorial, adapt accordingly). Next, you need to set the system boot order using the following command.
sudo egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
My display is as follows:
CentOS Linux (5.3.8-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1062.4.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-1062.1.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.5.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-957.1.3.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-862.14.4.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-618ca2de6e204efbb013b592564ef36a) 7 (Core)
The first entry is CentOS Linux (5.3.8-1.el7.elrepo.x86_64) 7 (Core). Count from the first row as 0, then 1, 2, 3, and so on. See which number your new kernel is. Then enter the following command (example command is for row 1).
sudo grub2-set-default 0
Next, restart the server.
reboot
Check the kernel version again.
uname -r
If the kernel version shows 4.9 or higher (at the time of this update, the new version was 5.3.8), it proves the installation was successful. Rebuild the kernel configuration.
grub2-mkconfig -o /boot/grub2/grub.cfg
Restart the system to verify; if there are no issues, it's OK.
Enable BBR on the New Kernel in CentOS7
To enable the new kernel on the freshly installed CentOS7, simply copy and execute the code below.
echo 'net.core.default_qdisc=fq' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Then enter the following command to check if BBR was successfully enabled.
sudo sysctl net.ipv4.tcp_available_congestion_control
If successful, the output should look like this.
net.ipv4.tcp_available_congestion_control = bbr cubic reno
Continue verification.
sudo sysctl -n net.ipv4.tcp_congestion_control
The output should be.
bbr
Finally, check if the kernel module is loaded.
lsmod | grep bbr
The output should be similar to the following.
tcp_bbr 16384 0
What is the use of enabling BBR?
In simple terms, enabling BBR can optimize your website's access speed to a certain extent. For example, Naiba's notes use WordPress, and BBR can also provide some acceleration optimization for WordPress websites. Of course, since Naiba uses domestic servers, the acceleration effect of BBR won't be very significant. BBR is an open-source TCP network congestion optimization algorithm from Google. TCP BBR aims to solve two problems: fully utilizing bandwidth on network links with a certain packet loss rate, and reducing buffer occupancy on network links to lower latency. The goal of TCP congestion control is to maximize the utilization of bandwidth on bottleneck links in the network. Open-source address:
https://github.com/google/bbrBBR and BBR2 One-Click Packages
What is BBR2?
BBR2 is currently still in preview, an upgraded version of BBR, and not yet mature enough; it is not recommended for production environments. For detailed information on BBR2, refer to:
https://github.com/google/bbr/blob/v2alpha/README.mdThe documentation also includes a tutorial and steps for manually installing BBR2, which won't be copied here.
bbr2 one-click package
Warning: Changing the kernel carries risks. If you are unable to boot after using this script and incur losses, no responsibility will be taken. Recommended system: Debian 10 x86_64. Theoretically supports Debian 8+, Ubuntu 16.04+. Only applicable to KVM virtual architecture VPS; do not attempt on OVZ, Xen, or dedicated servers. Only applicable to 64-bit (x86_64) systems; x86 is not supported,
CentOS and other systems are not supported. Tested and passed on BandwagonHost Debian 8, 9, 10, and Ubuntu 16.04, 18.04 (Ubuntu 14.04 failed). Tested and passed on Debian 10 systems from the following providers: Oracle Public Cloud, DMIT, OLVPS, AlibabaCloud. Debian 10 installation success rate: 100%. CentOS users are advised to use BBR or attempt manual installation of BBR2.
wget --no-check-certificate -q -O bbr2.sh "https://raw.githubusercontent.com/yeyingorg/bbr2.sh/master/bbr2.sh" && chmod +x bbr2.sh && bash bbr2.sh auto
Important! Please restart the system after enabling/disabling BBR/ECN. It has been found that the script may have bugs causing it not to take effect or coexist with old acceleration methods like BBR.BBR one-click package
The BBR one-click package supports more systems, but the prerequisite is that the kernel version must support BBR. If the kernel version is insufficient, you still need to manually update the kernel. System support: CentOS 6+, Debian 7+, Ubuntu 12+. Virtualization technology: All except OpenVZ, such as KVM, Xen, VMware, etc. Memory requirement: ≥128M.
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
bbr plus one-click package
BBR Plus is an optimization of the original BBR with parameter adjustments, providing better acceleration effects on certain machines compared to the original version. The BBR Plus one-click installation script introduced in this article is from netizen cx9208. In addition to BBR Plus, it also integrates one-click installations for the original BBR, modified BBR, and LotServer (Sharp Speed), making it a four-in-one version where all four versions can be switched between. Applicable architectures: KVM / Xen; OpenVZ (OVZ) is not supported. Applicable systems: CentOS 7, Debian 8, Debian 9, Ubuntu 16.04, Ubuntu 18.04.
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.