计算机技术

使用闲置服务器的CPU算力挖掘Monero

Monero是开源、去中心化的虚拟货币,目前以XMR的ticker在各大虚拟货币交易所开放交易,其Market Cap在所有虚拟货币中排名第9,高于以太币经典(ETC)等高流通量货币。目前,每个XMR大约价值110美元。

既然在Monero之前还有很多货币,为什么我们偏偏选择了Monero来挖呢?原因在于,Monero对于CPU挖掘非常友好。根据CPUCoinList.com的研究,CPU和GPU挖掘Monero有相同的优势,这一点在所有虚拟币中弥足珍贵。也就是说,对于服务器上多余的CPU算力,我们完全可以利用起来,挖掘Monero.

本文作者为香菇肥牛,原文地址为https://qing.su/article/129.html, 文章同时发于香菇肥牛的博客和Hostloc.com, 未经允许不得转载。

以手上的波兰服务器为例,月付13美元,仅使用一半的CPU核心挖矿,其运算速率大约在310H/s, 这样每月挖到的Monero兑换成美元大概在22刀,相当于不仅白送了一台服务器的使用权,还可以净赚9刀。

下面我就来介绍一下使用服务器挖掘Monero的方法。以下所有操作均在一台64位Ubuntu 14.04 LTS服务器上完成。

首先,我们需要注册一个钱包。几乎所有的虚拟币交易所都支持Monero的交易,我们在任何一家交易所注册一个账号后就可以获得一个Monero钱包地址。如果你不知道哪里可以注册账号,可以到这个链接上注册https://hitbtc.com/?ref_id=5a052b51ce60a,我就是在这里注册的账号,童叟无欺。注册好后在后台获得Monero钱包地址。

然后我们要选择一个矿池。Monero矿池有很多,官网http://moneropools.com/中列举了很多个矿池,可以选择想加入的矿池。我这里选择的是xmr.nanopool.org.

接下来就是安装矿机了。登录服务器,执行下列命令安装矿机软件:

1
2
3
4
5
6
7
8
add-apt-repository ppa:ubuntu-toolchain-r/test
apt update
apt install gcc-5 g++-5 make
update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-5 1 –slave /usr/bin/g++ g++ /usr/bin/g++-5
curl -L http://www.cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xvzf – -C /tmp/
cd /tmp/cmake-3.4.1/ && ./configure && make && sudo make install && cd –
update-alternatives –install /usr/bin/cmake cmake /usr/local/bin/cmake 1 –force
apt install libmicrohttpd-dev libssl-dev libhwloc-dev
1
2
3
4
git clone https://github.com/fireice-uk/xmr-stak-cpu xmr-stak
cd xmr-stak
cmake .
make install

这样,我们就安装好了挖矿软件。进入binary目录后运行一遍那个程序,会给出推荐的CPU配置信息,然后我们编辑binary目录下面config.txt, 填上你自己的钱包地址、矿池地址、Payment ID等信息并且填写CPU配置信息(可微调),之后执行 ./xmr-stak-cpu就可以自动开始挖矿啦。挖到Payout数目之后矿池就会自动把Monero打到你之前开的钱包之中。

关于Monero的介绍和挖矿技巧就介绍到这里,如果有不明白的地方欢迎在这里留言。本文作者为香菇肥牛,原文地址为https://qing.su/article/129.html, 文章同时发于香菇肥牛的博客和Hostloc.com, 未经允许不得转载。谢谢!

EDIT: 加上了CentOS版本的矿机安装。

1
2
3
4
5
6
7
yum install centos-release-scl cmake3 hwloc-devel libmicrohttpd-devel openssl-devel
yum install devtoolset-4-gcc*
scl enable devtoolset-4 bash
git clone https://github.com/fireice-uk/xmr-stak-cpu xmr-stak
cd xmr-stak
cmake3 .
make install

EDIT: 加上了Windows版本的矿机安装。
1, 在C盘根目录下新建文件夹xmr-stak-dep.
2, 安装Visual Studio 2017 Community版https://www.visualstudio.com/downloads/, 安装时请加上Desktop development with C++和Toolset for Visual Studio C++ 2015.3 v140…这两个组件。
3, 安装https://cmake.org/files/v3.9/cmake-3.9.0-rc3-win64-x64.msi, 安装时务必选择Add CMake to the system PATH for all users.
4, 下载https://github.com/fireice-uk/xmr-stak-dep/releases/download/v1/xmr-stak-dep.zip并解压到C:xmr-stak-dep
5, 在命令行中执行:

1
2
3
4
5
6
7
8
9
cd C:xmr-stak-dep
“C:Program Files (x86)Microsoft Visual Studio2017CommunityCommon7ToolsVsMSBuildCmd.bat”
set CMAKE_PREFIX_PATH=C:xmr-stak-dephwloc;C:xmr-stak-deplibmicrohttpd;C:xmr-stak-depopenssl
mkdir build
cd build
cmake -G “Visual Studio 15 2017 Win64” -T v141,host=x64 ..
msbuild xmr-stak-cpu.sln /p:Configuration=Release
cd binRelease
copy ……config.txt .

这样就安装好了Windows版本的矿机。

EDIT: 关于Payment ID:

1
openssl rand -hex 32

EDIT: 关于Linux下挖矿出现MEMORY ALLOC FAILED: mmap failed
解决方案:

1
sysctl -w vm.nr_hugepages=128

然后编辑文件/etc/security/limits.conf, 在倒数第二行或者之前加入下面两行:

1
2
* soft memlock 262144
* hard memlock 262144

然后重启或者注销并重新登录。

EDIT: Debian 8 矿机安装. Credit to CheapLolicon (http://www.hostloc.com/space-uid-25192.html)

1
2
3
4
5
6
7
8
9
10
11
12
echo “deb http://ftp.us.debian.org/debian unstable main contrib non-free” >> /etc/apt/sources.list.d/unstable.list
apt-get update
apt-get install -t unstable gcc-5 g++-5 make
update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-5 1 –slave /usr/bin/g++ g++ /usr/bin/g++-5
curl -L http://www.cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xvzf – -C /tmp/
cd /tmp/cmake-3.4.1/ && ./configure && make && make install && cd –
update-alternatives –install /usr/bin/cmake cmake /usr/local/bin/cmake 1 –force
apt install libmicrohttpd-dev libssl-dev libhwloc-dev
git clone https://github.com/fireice-uk/xmr-stak-cpu xmr-stak
cd xmr-stak
cmake .
make install

EDIT: 更改捐赠比例. Credit to moneypy (http://www.hostloc.com/space-uid-3598.html)
编辑文件donate-level.h, 找到constexpr double fDevDonationLevel, 更改相应数值,并重新编译。

https://qing.su/article/129.html

Related Articles

发表回复

Check Also
Close
Back to top button