UbuntuでBitzenyをCPUマイニングをしてみよう!



今はやりのマイニングについてお話します。Windows OSは沢山紹介されていますので、まずはUbuntuでの環境設定についてご紹介します。
流れは以下の通り簡単にざっくり説明します。
- Ubuntuのコンテンツをアップデート
- gitをダウンロード
- マイナー(コインを掘るもの)をダウンロード
- マイナーをインストール
- 動かしてみる!
説明環境について
説明環境は下記の通りです。下記コマンドを打って確認します。
1 |
cat /etc/os-release |
1 2 3 4 5 6 7 8 9 10 11 |
NAME="Ubuntu" VERSION="16.04.3 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.3 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial |
上記の通りUbuntu 16.04.3 LTSです。
コンテンツをアップデートしましょう
まずはUbuntuのコンテンツを最新ファイルになってるか確認、そしてアップデートします。
1 |
sudo apt update |
上記コマンドを打つと、このようなログが吐き出されると思います。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
ubuntu@ip-*****************:~$ sudo apt update Hit:1 http://*********************.ubuntu.com/ubuntu xenial InRelease Get:2 http://*********************.ubuntu.com/ubuntu xenial-updates InRelease [102 kB] Get:3 http://*********************.ubuntu.com/ubuntu xenial-backports InRelease [102 kB] . <省略> . Get:42 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [1,408 B] Fetched 24.6 MB in 8s (2,828 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 41 packages can be upgraded. Run 'apt list --upgradable' to see them. |
続いて次のコマンドを打ってみましょう。
1 |
sudo apt upgrade |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
ubuntu@ip-***************:~$ sudo apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following NEW packages will be installed: libdrm-common linux-aws-headers-4.4.0-1044 linux-headers-4.4.0-1044-aws linux-image-4.4.0-1044-aws The following packages will be upgraded: apport cloud-init curl distro-info-data dnsmasq-base dpkg grub-common grub-legacy-ec2 grub-pc grub-pc-bin grub2-common initramfs-tools initramfs-tools-bin initramfs-tools-core klibc-utils libcurl3-gnutls libdb5.3 libdrm2 libklibc libpython3.5 libpython3.5-minimal libpython3.5-stdlib libseccomp2 libssl1.0.0 libxml2 linux-aws linux-headers-aws linux-image-aws lxcfs lxd lxd-client openssl python3-apport python3-problem-report python3.5 python3.5-minimal rsync snapd squashfs-tools ubuntu-core-launcher unattended-upgrades 41 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 64.0 MB of archives. After this operation, 136 MB of additional disk space will be used. Do you want to continue? [Y/n] |
Do you want to continue? [Y/n]と表示されたら、「Enter」か「Y」と入力し「Enter」を押してください。
1 |
Progress: [ 27%] [############################################################.................................................................................................................................. |
こんな感じのプログレスバーが表示され、100%になった後、しばらくすると終わります。
※場合によっては、プログレスバーの途中で下記が表示されますが、「install the package maintainer’s verision」を選べばすんなり終わります。
ここまでで最適化(と呼べばいいでしょうか)は完了です。
gitをダウンロードしよう!
続いて、gitをダウンロードする必要があります。gitとはプログラムのソースコードなどの変更履歴を記録・追跡するための分散型バージョン管理システムです。これをインストールしてgithubから必要なファイルをダウンロードします。(GitHubとは、このGitの仕組みを利用して世界中のエンジニアが、プログラムコードやデザインデータなどを保存や公開できるようにしたウェブサービスです。)
早速gitをダウンロードしましょう。
1 |
sudo apt-get install git |
このようなログがでて完了します。
1 2 3 4 5 6 |
ubuntu@ip-*********:~$ sudo apt-get install git Reading package lists... Done Building dependency tree Reading state information... Done git is already the newest version (1:2.7.4-0ubuntu1.3). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
これで完了です!
マイナーをダウンロードしよう
gitのインストールが終わったら、続いてマイナーをダウンロードします。今回はBitzenyを利用するという前提でbitzenyのところからダウンロードします。
1 |
git clone https://github.com/bitzeny/cpuminer.git cpuminer |
このようなログがでて完了です。
1 2 3 4 5 6 7 |
ubuntu@ip-*************:~$ git clone https://github.com/bitzeny/cpuminer.git cpuminer Cloning into 'cpuminer'... remote: Counting objects: 1387, done. remote: Total 1387 (delta 0), reused 0 (delta 0), pack-reused 1386 Receiving objects: 100% (1387/1387), 559.00 KiB | 452.00 KiB/s, done. Resolving deltas: 100% (897/897), done. Checking connectivity... done. |
完了したら、cpuminerのディレクトリに移動しましょう。
1 |
cd cpuminer |
これだけでは動きません。Windowsならexeファイルがあって、もう動く状態になりますが、ダウンロードしたパッケージをインストールしないといけません。
次のコマンドを入力してください。
1 |
sudo apt-get install libcurl4-openssl-dev gcc-mingw-w64 automake gcc make |
また「Do you want to continue? [Y/n]」とでますので、「Enter」で続けてください。今までより多少お時間がかかります。
ここで完了したら、最後の詰めです。
1 |
./autogen.sh |
1 |
./configure CFLAGS="-O3 -march=native -funroll-loops -fomit-frame-pointer" |
1 |
make |
これで完了です!!!
最後に動作するかチェックしましょう。
1 |
./minerd --help |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
ubuntu@ip-***********:~/cpuminer$ ./minerd --help Usage: minerd [OPTIONS] Options: -a, --algo=ALGO specify the algorithm to use yescrypt yescrypt (default) scrypt scrypt(1024, 1, 1) scrypt:N scrypt(N, 1, 1) sha256d SHA-256d -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) -T, --timeout=N timeout for long polling, in seconds (default: none) -s, --scantime=N upper bound on time spent scanning current work when long polling is unavailable, in seconds (default: 5) --coinbase-addr=ADDR payout address for solo mining --coinbase-sig=TEXT data to insert in the coinbase when possible --no-longpoll disable long polling support --no-getwork disable getwork support --no-gbt disable getblocktemplate support --no-stratum disable X-Stratum support --no-redirect ignore requests to change the URL of the mining server -q, --quiet disable per-thread hashmeter output -D, --debug enable debug output |
上記のようなログが吐き出されれば、全く問題ないです。もう動く状態です!
マイニングしてみよう
マイニングプールを準備した場合を想定します。(※マイニングプールの登録方法等は別途記事にします。)
LAPOOLを準備、Bitzenyをマイニングしようとした場合、下記コマンドを打てば動きだします。(※ポート番号は若干異なりますが、今回は説明を割愛します。)
1 |
./minerd -a yescrypt -o stratum+tcp://jp.lapool.me:3014 -u [ユーザー名].worker -p password |
上記を具体例をいれると、このような形になります。
- ユーザ名:lumbini
- ワーカー名:worker1
- パスワード:1234
1 |
./minerd -a yescrypt -o stratum+tcp://jp.lapool.me:3014 -u lumbini.worker1 -p 1234 |
マイニングプールの登録、ワーカー登録はこちらでご紹介中!
本当に動いてる!?
下記「yay!!」がでれば、問題ないです
1 2 3 4 5 6 7 |
ubuntu@ip-***:~/cpuminer$ ./minerd -a yescrypt -o stratum+tcp://jp.lapool.me:3014 -u *** -p *** [2018-01-04 10:37:15] 1 miner threads started, using 'yescrypt' algorithm. [2018-01-04 10:37:15] Starting Stratum on stratum+tcp://jp.lapool.me:3014 [2018-01-04 10:37:15] Stratum requested work restart [2018-01-04 10:37:22] thread 0: 4096 hashes, 0.64 khash/s [2018-01-04 10:37:28] thread 0: 3439 hashes, 0.63 khash/s [2018-01-04 10:37:28] accepted: 1/1 (100.00%), 0.63 khash/s (yay!!!) |
如何でしたでしょうか。ここまでくればマイニングできています。
ただし、このままやっているとCPU利用率が100%になっていたり(CPUの利用率を確認する方法も必要ですね)と不都合が出てきます。
ちょっと便利な制御はこちらで紹介中です。
最後までお読みいただき有難うございました。良いマイニングを!これであなたも毎日マイニーですね!
Simple PoS Pool
ここ最近人気が急上昇中のPoSマイニングプールです。PoSマイニングなので、コインを入れておくだけでザクザクとコインが増えていきます。
現在16のコインに対応しております。ユーザ数とともに登録規制などもあるので、アカウント作成だけでもしておいて損はないと思います。記事にもしてありますので、宜しければご確認ください。
ウォレット・取引所
今おススメ、有名なウォレット・取引所のリンクを張ります。各々の取引所では長所・短所(取扱通貨が異なる)があるため、全て作成しておいても損はないと思います(^。^)いつか利用するときが来るかもしれません。
KuCoinは現在人気がうなぎのぼりです。登録は無料なので、登録中止になる前に開設だけする事をおススメします。