n2n supernode Linux完整部署笔记,包含离线部署,

🚀 n2n supernode 完整部署笔记

(适用于 CentOS/RHEL 系列无网/有网环境)


🔧 一、环境准备(有网机器)

  1. 安装编译依赖

    bash 复制代码
    yum install -y git gcc make
  2. 克隆 n2n 源码

    bash 复制代码
    git clone https://github.com/ntop/n2n.git
    cd n2n
  3. 生成配置脚本

    bash 复制代码
    ./autogen.sh
  4. 配置编译选项

    bash 复制代码
    ./configure
  5. 编译生成二进制

    bash 复制代码
    make
  6. 打包二进制(离线传输用)

    bash 复制代码
    tar -czf n2n-offline.tar.gz supernode edge

📦 二、离线传输到目标服务器

  1. 将 n2n-offline.tar.gz 通过 U 盘/SCP 等方式传到离线服务器

  2. 解压文件

    bash 复制代码
    tar -xzf n2n-offline.tar.gz
  3. 复制到系统路径并添加执行权限

    bash 复制代码
    cp supernode /usr/local/bin/
    chmod +x /usr/local/bin/supernode

⚙️ 三、配置 Systemd 服务

  1. 创建服务文件

    bash 复制代码
    cat > /etc/systemd/system/supernode.service << 'EOF'
    [Unit]
    Description=N2N Supernode Service
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/usr/local/bin/supernode -p 8016 -v -f
    Restart=on-failure
    RestartSec=5
    StandardOutput=append:/var/log/supernode.log
    StandardError=append:/var/log/supernode.log
    
    [Install]
    WantedBy=multi-user.target
    EOF
  2. 创建日志文件

    bash 复制代码
    touch /var/log/supernode.log
    chmod 644 /var/log/supernode.log

🚀 四、启动并验证服务

  1. 重新加载 Systemd 配置

    bash 复制代码
    systemctl daemon-reload
  2. 设置开机自启并启动服务

    bash 复制代码
    systemctl enable supernode.service
    systemctl start supernode.service
  3. 验证服务状态

    bash 复制代码
    systemctl status supernode.service

    ✅ 正常输出:Active: active (running)

  4. 验证端口监听

    bash 复制代码
    ss -untple | grep 8016

    ✅ 正常输出:UDP 和 TCP 都在 8016 端口监听


查看版本号是 -h

🛠️ n2n supernode 常见问题排查清单

🔍 1. 服务无法启动

  • 现象 :systemctl status supernode.service 显示 inactive (dead)
  • 排查步骤 :
    1. 检查 /usr/local/bin/supernode 是否为二进制文件:

      bash 复制代码
      file /usr/local/bin/supernode

      正确输出应包含 ELF 64-bit LSB executable。

    2. 手动执行二进制,看是否报错:

      bash 复制代码
      /usr/local/bin/supernode -p 8016 -v -f
    3. 检查服务文件中的 ExecStart 路径是否正确,是否包含 -f 参数。


🔍 2. 端口未监听

  • 现象 :ss -untple | grep 8016 无输出
  • 排查步骤 :
    1. 确认服务正在运行:systemctl status supernode.service

    2. 检查启动参数是否正确:supernode 用 -p 指定端口,而非 -l。

    3. 检查防火墙是否开放 8016 端口:

      bash 复制代码
      firewall-cmd --list-ports | grep 8016
      # 若未开放,执行:
      firewall-cmd --add-port=8016/tcp --add-port=8016/udp --permanent
      firewall-cmd --reload

🔍 3. Systemd 服务报错

  • 现象 :systemctl status 显示 status=127
  • 排查步骤 :
    1. 确认 /usr/local/bin/supernode 存在且有执行权限:

      bash 复制代码
      ls -l /usr/local/bin/supernode

      权限应包含 x(如 -rwxr-xr-x)。

    2. 确认该文件不是 OpenWRT 脚本,而是编译后的二进制。


🔍 4. 开机自启失效

  • 现象 :systemctl enable supernode.service 报错
  • 排查步骤 :
    1. 检查服务文件的 [Install] 部分:

      ini 复制代码
      [Install]
      WantedBy=multi-user.target

      确保这一行存在且无注释、无拼写错误。

    2. 重新加载配置并再次启用:

      bash 复制代码
      systemctl daemon-reload
      systemctl enable supernode.service

🔍 5. 日志排查

  • 查看实时日志 :

    bash 复制代码
    tail -f /var/log/supernode.log
  • 查看 Systemd 日志 :

    bash 复制代码
    journalctl -u supernode.service -f

📝 关键问题总结

Systemd 服务适配 :必须用 -f 参数强制 supernode 前台运行,否则 Systemd 会误判服务已退出。

中间遇到好多坑,不过都已经处理完了,我这配置直接拿去用就行。


相关推荐
大哥您好8 小时前
QEMU 11.1.2 多架构编译指南(x86_64 / aarch64 / riscv64)
linux·服务器
hanlin039 小时前
刷题笔记:力扣第32题-最长有效括号
笔记·算法·leetcode
道满科技9 小时前
Function Calling 参数总出错?只修参数就行
linux·windows·python
Gauss松鼠会9 小时前
高斯数据库(openGauss)的物理存储结构
运维·服务器·数据库·sql·opengauss·经验总结
Android系统攻城狮9 小时前
Linux Gstreamer深度解析之gst_audio_ring_buffer_prepare_read调用流程与实战(七十四)
linux·运维·服务器·gstreamer音视频·音视频进阶
杨云龙UP9 小时前
PostgreSQL 18.4 数据库整库迁移实战:pg_dump 备份与 pg_restore 恢复完整操作手册
运维·服务器·数据库·postgresql·pg_dump·pg_restore
我科绝伦(Huanhuan Zhou)10 小时前
Linux 通用压力测试脚本合集:磁盘 + 网络
linux·网络·压力测试
xian_wwq10 小时前
【学习笔记】Milvus 如何完成一次向量相似度检索,Milvus 索引到底应该怎么选?-15
笔记·学习·milvus
无人生还别怕11 小时前
如何安装任意版本docker
运维·docker·容器
T0uken11 小时前
Colab:SSH 访问免费 GPU Server
运维·ssh