apernet / tcp-brutal

GNU General Public License v3.0
654 stars 70 forks source link

【求助】脚本 1.0.1 安装失败-系统 Ubuntu 20.04.4 LTS Linux 6.6.1 #6

Closed fscarmen closed 11 months ago

fscarmen commented 11 months ago

系统信息

root@sg1:~# hostnamectl
   Static hostname: sg1
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 32f94651ef1046b593be123a24a353b7
           Boot ID: 0e24ce8add424f22aa5e3213d4220ec2
    Virtualization: kvm
  Operating System: Ubuntu 20.04.4 LTS
            Kernel: Linux 6.6.1
      Architecture: x86-64

root@sg1:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

root@sg1:~# uname -a
Linux sg1 6.6.1 #1 SMP PREEMPT_DYNAMIC Fri Nov 10 08:09:00 CST 2023 x86_64 x86_64 x86_64 GNU/Linux

root@sg1:~# dpkg --list | grep linux-image
ii  linux-image-6.6.1                      6.6.1-1                           amd64        Linux kernel, version 6.6.1

安装错误日志

root@sg1:~# bash <(curl -fsSL https://tcp.hy2.sh/)
Checking linux-headers ... ok
Cleaning old installations ... 
Checking installed version ... v1.0.1
Checking latest version ... v1.0.1
Rebuilding DKMS modules as needed ... 

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j2 KERNELRELEASE=6.6.1 KERNEL_DIR=/lib/modules/6.6.1/build all...(bad exit status: 2)
ERROR (dkms apport): binary package for tcp-brutal: 1.0.1 not found
Error! Bad return status for module build on kernel: 6.6.1 (x86_64)
Consult /var/lib/dkms/tcp-brutal/1.0.1/build/make.log for more information.
Enabling auto load kernel module brutal on system boot ... ok
Loading kernel module brutal ... modprobe: FATAL: Module brutal not found in directory /lib/modules/6.6.1
bash <(curl -fsSL https://tcp.hy2.sh): error: Failed to load kernel module, kernel module might not be installed successfully.
bash <(curl -fsSL https://tcp.hy2.sh): warning: tcp-brutal is installed but failed to load.
There is nothing to do today.

root@sg1:~# cat /var/lib/dkms/tcp-brutal/1.0.0/build/make.log
cat: /var/lib/dkms/tcp-brutal/1.0.0/build/make.log: No such file or directory

debug 安装

bash -x install_dkms.sh 
+ set -e
+ SCRIPT_ARGS=("$@")
+ SCRIPT_INITIATOR_URL=https://tcp.hy2.sh
+ SCRIPT_INITIATOR_COMMAND='bash <(curl -fsSL https://tcp.hy2.sh)'
+ REPO_URL=https://github.com/apernet/tcp-brutal
+ HY2_API_BASE_URL=https://api.hy2.io/v1
+ CURL_FLAGS=(-L -f -q --retry 5 --retry-delay 10 --retry-max-time 60)
+ DKMS_MODULE_NAME=tcp-brutal
+ KERNEL_MODULE_NAME=brutal
+ PACKAGE_MANAGEMENT_INSTALL=
++ tput setaf 1
++ has_command tput
++ local _command=tput
++ type -P tput
++ command tput setaf 1
++ tput setaf 1
+ tred=''
++ tput setaf 2
++ has_command tput
++ local _command=tput
++ type -P tput
++ command tput setaf 2
++ tput setaf 2
+ tgreen=''
++ tput setaf 3
++ has_command tput
++ local _command=tput
++ type -P tput
++ command tput setaf 3
++ tput setaf 3
+ tyellow=''
++ tput setaf 4
++ has_command tput
++ local _command=tput
++ type -P tput
++ command tput setaf 4
++ tput setaf 4
+ tblue=''
++ tput setaf 6
++ has_command tput
++ local _command=tput
++ type -P tput
++ command tput setaf 6
++ tput setaf 6
+ taoi=''
++ tput bold
++ has_command tput
++ local _command=tput
++ type -P tput
++ command tput bold
++ tput bold
+ tbold=''
++ tput sgr0
++ has_command tput
++ local _command=tput
++ type -P tput
++ command tput sgr0
++ tput sgr0
+ treset=''
+ main
+ check_show_usage_and_exit
+ case "$1" in
+ [[ 0 -gt 0 ]]
+ check_permission
+ [[ 0 -eq 0 ]]
+ return
+ check_environment
+ check_environment_operating_system
++ uname
+ [[ xLinux == \x\L\i\n\u\x ]]
+ return
+ check_environment_curl
+ has_command curl
+ local _command=curl
+ type -P curl
+ return
+ check_environment_grep
+ has_command grep
+ local _command=grep
+ type -P grep
+ return
+ check_environment_dkms
+ has_command dkms
+ local _command=dkms
+ type -P dkms
+ return
+ check_linux_headers
+ echo -n 'Checking linux-headers ... '
Checking linux-headers ... + is_linux_headers_installed
++ uname -r
+ test -d /lib/modules/6.6.1/build
+ echo ok
ok
+ case "$1" in
+ perform_install
+ local _local_file=
+ local _user_provided_local_file=
+ local _version=
+ local _install_needed=
+ [[ 0 -gt 0 ]]
+ [[ -n '' ]]
+ echo 'Cleaning old installations ... '
Cleaning old installations ... 
+ dkms_remove_modules tcp-brutal 1
+ local _module=tcp-brutal
+ local _keep_latest=1
+ _versions_to_remove=($(dkms_get_installed_versions "$_module"))
++ dkms_get_installed_versions tcp-brutal
++ local _module=tcp-brutal
++ local _dkms_moddir=/var/lib/dkms/tcp-brutal
++ [[ ! -d /var/lib/dkms/tcp-brutal ]]
+++ command ls /var/lib/dkms/tcp-brutal/
+++ ls /var/lib/dkms/tcp-brutal/
++ for file in $(command ls "$_dkms_moddir/")
++ [[ -L /var/lib/dkms/tcp-brutal/1.0.1 ]]
++ echo v1.0.1
+ local _versions_to_remove
+ [[ -n 1 ]]
+ local _latest=
+ local _new_versions_to_remove
+ _new_versions_to_remove=()
+ for version in "${_versions_to_remove[@]}"
++ vercmp v1.0.1 ''
++ local _lhs=1.0.1
++ local _rhs=
++ [[ -n 1.0.1 ]]
++ [[ -n '' ]]
++ [[ x1.0.1 == \x ]]
++ [[ -z 1.0.1 ]]
++ [[ -z '' ]]
++ echo 1
++ return
+ local _vercmp=1
+ [[ 1 -gt 0 ]]
+ [[ -n '' ]]
+ _latest=v1.0.1
+ _versions_to_remove=("${_new_versions_to_remove[@]}")
+ echo -n 'Checking installed version ... '
Checking installed version ... ++ dkms_get_installed_versions tcp-brutal
++ local _module=tcp-brutal
++ local _dkms_moddir=/var/lib/dkms/tcp-brutal
++ [[ ! -d /var/lib/dkms/tcp-brutal ]]
++ head -1
+++ command ls /var/lib/dkms/tcp-brutal/
+++ ls /var/lib/dkms/tcp-brutal/
++ for file in $(command ls "$_dkms_moddir/")
++ [[ -L /var/lib/dkms/tcp-brutal/1.0.1 ]]
++ echo v1.0.1
+ local _installed_version=v1.0.1
+ [[ -n v1.0.1 ]]
+ echo v1.0.1
v1.0.1
+ [[ -z '' ]]
+ [[ -z '' ]]
+ echo -n 'Checking latest version ... '
Checking latest version ... ++ get_latest_version
++ [[ -n '' ]]
+++ mktemp
+++ command mktemp /tmp/brutalinst.XXXXXXXXXX
+++ mktemp /tmp/brutalinst.XXXXXXXXXX
++ local _tmpfile=/tmp/brutalinst.V9GDcpHXXd
++ curl -sS 'https://api.hy2.io/v1/update?cver=installscript&arch=generic&plat=linux&chan=tcp-brutal' -o /tmp/brutalinst.V9GDcpHXXd
++ command curl -L -f -q --retry 5 --retry-delay 10 --retry-max-time 60 -sS 'https://api.hy2.io/v1/update?cver=installscript&arch=generic&plat=linux&chan=tcp-brutal' -o /tmp/brutalinst.V9GDcpHXXd
++ curl -L -f -q --retry 5 --retry-delay 10 --retry-max-time 60 -sS 'https://api.hy2.io/v1/update?cver=installscript&arch=generic&plat=linux&chan=tcp-brutal' -o /tmp/brutalinst.V9GDcpHXXd
+++ grep -oP '"lver":\s*\K"v.*?"' /tmp/brutalinst.V9GDcpHXXd
+++ head -1
++ local '_latest_version="v1.0.1"'
++ _latest_version='v1.0.1"'
++ _latest_version=v1.0.1
++ [[ -n v1.0.1 ]]
++ echo v1.0.1
++ rm -f /tmp/brutalinst.V9GDcpHXXd
+ local _latest_version=v1.0.1
+ [[ -n v1.0.1 ]]
+ echo v1.0.1
v1.0.1
+ _version=v1.0.1
+ [[ -z '' ]]
+ [[ -n v1.0.1 ]]
++ vercmp v1.0.1 v1.0.1
++ local _lhs=1.0.1
++ local _rhs=1.0.1
++ [[ -n 1.0.1 ]]
++ [[ -n 1.0.1 ]]
++ local _clhs=1
++ local _crhs=1
+++ vercmp_segment 1 1
+++ local _lhs=1
+++ local _rhs=1
+++ [[ x1 == \x\1 ]]
+++ echo 0
+++ return
++ local _segcmp=0
++ [[ 0 -ne 0 ]]
++ _lhs=.0.1
++ _lhs=0.1
++ _rhs=.0.1
++ _rhs=0.1
++ [[ -n 0.1 ]]
++ [[ -n 0.1 ]]
++ local _clhs=0
++ local _crhs=0
+++ vercmp_segment 0 0
+++ local _lhs=0
+++ local _rhs=0
+++ [[ x0 == \x\0 ]]
+++ echo 0
+++ return
++ local _segcmp=0
++ [[ 0 -ne 0 ]]
++ _lhs=.1
++ _lhs=1
++ _rhs=.1
++ _rhs=1
++ [[ -n 1 ]]
++ [[ -n 1 ]]
++ local _clhs=1
++ local _crhs=1
+++ vercmp_segment 1 1
+++ local _lhs=1
+++ local _rhs=1
+++ [[ x1 == \x\1 ]]
+++ echo 0
+++ return
++ local _segcmp=0
++ [[ 0 -ne 0 ]]
++ _lhs=
++ _lhs=
++ _rhs=
++ _rhs=
++ [[ -n '' ]]
++ [[ x == \x ]]
++ echo 0
++ return
+ local _vercmp=0
+ [[ 0 -lt 0 ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -z '' ]]
+ [[ -n '' ]]
+ echo 'Rebuilding DKMS modules as needed ... '
Rebuilding DKMS modules as needed ... 
+ dkms autoinstall

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j2 KERNELRELEASE=6.6.1 KERNEL_DIR=/lib/modules/6.6.1/build all...(bad exit status: 2)
ERROR (dkms apport): binary package for tcp-brutal: 1.0.1 not found
Error! Bad return status for module build on kernel: 6.6.1 (x86_64)
Consult /var/lib/dkms/tcp-brutal/1.0.1/build/make.log for more information.
+ kmod_setup_autoload brutal
+ local _module=brutal
+ echo -n 'Enabling auto load kernel module brutal on system boot ... '
Enabling auto load kernel module brutal on system boot ... + echo brutal
+ echo ok
ok
+ [[ -z '' ]]
+ kmod_load_if_unloaded brutal
+ local _module=brutal
+ kmod_is_loaded brutal
+ local _module=brutal
+ lsmod
+ grep -qP '\bbrutal\b'
+ echo -n 'Loading kernel module brutal ... '
Loading kernel module brutal ... + modprobe brutal
modprobe: FATAL: Module brutal not found in directory /lib/modules/6.6.1
+ error 'Failed to load kernel module, kernel module might not be installed successfully.'
+ local '_msg=Failed to load kernel module, kernel module might not be installed successfully.'
++ script_name
++ local _keep_dirname=
++ is_run_from_fd
++ has_prefix install_dkms.sh /dev/
++ local _s=install_dkms.sh
++ local _prefix=/dev/
++ [[ -z /dev/ ]]
++ [[ -z install_dkms.sh ]]
++ [[ xinstall_dkms.sh != \x\i\n\s\t\a\l\l\_\d\k\m\s\.\s\h ]]
++ has_prefix install_dkms.sh /proc/
++ local _s=install_dkms.sh
++ local _prefix=/proc/
++ [[ -z /proc/ ]]
++ [[ -z install_dkms.sh ]]
++ [[ xinstall_dkms.sh != \x\i\n\s\t\a\l\l\_\d\k\m\s\.\s\h ]]
++ has_prefix install_dkms.sh .
++ local _s=install_dkms.sh
++ local _prefix=.
++ [[ -z . ]]
++ [[ -z install_dkms.sh ]]
++ [[ xinstall_dkms.sh != \x\i\n\s\t\a\l\l\_\d\k\m\s\.\s\h ]]
++ [[ -z '' ]]
++ basename install_dkms.sh
++ return
+ echo -e 'install_dkms.sh: error: Failed to load kernel module, kernel module might not be installed successfully.'
install_dkms.sh: error: Failed to load kernel module, kernel module might not be installed successfully.
+ return 1
+ warning 'tcp-brutal is installed but failed to load.'
+ local '_msg=tcp-brutal is installed but failed to load.'
++ script_name
++ local _keep_dirname=
++ is_run_from_fd
++ has_prefix install_dkms.sh /dev/
++ local _s=install_dkms.sh
++ local _prefix=/dev/
++ [[ -z /dev/ ]]
++ [[ -z install_dkms.sh ]]
++ [[ xinstall_dkms.sh != \x\i\n\s\t\a\l\l\_\d\k\m\s\.\s\h ]]
++ has_prefix install_dkms.sh /proc/
++ local _s=install_dkms.sh
++ local _prefix=/proc/
++ [[ -z /proc/ ]]
++ [[ -z install_dkms.sh ]]
++ [[ xinstall_dkms.sh != \x\i\n\s\t\a\l\l\_\d\k\m\s\.\s\h ]]
++ has_prefix install_dkms.sh .
++ local _s=install_dkms.sh
++ local _prefix=.
++ [[ -z . ]]
++ [[ -z install_dkms.sh ]]
++ [[ xinstall_dkms.sh != \x\i\n\s\t\a\l\l\_\d\k\m\s\.\s\h ]]
++ [[ -z '' ]]
++ basename install_dkms.sh
++ return
+ echo -e 'install_dkms.sh: warning: tcp-brutal is installed but failed to load.'
install_dkms.sh: warning: tcp-brutal is installed but failed to load.
+ echo 'There is nothing to do today.'
There is nothing to do today.
+ exit 0
haruue commented 11 months ago

内核模块编译失败了, 编译错误在这个文件里。

/var/lib/dkms/tcp-brutal/1.0.1/build/make.log

另外我注意到你在 Ubuntu 20.04 LTS 上使用 6.6.1 内核, 这类问题通常是你系统里的 gcc 太旧, 无法为你额外安装的最新内核编译内核模块。

升级编译器通常可以解决这个问题(但是相当麻烦), 我通常建议把系统升级到较新版本(例如 Ubuntu 22.04 LTS), 或者降级内核到 5.x(通常是需要卸载你安装的最新内核, 并在重启后用 uname -r 确认是否切换成功)。

fscarmen commented 11 months ago

内核模块编译失败了, 编译错误在这个文件里。

/var/lib/dkms/tcp-brutal/1.0.1/build/make.log

另外我注意到你在 Ubuntu 20.04 LTS 上使用 6.6.1 内核, 这类问题通常是你系统里的 gcc 太旧, 无法为你额外安装的最新内核编译内核模块。

升级编译器通常可以解决这个问题(但是相当麻烦), 我通常建议把系统升级到较新版本(例如 Ubuntu 22.04 LTS), 或者降级内核到 5.x(通常是需要卸载你安装的最新内核, 并在重启后用 uname -r 确认是否切换成功)。

搞掂了,把 Ubuntu 20.04 升级为 22.04 之后就可以正确安装了。 还想问两个问题:

  1. 不是从查内核加载的方法,有些什么更直观办法看正常工作呢?(像多路复用,可以用并发TCP来看)
  2. 与BBR搭配有没有问题呢?相互不影响还是只能两者选其一的?
jameqq commented 11 months ago

E: Unable to locate package linux-headers-6.1.0-9-amd64 E: Couldn't find any package by glob 'linux-headers-6.1.0-9-amd64' bash <(curl -fsSL https://tcp.hy2.sh): error: Cannot install 'linux-headers-6.1.0-9-amd64' with detected package manager, please install it manually.

这是什么问题

haruue commented 11 months ago

@jameqq

E: Unable to locate package linux-headers-6.1.0-9-amd64 E: Couldn't find any package by glob 'linux-headers-6.1.0-9-amd64' bash <(curl -fsSL https://tcp.hy2.sh): error: Cannot install 'linux-headers-6.1.0-9-amd64' with detected package manager, please install it manually.

看起来你在用 Debian 12 + 内核包版本 6.1.0-9 , 但是 Debian 软件仓库已经不再提供 6.1.0-9 内核(及其 headers)的下载。 你可以试试先升级系统(通过 apt update && apt upgrade ), 然后重启, 再重新运行此脚本。

xqdoo00o commented 11 months ago

内核版本不是仓库最新的话,确实要先升级版本。apt upgrade之类的,不然就会报错

haruue commented 11 months ago

@fscarmen

  1. 不是从查内核加载的方法,有些什么更直观办法看正常工作呢?(像多路复用,可以用并发TCP来看)

可以用仓库 example/ 目录里的 python 测试脚本, 在同一台机器上同时开启 server.pyclient.py 。 并把客户端参数设置成一个比较低的带宽(比如 python client.py 127.0.0.1 10, 连接本机的 server.py , 限速到 10 Mbps), 如果服务端和客户端都能正常启动, 并且测得 Current speed 是你设置的低带宽, 那就是正常工作了。

  1. 与BBR搭配有没有问题呢?相互不影响还是只能两者选其一的?

只有支持 brutal 的应用程序能选择使用 brutal, 不支持 brutal 的应用程序仍然使用你配置的默认拥塞控制(你配置了 bbr 那就是 bbr), 请参考 这里的说明

请保持 bbr 相关配置(例如通过 net.ipv4.tcp_congestion_control=bbr 把 bbr 设置为全局默认的拥塞控制算法), 以保证不支持 brutal 的(绝大部分)应用程序的 TCP 传输速度。

fscarmen commented 11 months ago

@fscarmen

  1. 不是从查内核加载的方法,有些什么更直观办法看正常工作呢?(像多路复用,可以用并发TCP来看)

可以用仓库 example/ 目录里的 python 测试脚本, 在同一台机器上同时开启 server.pyclient.py 。 并把客户端参数设置成一个比较低的带宽(比如 python client.py 127.0.0.1 10, 连接本机的 server.py , 限速到 10 Mbps), 如果服务端和客户端都能正常启动, 并且测得 Current speed 是你设置的低带宽, 那就是正常工作了。

  1. 与BBR搭配有没有问题呢?相互不影响还是只能两者选其一的?

只有支持 brutal 的应用程序能选择使用 brutal, 不支持 brutal 的应用程序仍然使用你配置的默认拥塞控制(你配置了 bbr 那就是 bbr), 请参考 这里的说明

请保持 bbr 相关配置(例如通过 net.ipv4.tcp_congestion_control=bbr 把 bbr 设置为全局默认的拥塞控制算法), 以保证不支持 brutal 的(绝大部分)应用程序的 TCP 传输速度。

谢谢,原来 README.md 都有写了,是我没有先在里面找答案,谢谢!