chia-plotter跨平台部署实战:Linux、macOS、Windows与Docker安装全流程

原创2026-10-15 19:29:272,230 阅读

chia-plotter跨平台部署实战:Linux、macOS、Windows与Docker安装全流程

chia-plotter 是一个采用流水线(Pipeline)多线程架构的 Chia 造块(Plotter)工具,能像 GPU 一样并行压榨 CPU 算力,从而满速跑满磁盘带宽。本文带你完成 chia-plotter 的跨平台部署:Linux(Ubuntu / Debian / Arch / CentOS)、macOS(Intel 与 Apple Silicon)、Windows,以及最省心的 Docker 容器化安装全流程,新手照着做即可在 10 分钟内编译运行出自己的 chia_plot 可执行文件。

为什么选择 chia-plotter?

在开始安装之前,先 30 秒理解这个项目:

  • 流水线多核并行:把造块过程拆分为 Phase 1~4,每个阶段由多个线程流水线式处理,线程越多,磁盘读写带宽利用率越高(核心逻辑见 src/chia_plot.cpp)
  • 磁盘占用低:<tmpdir> 约需 220 GiB,<tmpdir2>(建议内存盘)约 110 GiB,峰值总占用小于 256 GiB
  • 跨平台:官方支持 Linux、macOS、Windows(预编译包 + Docker)

项目当前版本定义在 include/version.hpp,编译前先用 --version 验证即可。

部署前准备:通用依赖清单

无论哪种系统,依赖都只有两样(详见 README.md 的 Dependencies 部分):

依赖 最低要求 用途
cmake ≥ 3.14(bls-signatures 模块要求) 构建系统
libsodium-dev 最新稳定版 加密原语库

另外需要 C++17 编译器(g++/clang++)、Git。构建入口为 CMakeLists.txt,它会自动拉取 BLAKE3、FSE、bls-signatures 等 lib/ 下的子模块。

Linux 安装:一条命令编译

Ubuntu / Debian 最快安装方法

以 Ubuntu 20.04 为例(Debian 同理,注意 Debian 10 需从 buster-backports 安装 cmake ≥ 3.14):

sudo apt install -y libsodium-dev cmake g++ git build-essential

# 克隆源码(仓库是只读的,仅用于编译)
git clone https://gitcode.com/gh_mirrors/ch/chia-plotter
cd chia-plotter

git submodule update --init
./make_devel.sh
./build/chia_plot --help   # 看到参数列表即安装成功

💡 编译脚本说明:make_devel.sh 是带 -O3 优化的开发构建;追求极致性能可改用 make_release.sh(纯 -O3 发布构建);排查问题可用 make_debug.sh。用 clean_all.sh 可清空 build 目录重新编译。

Arch Linux

sudo pacman -S cmake libsodium gmp gcc11
git clone https://gitcode.com/gh_mirrors/ch/chia-plotter
cd chia-plotter
git submodule update --init
./make_devel.sh

CentOS 7 部署(需要新版工具链)

CentOS 7 默认编译器过旧,需安装 devtoolset:

sudo yum install epel-release -y
sudo yum install cmake3 libsodium libsodium-static centos-release-scl -y
sudo yum install devtoolset-7 -y
ln /usr/bin/cmake3 /usr/bin/cmake
scl enable devtoolset-7 bash

git clone https://gitcode.com/gh_mirrors/ch/chia-plotter
cd chia-plotter && git submodule update --init
./make_devel.sh

编译完成后,二进制文件输出在 build/ 目录,可自由拷贝到同架构的其他机器。

macOS 安装:Intel 与 M 系列芯片通用步骤

macOS 上主要多两步:安装 Xcode 命令行工具和 Homebrew 依赖。

# 1. 安装编译工具链(已有 Xcode 可跳过)
xcode-select --install

# 2. 安装 chia-plotter 的依赖
brew install libsodium cmake git autoconf automake libtool wget
brew link cmake

# 3. 克隆并编译
git clone https://gitcode.com/gh_mirrors/ch/chia-plotter
cd chia-plotter
git submodule update --init
./make_devel.sh
./build/chia_plot --help

两个 macOS 专属注意事项:

  1. libsodium 找不到? 项目自带 cmake_modules/Findsodium.cmake 模块用于定位 libsodium,若链接失败,可手动为命令行工具创建软链接:
sudo ln -s /usr/local/include/sodium.h /Library/Developer/CommandLineTools/usr/include
sudo ln -s /usr/local/include/sodium /Library/Developer/CommandLineTools/usr/include
  1. "打开文件数过多"报错? macOS 默认句柄上限只有 256,低于默认 256 桶(buckets)的需求,启动造块前先执行:
ulimit -n 3000

Windows 安装:预编译包与 Docker 双方案

Windows 原生编译环境较折腾,推荐两种方式:

方案一:预编译二进制 社区维护的 Windows 版本 chia_plot.exe 可在项目 Releases 页面下载(由 stotiks 构建),解压即用,直接传入下文相同的参数即可。

方案二:Docker Desktop 容器运行(推荐) 在 Windows 上装好 Docker Desktop 后,即可复用下面的 Docker 章节命令。注意 Docker Desktop 基于 Hyper-V 运行,需确认没有限制 CPU/内存配额,否则可用 --cpus 和 -m 参数显式放开资源。

Docker 部署:三行命令跑起来

Docker 方案适合任何操作系统(尤其是 Windows),官方基准测试显示容器内运行仅比原生慢约 5%。

直接运行官方镜像

docker run \
  -v <你的临时目录>:/mnt/harvester \
  -v <你的最终目录>:/mnt/farm \
  odelucca/chia-plotter \
    -t /mnt/harvester/ \
    -d /mnt/farm/ \
    -p <pool-key> \
    -f <farm-key> \
    -r <CPU核心数>

镜像名之后可追加任意 chia_plot 参数(如 -k 32 -n 3)。

限制资源与分配多核(Windows 必看)

docker run \
  -v <你的临时目录>:/mnt/harvester \
  -v <你的最终目录>:/mnt/farm \
  -m 8G \
  --cpus 8 \
  odelucca/chia-plotter \
    -t /mnt/harvester/ \
    -d /mnt/farm/ \
    -p <pool-key> \
    -f <farm-key> \
    -r 8

这条命令会让容器以 8 核 + 8GB 内存运行造块器。

从源码自建镜像

项目内置 Dockerfile,采用 Alpine 双阶段构建(compiler 阶段编译、runtime 阶段仅拷贝二进制并创建 chia_plot 软链接),镜像非常精简:

git clone https://gitcode.com/gh_mirrors/ch/chia-plotter
cd chia-plotter
git submodule update --init
docker build -t my-chia-plotter .

安装验证与第一次造块

验证安装成功

./build/chia_plot --version    # 应输出 1.1.8 及 Git 提交号
./build/chia_plot --help      # 查看完整参数表

关键参数速查

参数 说明 建议值
-k 造块规模,默认 32 32
-r 线程数(倍数),默认 4 与物理核心数一致
-t 临时目录,约需 220 GiB 独立 SSD 目录
-2 临时目录 2,约需 110 GiB 内存盘
-d 造块文件最终存放目录 你的农场目录
-p / -f 池公钥 / 农场公钥 chia keys show 输出
-n 造块数量,-1 表示无限 1

Linux 内存盘配置(强烈推荐)

有 128 GiB 以上内存时,为 <tmpdir2> 挂载 tmpfs 内存盘,造块速度可提升明显:

sudo mkdir -p /mnt/ram
sudo mount -t tmpfs -o size=110G tmpfs /mnt/ram/

一条最小可运行的造块命令

./build/chia_plot \
  -t /mnt/tmp/ -2 /mnt/ram/ -d /mnt/farm/ \
  -p <pool-key> -f <farm-key> \
  -r 16 -n 1

⏹ 批量造块时(-n 2 以上),按一次 Ctrl-C 会优雅终止(当前块完成后停止),1 秒内按两次 Ctrl-C 可立即强制退出——该逻辑实现在 src/chia_plot.cpp 的中断处理器里。

常见问题(FAQ)

Q1:cmake 版本不够怎么办? bls-signatures 模块硬性要求 cmake ≥ 3.14。Ubuntu 18.04 及 Debian 10 需从 backports 或 apt.llvm.org 安装新版 cmake,详见 README.md 的 Known Issues 部分。

Q2:编译报 sodium.h: No such file or directory? 没装 libsodium-dev(Ubuntu/Debian)或 libsodium(Arch)。macOS 上还需检查 Homebrew 的 libsodium 是否被 cmake 正确发现,参考上文软链接方案。

Q3:内存要留多少? 内存占用取决于线程数与桶数,默认 256 桶下每线程最多约 0.5 GB,建议线程数的 1~2 倍内存作为预留。

Q4:如何确认造出的块有效? 可用 chiapos 官方 ProofOfSpace check -f plot-k32-xxx.plot 工具校验,说明见 README.md。

总结

本文完整演示了 chia-plotter 的四条部署路径:

  1. Linux:apt/pacman/yum 装两个依赖 → git submodule update --init → ./make_devel.sh
  2. macOS:xcode-select + brew 装依赖 → 编译 → 记得 ulimit -n 3000
  3. Windows:下载预编译 exe,或用 Docker Desktop
  4. Docker:一条 docker run 挂载目录即可跨平台运行

掌握 git submodule update --init 与 make_devel.sh 这两个关键步骤后,后续升级到最新版本只需 git pull && git submodule update --init && ./make_devel.sh 即可,祝造块顺利!

登录后查看全文
chia-plotter