概述
之前抱着试试看的心态入手了Virmach 最便宜的KVM构架的VPS
没想到速度如此之慢…… 跟国内的链接速度实在感人……
到手折腾了一下,今天重装成CentOS7的系统
最近很火的Google TCP-BBR优化算法可以在KVM构架的VPS里面开启,今天就试试了。
这是2016年9月份才开源的一个优化网络拥堵的算法。
开源地址
注意这不是Google官方的产品。
使用必读
不支持OpenVZ虚拟!
安装前需要备份重要数据,安装完可能会导致系统无法启动!
系统无法修改请尝试修改引导!或者重装系统!
安装方式
1. 安装elrepo提供的kernel4.9
增加elrepo源
cat > /etc/yum.repos.d/elrepo.repo << EOF [elrepo-kernel] name=ELRepo.org Community Enterprise Linux Kernel Repository - el7 baseurl=http://elrepo.org/linux/kernel/el7/\$basearch/ http://mirrors.coreix.net/elrepo/kernel/el7/\$basearch/ http://jur-linux.org/download/elrepo/kernel/el7/\$basearch/ http://repos.lax-noc.com/elrepo/kernel/el7/\$basearch/ http://mirror.ventraip.net.au/elrepo/kernel/el7/\$basearch/ enabled=1 gpgcheck=0 EOF
可能存在yum更新内核时候找不到升级包,请检查/etc/yum.conf是否过滤了kernel
找到改文件将exclude=kernel* centos-release*注销,再尝试安装
安装elrepo替换4.9内核及grub2
yum -y install kernel-ml grub2
查看4.9内核是否安装成功
ls -l /boot/vmlinuz*
回显结果类似:
-rwxr-xr-x. 1 root root 5393008 Mar 4 16:31 /boot/vmlinuz-0-rescue-56751acc5351469882eb49d16e0d7f16 -rwxr-xr-x. 1 root root 5393328 Dec 25 12:00 /boot/vmlinuz-0-rescue-8c51b04886234e47bf5385321ac3bcae -rwxr-xr-x. 1 root root 5029136 Apr 15 2015 /boot/vmlinuz-0-rescue-f93f471fcefa4190a918621cd9b830e9 -rwxr-xr-x. 1 root root 5393008 Mar 3 08:15 /boot/vmlinuz-3.10.0-514.10.2.el7.x86_64 -rwxr-xr-x. 1 root root 5393328 Dec 7 07:18 /boot/vmlinuz-3.10.0-514.2.2.el7.x86_64 -rwxr-xr-x. 1 root root 6192368 Feb 27 09:45 /boot/vmlinuz-4.10.1-1.el7.elrepo.x86_64
2. 替换CentOS7内核
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
回显结果类似:
CentOS Linux (4.10.1-1.el7.elrepo.x86_64) 7 (Core) CentOS Linux (4.10.1-1.el7.elrepo.x86_64) 7 (Core) with debugging CentOS Linux 7 Rescue 56751acc5351469882eb49d16e0d7f16 (3.10.0-514.10.2.el7.x86_64) CentOS Linux 7 Rescue 56751acc5351469882eb49d16e0d7f16 (3.10.0-514.10.2.el7.x86_64) with debugging CentOS Linux (3.10.0-514.10.2.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-514.10.2.el7.x86_64) 7 (Core) with debugging CentOS Linux 7 Rescue 8c51b04886234e47bf5385321ac3bcae (3.10.0-514.2.2.el7.x86_64) CentOS Linux 7 Rescue 8c51b04886234e47bf5385321ac3bcae (3.10.0-514.2.2.el7.x86_64) with debugging CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core) with debugging CentOS Linux 7 (Core), with Linux 0-rescue-f93f471fcefa4190a918621cd9b830e9
grub2-set-default 0,切换到新内核
grub2-set-default 0
重启服务器:
reboot
查看内核版本
uname -a
回显结果类似:
Linux DeterminedJaded-VM 4.10.1-1.el7.elrepo.x86_64 #1 SMP Sun Feb 26 19:47:48 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
3. 开启TCP-BBR
cat >>/etc/sysctl.conf << EOF net.core.default_qdisc=fq net.ipv4.tcp_congestion_control=bbr EOF
内核参数生效:
sysctl -p
回显结果类似:
fs.file-max = 65535 net.ipv4.tcp_max_tw_buckets = 60000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.ipv4.tcp_max_syn_backlog = 65536 net.core.netdev_max_backlog = 32768 net.core.somaxconn = 32768 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_timestamps = 1 net.ipv4.tcp_fin_timeout = 20 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.ip_local_port_range = 1024 65000 net.nf_conntrack_max = 6553500 net.netfilter.nf_conntrack_max = 6553500 net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60 net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120 net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120 net.netfilter.nf_conntrack_tcp_timeout_established = 3600 net.core.default_qdisc = fq net.ipv4.tcp_congestion_control = bbr
查看bbr是否生效:
sysctl net.ipv4.tcp_available_congestion_control
回显结果类似:
net.ipv4.tcp_available_congestion_control = bbr cubic reno
lsmod | grep bbr
回显结果显示:
tcp_bbr 16384 0
至此全部修改结束。
结论
对于与国内连接速度差的vps来说,开启Google TCP-BBR优化算法并没有什么卵用……
本站还架设在OPENVZ构架的RamNode的VPS上,速度明显比Virmach上的快太多了。
以上。