进阶 docs.nethermind.io 2026-11-13 08:27:03 · 9 阅读

第7章 安装 Nethermind

版本:2.2.0 安装 Nethermind Nethermind 有多种安装方式: - 通过包管理器安装 - 直接下载独立安装包 - 使用 Docker 容器 - 从源码构建 前提条件​ info 此项不适用于 Docker 发行版。 安装 Nethermind 之前,你的平台可能需要满足以下前提条件。 Linux Windows macOS 无需额外操作 虽然 Windows 新版本自带较新的 Microsoft Visual C++ Redistributable,但某些情况下可能需要更新:winget install --id Microsoft.VCRedist.2015+.x64
无需额外操作 包管理器​ 包管理器是安装 Nethermind 最简单快捷的方式。 Linux Windows macOS 在 Ubuntu 及其他支持 PPA 的 Linux 发行版上,可以通过 Launchpad PPA 安装 Nethermind。 首先,添加 Nethermind 软件源: sudo add-apt-repository ppa:nethermindeth/nethermind

# 如果提示找不到该命令,请先执行
# sudo apt-get install software-properties-common
然后安装 Nethermind: sudo apt-get update
sudo apt-get install nethermind
在 Windows 上,可以通过 Windows Package Manager 安装: winget install --id Nethermind.Nethermind -e
在 macOS 上,可以通过 Homebrew 安装。 首先,添加 Nethermind 软件源: brew tap nethermindeth/nethermind
然后安装 Nethermind: brew install nethermind
更多操作说明请参阅 Running a node。 独立安装包​ 直接下载安装包更灵活:可以指定 Nethermind 版本、选择安装位置,并避免自动更新。 GitHub Releases 提供 Linux、Windows 和 macOS 平台、面向 x86-64 和 AArch64(ARM64)CPU 架构的 ZIP 压缩包。 签名​ 为了保障安全,Nethermind 为每个安装包提供单独的 .asc 签名文件(分离式签名),使用以下密钥签名:AD12 7976 5093 C675 9CD8 A400 24A7 7461 6F1E 617E 验证前,先导入上述签名密钥: gpg --keyserver keyserver.ubuntu.com --recv-keys 24A774616F1E617E
然后下载对应的 .asc 文件来验证所选安装包,例如: gpg --verify nethermind-1.35.8-c066aee2-linux-x64.zip.asc nethermind-1.35.8-c066aee2-linux-x64.zip
配置为 Linux 服务 将 Nethermind 安装为 Linux systemd 服务只需几个简单步骤: 为 Nethermind 创建独立的用户和组,并按如下方式配置: # 创建新用户和组
sudo useradd -m -s /bin/bash nethermind

# 提高可打开文件的最大数量
sudo bash -c 'echo "nethermind soft nofile 100000" > /etc/security/limits.d/nethermind.conf'
sudo bash -c 'echo "nethermind hard nofile 100000" >> /etc/security/limits.d/nethermind.conf'

# 切换到 nethermind 用户
sudo su -l nethermind

# 创建所需目录
# 注意,此时主目录(~)为 /home/nethermind
mkdir ~/bin
mkdir ~/data
下载 Nethermind,并将包内容解压至上一步创建的 ~/bin 目录。 在 ~/.env 文件中配置 Nethermind 选项: ~/.env# 必需项
NETHERMIND_CONFIG="mainnet"

# 可选项
NETHERMIND_HEALTHCHECKSCONFIG_ENABLED="true"
可用选项详见“配置”章节。 创建 ~/nethermind.service 单元文件: ~/nethermind.service[Unit]
Description=Nethermind node
Documentation=https://docs.nethermind.io
After=network.target

[Service]
User=nethermind
Group=nethermind
EnvironmentFile=/home/nethermind/.env
WorkingDirectory=/home/nethermind
ExecStart=/home/nethermind/bin/nethermind --data-dir /home/nethermind/data
Restart=on-failure
LimitNOFILE=1000000

[Install]
WantedBy=default.target
最后,配置 Linux 服务: # 将单元文件移动至 systemd 目录
sudo mv nethermind.service /etc/systemd/system

# 重新加载 systemd 守护进程
sudo systemctl daemon-reload

# 启动服务
sudo systemctl start nethermind

# 可选:配置服务开机自启
sudo systemctl enable nethermind
完成!为确保服务正常运行,请查看其状态: sudo systemctl status nethermind
要监控 Nethermind 输出,请执行: journalctl -u nethermind -f
更多操作说明,请参阅“运行节点”。 Docker 容器 Nethermind 的 Docker 镜像可在 Docker Hub 获取。 这些 Docker 镜像基于 Ubuntu 26.04,支持 x86-64 和 AArch64 (ARM64) CPU 架构。标签如下: latest:Nethermind 的最新版本(默认标签)。 latest-chiseled:Nethermind 最新版本的无根且精简镜像。
出于安全考虑,该镜像只包含必需的组件,并以 UID/GID 为 64198 的非 root 应用用户运行。 x.x.x:Nethermind 的特定版本,例如 1.27.0。 x.x.x-chiseled:特定版本的 rootless、chiseled 镜像,例如 1.27.0-chiseled。 例如,要从镜像仓库下载最新的 chiseled 镜像,运行: docker pull nethermind/nethermind:latest-chiseled
启动容器: docker run -it nethermind/nethermind:latest-chiseled
默认暴露以下端口: 8545:TCP,用于 JSON-RPC 接口 8551:TCP,用于共识客户端的 JSON-RPC 接口 30303:TCP 和 UDP,用于 P2P 网络 tip强烈建议将数据卷挂载为 Nethermind 的数据目录,以保证容器重启后已同步的数据不会丢失。 默认提供以下挂载点: /nethermind/nethermind_db:存储数据库 /nethermind/logs:存储日志 /nethermind/keystore:存储密钥 要为上述每个目录分别挂载独立的数据卷,运行: docker run -it \
--mount type=bind,source=path/to/db,target=/nethermind/nethermind_db \
--mount type=bind,source=path/to/logs,target=/nethermind/logs \
--mount type=bind,source=path/to/keystore,target=/nethermind/keystore \
nethermind/nethermind
也可以只用一个数据卷作为 Nethermind 的数据目录: docker run -it \
--mount type=bind,source=path/to/data_dir,target=/nethermind/data_dir \
nethermind/nethermind --data-dir /nethermind/data_dir
注意,任何 Nethermind 的配置选项都可以附加在命令末尾,例如这里的 --data-dir。更多说明请参阅 Running a node。 要自行构建 Docker 镜像,请参阅 Building Docker image。

评论 (0)