Total Pageviews

Friday 17 November 2017

使用linhua的黑科技rinetd为openvz VPS开启bbr

使用@linhua的黑科技rinetd为OVZ构架的VPS开启bbr,适用于CentOS/RHEL7+,Ubuntu15+,Debian8+

下载rintd二进制文件(原版bbr和修改版bbr二选一即可):

1. wget --no-check-certificate https://raw.githubusercontent.com/mixool/rinetd/master/rinetd
2. wget --no-check-certificate https://raw.githubusercontent.com/mixool/rinetd/master/rinetd_bbr_powered -O /root/rinetd
  • 修改权限:
    chmod +x rinetd

修改rinetd的配置文件rinetd.conf,添加监听地址:

vi rinetd.conf
# bindadress bindport connectaddress connectport
0.0.0.0 443 0.0.0.0 443
0.0.0.0 80 0.0.0.0 80

设置开机启动

vi /etc/systemd/system/rinetd.service
[Unit]
Description=rinetd

[Service]
ExecStart=/root/rinetd -f -c /root/rinetd.conf raw venet0:0
Restart=always
  
[Install]
WantedBy=multi-user.target

最后执行:

systemctl enable rinetd.service && systemctl start rinetd.service

LKL BBR RINETD  
For more details:linhua55/lkl_study
PS: 推荐使用最新的One-key script  
  • 更新个自己写的一键(rinetd文件不一定是最新的):
    curl https://raw.githubusercontent.com/mixool/script/master/rinetd.sh | bash

from  https://github.com/mixool/rinetd
--------

bbr是使服务器加速的技术。
----------

OPENVZ VPS的Google BBR加速之Rinetd方式

简介


Rinetd 这种方式其实两三个月前就已经有了,是 v2ex 网友 @linhua 的成果,他直接将 BBR 内置到了 Rinetd 里边,比较方便的就能配置出来。也就是由于配置比较简单,我本来没想再写这个的一键配置脚本(@linhua 实现了一个 https://github.com/linhua55/lkl_study),但由于很多朋友使用 haproxy 的方式失败了,网上的脚本也只支持 Ubuntu 16 和 CentOS 7 以上的系统。

手动搭建

仅支持 64 位系统。
1.下载文件到 /usr/bin/rinetd-bbr
2.设置权限
3.创建配置文件
输入以下内容
其中的 443 请改为你的端口
IP 地址统一写 0.0.0.0
4.获取接口名称
看具有公网 IP 的接口名称(比如我的公网 IP 是 10.10.10.10),上面这种的接口是 venet0:0 而不是 venet0
搬瓦工的 OpenVZ 应该都是 venet0:0 接口。
5.启动
注意:将最后的接口改为你上面获取到的接口。在命令最后面加 & 以使其能后台运行。

验证

正常情况下的输出:
查看 iptables 规则:
已经有两条规则了。
from  https://blog.kuoruan.com/119.html
------------------

About

study the LKL(linux kernel library) https://github.com/lkl/linux

lkl_study

study the LKL(linux kernel library) https://github.com/lkl/linux

Only apply to 64Bit Linux with ipv4 network.

Rinetd version(with LKL and raw socket backend)

Compile

  1. compile static library liblkl.a

https://github.com/linhua55/linux/tree/rinetd_bpf

refer to https://github.com/lkl/linux

Linux(LKL)'s kernel configuration file is the .config file in this repository, it need to be placed at the root directory of the LKL repository.

  1. compile rinetd(with lkl)

https://github.com/linhua55/rinetd

refer to https://github.com/linhua55/rinetd/blob/lkl_raw/make.sh

replace /home/vagrant/lkl/linux/tools/lkl/liblkl.a and /home/vagrant/lkl/linux/tools/lkl/include with your actual LKL path.

Release

rinetd(lkl) with bbr powered congestion control

wget "https://github.com/linhua55/lkl_study/releases/download/v1.2/rinetd_bbr_powered" -O /usr/bin/rinetd

rinetd(lkl) with bbr congestion control

wget "https://github.com/linhua55/lkl_study/releases/download/v1.2/rinetd_bbr" -O /usr/bin/rinetd

rinetd(lkl) with pcc congestion control

wget "https://github.com/linhua55/lkl_study/releases/download/v1.2/rinetd_pcc" -O /usr/bin/rinetd

For usage, refer to:

https://gist.github.com/codexss/1d5a834c479bb1532b9f82b23ee2f3fa

https://github.com/mixool/rinetd

https://www.v2ex.com/t/353778#r_4311799

One-key script

Thanks to @phuslu for his one-key script

Usage:

  curl https://raw.githubusercontent.com/linhua55/lkl_study/master/get-rinetd.sh | bash

      The configuration file generated by one-key script is /etc/rinetd-bbr.conf. By default, it only proxy(speed up) port 443and80, modify the port number as needed.

Determine if function

Use top command, view process rinetd's CPU usage. The faster of network speed, the bigger of CPU usage.

Caution:

  1. Dependency: iptables, grep, cut, xargs. Usual linux have these tools,But some linux use firewalld instead of iptables, it need install iptables
  2. For KVM VPS, need to change venet0:0 to the name of the network interface which have KVM's public IP, normally it is eth0

Some technical details

https://linhua55.github.io/2017/04/24/LKL(Linux%20Kernel%20Library)/


from https://github.com/linhua55/lkl_study

No comments:

Post a Comment