一、安装BBR
1、安装BBR内核
#CentOS 6系统
#导入ELRepo公钥
wget https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm --import RPM-GPG-KEY-elrepo.org
#安装ELRepo
rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
#升级最新内核
yum --enablerepo=elrepo-kernel install kernel-ml -y
#调整内核启动顺序
sed -i '/default=/d' /boot/grub/grub.conf && echo -e "\ndefault=0\c" >> /boot/grub/grub.conf
#重启
reboot
#CentOS 7系统
#导入ELRepo公钥
wget https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm --import RPM-GPG-KEY-elrepo.org
#安装ELRepo
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
#升级最新内核
yum --enablerepo=elrepo-kernel install kernel-ml -y
#调整内核启动顺序
grub2-mkconfig -o /boot/grub2/grub.cfg && grub2-set-default 0
#重启
reboot
2.开启BBR
#查看最新内核,如果大于4.9,则进行下一步
uname -r
#修改配置
cat >>/etc/sysctl.conf << EOF
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
EOF
#使配置生效
sysctl -p
#检查生效,输出带有tcp_bbr 20480 0即生效
lsmod | grep bbr
二、安装魔改BBR
1、安装新内核
#CentOS 6系统
#下载并安装内核
wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-4.12.10-1.el6.elrepo.x86_64.rpm && yum -y install kernel-ml-4.12.10-1.el6.elrepo.x86_64.rpm
wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-devel-4.12.10-1.el6.elrepo.x86_64.rpm && yum -y install kernel-ml-devel-4.12.10-1.el6.elrepo.x86_64.rpm
wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-headers-4.12.10-1.el6.elrepo.x86_64.rpm && yum -y install kernel-ml-headers-4.12.10-1.el6.elrepo.x86_64.rpm
#调整内核启动顺序
sed -i '/default=/d' /boot/grub/grub.conf && echo -e "\ndefault=0\c" >> /boot/grub/grub.conf
#重启
reboot
#CentOS 7系统
#下载并安装内核
wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-4.12.10-1.el7.elrepo.x86_64.rpm && yum -y install kernel-ml-4.12.10-1.el7.elrepo.x86_64.rpm
wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-devel-4.12.10-1.el7.elrepo.x86_64.rpm && yum -y install kernel-ml-devel-4.12.10-1.el7.elrepo.x86_64.rpm
wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-headers-4.12.10-1.el7.elrepo.x86_64.rpm && yum -y install kernel-ml-headers-4.12.10-1.el7.elrepo.x86_64.rpm
#调整内核启动顺序
grub2-mkconfig -o /boot/grub2/grub.cfg && grub2-set-default 0
#重启
reboot
检查当前已安装内核,并删除新内核以外的内核
rpm -qa | grep kernel
yum remove -y 内核名
3、开启魔改BBR
安装魔改BBR
#安装依赖
yum -y install make gcc
wget -O ./tcp_tsunami.c https://www.moerats.com/usr/down/CentOS_Kernel/tcp_tsunami.c
#安装魔改BBR
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
sysctl -p
检查开启状态
lsmod | grep tsunami
如果返回tcp_tsunami 16384 26类似信息,则开启成功。
转自Rat's Blog 原文链接:https://www.moerats.com/archives/580/
文章评论