独服的 CPU 闲着也是闲着,小挖怡情,大挖伤身。本文主要基于 NiceHash Miner 可用的挖矿程序,在 Linux 下编译 CPU 可用的版本
Equihash miner for NiceHash
项目源码在这里,这个 miner 的编译稍稍有些麻烦,很多依赖需要自己安装。由于是纯 CPU 挖矿,尽管页面上提到了 CUDA Kit,但是我们并不需要安装这个。
需要的依赖有这些,Boost 1.62+ 和 CMake 3.5+,但是实际操作中,由于 CMake 和 Boost 库存在版本兼容性问题(Boost 1.63 / CMake 3.7+; Boost 1.64 / CMake 3.8+; Boost 1.65 & 1.65.1 / CMake 3.9.3+),因此不能采用简单的 apt 方式安装,而需要自己下载。
Boost 我选择了 1.65.1,具体安装看这里,具体命令如下:
wget https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.bz2 tar --bzip2 -xf /path/to/boost_1_65_1.tar.bz2 cd path/to/boost_1_65_1 ./bootstrap.sh ./b2 install
然后安装 CMake 3.9.3+,这里我一开始就被坑了,如果不选择合适的 CMake 版本,则编译时无法找到 Boost 库。
wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh chmod +x /path/to/cmake-3.9.6-Linux-x86_64.sh sudo /path/to/cmake-3.9.6-Linux-x86_64.sh #Set your own install path during the process sudo ln -s /path/to/cmake-3.9.6-Linux-x86_64/bin/* /usr/local/bin
然后运行 cmake --version
查看版本,应该已经是 3.9.3+ 了
接下来按照 GitHub 页面操作
git clone https://github.com/nicehash/nheqminer.git
- 修改根目录下的 CMakeList.txt,修改这样一行:
option(USE_CUDA_DJEZO "USE CUDA_DJEZO" ON)
后面的 ON 为 OFF,这是因为我们要纯 CPU 挖矿,不编译 CUDA 版本。 cd nheqminer/cpu_xenoncat/asm_linux/
chmod +x fasm
sh assemble.sh
cd ../../../
mkdir build && cd build
cmake ../nheqminer
make -j $(nproc)
接下来在 build 目录下就会看到编译好的 nheqminer 程序,使用 nheqminer -l equihash.eu.nicehash.com:3357 -u <NH_BTC_ADDRESS>.<worker_name> -t <n_threads>
开始挖矿
CPUMiner-Multi
git clone https://github.com/tpruvot/cpuminer-multi.git
- 安装依赖
apt install automake autoconf libcurl4-openssl-dev libjansson-dev libssl-dev
cd cpuminer-multi
./build.sh
./cpuminer -a <algo> -o stratum+tcp://<pool_addr> -u <NH_BTC_ADDRESS>.<worker_name> -t <n_threads>
CPUMiner-Multi Help:
Usage: cpuminer-multi [OPTIONS] Options: -a, --algo=ALGO specify the algorithm to use axiom Shabal-256 MemoHash bitcore Timetravel with 10 algos blake Blake-256 14-rounds (SFR) blakecoin Blake-256 single sha256 merkle blake2s Blake2-S (256) bmw BMW 256 c11/flax C11 cryptolight Cryptonight-light cryptonight Monero decred Blake-256 14-rounds 180 bytes dmd-gr Diamond-Groestl drop Dropcoin fresh Fresh groestl GroestlCoin heavy Heavy jha JHA keccak Keccak luffa Luffa lyra2re Lyra2RE lyra2rev2 Lyra2REv2 (Vertcoin) myr-gr Myriad-Groestl neoscrypt NeoScrypt(128, 2, 1) nist5 Nist5 pluck Pluck:128 (Supcoin) pentablake Pentablake quark Quark qubit Qubit scrypt scrypt(1024, 1, 1) (default) scrypt:N scrypt(N, 1, 1) scrypt-jane:N (with N factor from 4 to 30) shavite3 Shavite3 sha256d SHA-256d sia Blake2-B sib X11 + gost (SibCoin) skein Skein+Sha (Skeincoin) skein2 Double Skein (Woodcoin) s3 S3 timetravel Timetravel (Machinecoin) vanilla Blake-256 8-rounds x11evo Permuted x11 x11 X11 x13 X13 x14 X14 x15 X15 x17 X17 xevan Xevan (BitSend) yescrypt Yescrypt zr5 ZR5 -o, --url=URL URL of mining server -O, --userpass=U:P username:password pair for mining server -u, --user=USERNAME username for mining server -p, --pass=PASSWORD password for mining server --cert=FILE certificate for mining server using SSL -x, --proxy=[PROTOCOL://]HOST[:PORT] connect through a proxy -t, --threads=N number of miner threads (default: number of processors) -r, --retries=N number of times to retry if a network call fails (default: retry indefinitely) -R, --retry-pause=N time to pause between retries, in seconds (default: 30) --time-limit=N maximum time [s] to mine before exiting the program. -T, --timeout=N timeout for long poll and stratum (default: 300 seconds) -s, --scantime=N upper bound on time spent scanning current work when long polling is unavailable, in seconds (default: 5) --randomize Randomize scan range start to reduce duplicates -f, --diff-factor Divide req. difficulty by this factor (std is 1.0) -m, --diff-multiplier Multiply difficulty by this factor (std is 1.0) -n, --nfactor neoscrypt N-Factor --coinbase-addr=ADDR payout address for solo mining --coinbase-sig=TEXT data to insert in the coinbase when possible --max-log-rate limit per-core hashrate logs (default: 5s) --no-longpoll disable long polling support --no-getwork disable getwork support --no-gbt disable getblocktemplate support --no-stratum disable X-Stratum support --no-extranonce disable Stratum extranonce support --no-redirect ignore requests to change the URL of the mining server -q, --quiet disable per-thread hashmeter output --no-color disable colored output -D, --debug enable debug output -P, --protocol-dump verbose dump of protocol-level activities --hide-diff Hide submitted block and net difficulty -S, --syslog use system log for output messages -B, --background run the miner in the background --benchmark run in offline benchmark mode --cputest debug hashes from cpu algorithms --cpu-affinity set process affinity to cpu core(s), mask 0x3 for cores 0 and 1 --cpu-priority set process priority (default: 0 idle, 2 normal to 5 highest) -b, --api-bind IP/Port for the miner API (default: 127.0.0.1:4048) --api-remote Allow remote control --max-temp=N Only mine if cpu temp is less than specified value (linux) --max-rate=N[KMG] Only mine if net hashrate is less than specified value --max-diff=N Only mine if net difficulty is less than specified value -c, --config=FILE load a JSON-format configuration file -V, --version display version information and exit -h, --help display this help text and exit