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 小时前
OpenCode AI 编程:Ubuntu 24.04 环境安装与使用指南
linux·服务器·网络·人工智能·tcp/ip·ubuntu
崇山峻岭之间8 小时前
Keil5输出hex转换为bin的设置
linux·运维·服务器
HERR_QQ9 小时前
强化学习的数学原理 学习笔记
人工智能·笔记·学习·自动驾驶
Hoxy.R9 小时前
KingbaseES读写分离高可用集群扩容、备库重建与故障切换实战
运维·数据库
谷雪_6589 小时前
Linux 网络命名空间:从内核原理到企业级容器网络架构全景实战
linux·网络·架构
qq_1631357510 小时前
Linux 【03- chgrp命令超详细教程】
linux
考虑考虑10 小时前
nginx配置ssl
运维·后端·nginx
我会尽全力 乐观而坚强11 小时前
MySQL库与表的操作
linux·数据库·mysql
着迷不白11 小时前
Linux 磁盘管理完全指南:分区、文件系统、挂载与 LVM 实战
linux·运维·服务器
山川而川-R11 小时前
LangChain
linux·运维·服务器