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 会误判服务已退出。

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


相关推荐
分布式存储与RustFS13 分钟前
给 RustFS 桶加一层内存缓存:用 Alluxio 让热数据少跑一遍网络
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
Oiiouui40 分钟前
linux服务器部署Logto后端与对应前端的实现
linux·服务器·前端·后端
ITKEY_1 小时前
用 Emacs Dired 实现 em:退出文件管理器后,让终端自动切换目录
linux·服务器·emacs
wt95271 小时前
VMware 虚拟机磁盘扩容实战文档(Ubuntu 22.04 + LVM)
linux·后端
就像楞次定律1 小时前
【Linux 学习记之二】C++ 构建体系与底层链接机制的深度透视(2)
linux·后端
Decay__2 小时前
22_MySQL 运维自动化平台 —— 部署编排 + 监控 + 巡检 + 告警 + 工单闭环一体化
运维·数据库·sql·mysql·架构
无足鸟ICT2 小时前
【RHCA+】slabtop命令(查看slab缓存)
linux
且从容.2 小时前
Ubuntu 安装 Docker
linux·ubuntu·docker
缘来是你远去是我2 小时前
本地个人笔记exe
笔记
青梅味猪大肠3 小时前
【操作系统-60】临近适应算法
java·linux·开发语言·嵌入式硬件·算法·操作系统