CPUマイニング環境を格安VPS上で動作させてみます。

はじめに
世間でも何かと話題の仮想通貨、有名なところではビットコインです。 株やFXのように市場で売り買いすることもできますが、仮想通貨ならではの発掘という方法で入手することができます。 発掘(マイニング)というのは、簡単に言うと仮想通貨の運営を協力して見返りを得ることを言います。 マイニング作業というのは、ブルートフォースアタックで暗号解読するようなものなのでCPUパワーを非常に使います。CPUの代わりにGPUを使ったり、FPGAやASICといった専用のチップを使う方法もあります。FPGAやASICは非常に効率が良いようですが、値段が高く敷居が高いです。 一般的に使われるのはGPUです。 問題は私がGPUを持っていないことです。ゲームしないので、オンボードグラフィックで十分だったので。。 しかしCryptoNightなどGPUによる演算が困難な仮想通貨であるMoneroなどがあるようで、CPUによるマイニングを試してみました。 まずは自宅のサーバやPCで試してみると良いと思います。 今回は安価なレンタルサーバDigitalOceanを使ってみましたので、手順を紹介します。 ここでも紹介していますがDigitalOceanは1円/時間で使えます。CPUはXeonです。
DigitalOceanの登録

以前の記事で紹介していますので参考に登録してください。 私の紹介で登録していただくと、2か月分に相当する$10分のクレジットがもらえます。最初は無料のクレジットで試してみてください。
MinerGateの登録
普段使いのものでなくてもかまいませんが、ちゃんと届くメールアドレスを用意しておいてください。 まずはこちらにアクセスします。
「Sign up」をクリックします。
用意したメールアドレスとパスワードを入力します。 これで登録完了です。 自宅のサーバやPCでマイニングする場合は、ここからMinerGateのダウンロードに移りますが、今回はDigitalOceanでMinerGateを動かすのでダウンロードしません。
DigitalOceanで仮想環境を準備する
先ほど登録したDigitalOceanにログインします。
右上の「Create Droplet」をクリックします。
OSはUbuntuがデフォルトで選択してあります。MinerGateはLinuxだとUbuntuかFedoraが対応しています。Fedoraは不安定なところもあるので、Ubuntuを選択しておいてください。
MinerGateで重要なのはCPUのコア数です。$5/moが最も割安なので、$5/moを選択してください。このサイズなら1か月$5で使うことができます。
どこに置かれた仮想マシンを使うか選択します。使う場所によってCPUの型番が違っていました。SingaporeやBangalorefあたりだと30H/s程度出ていました。 課金も1時間単位なので、色々起動して一番効率の良い置き場所を探してみてください。
最後にCreateボタンを押せば仮想マシンが作られます。
仮想環境の設定
仮想環境が構築されるまでしばらく待ちます。
IP Address列にIPアドレスが表示されます。
1 2 3 4 5 6 |
Your new Droplet is all set to go! You can access it using the following credentials: Droplet Name: ubuntu-512mb-ams3-01 IP Address: ???.???.???.??? Username: root Password: ****************** |
DigitalOceanの登録メールアドレスにこのようなメールが届きます。 Teratermを使用して指定されたIPアドレスに接続します。 Teratermを開き、ホスト欄に上で確認したIPアドレスを入れ、OKを押します。
初回接続時はホスト鍵の警告が出ます。これは、初めての接続時は必ず出るものなので続行しても問題ありません。 「このホストをknown listsリストに追加する」にチェックを入れておけば、2回目以降はこの警告は出ません。
つぎにユーザ名にroot、パスフレーズに送られてきたパスワードを入れ、OKを押します。
最初にパスワードの変更が必要です。 「(current)UNIX password:」にメールで届いたパスワードを入力します。 「Enter new UNIX password:」と「Retype new UNIX password:」には変更後のパスワードを入れます。英数字混在で長いものをお勧めします。
これでUbuntuにログインできました。
MinerGateのインストール
(2018/12/1追記 ダウンロードURLとインストール方法が変更になっていたので最新にしました。旧バージョンのツールでは2018/11初旬頃からマイニングできなくなっているようです。旧バージョンを使用していた方は最新版をインストールしなおしてください。) 続いてMinerGateをインストールしていきます。 DigitalOceanで生成したUbuntuにはGUIがないので、MinerGateのコンソール版ツールをインストールしてきます。 まずはInternetExplolerなどでコンソール版ツールのダウンロードURLを調べます。 (私が調べたURLを試してダメだったらこの手順で調べてもらっても良いと思います) MinerGateのDownloadからConsole minersを選択しても行けますが、ここのリンクからも移動できます。 下のほうにUbuntu版へのリンクがあるので、「xFast Console Miner」の「ubuntu」のリンク先URLをコピーします。 記事を書いた時点では「https://minergate.com/download/xfast-ubuntu-cli」でした。 URLにバージョン番号を含んでいないので、変わることはないと思います。 Teratermに戻ってこのファイルをUbuntuにダウンロードします。 「wget https://minergate.com/download/xfast-ubuntu-cli」コマンドを実行します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
root@ubuntu-512mb-tor1-01:~# wget https://minergate.com/download/xfast-ubuntu-cli --2018-12-01 02:46:41-- https://minergate.com/download/xfast-ubuntu-cli Resolving minergate.com (minergate.com)... 136.243.102.167, 94.130.143.162, 88.99.142.163, ... Connecting to minergate.com (minergate.com)|136.243.102.167|:443... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://download-endpoint.minergate.com/xfast-ubuntu-cli [following] --2018-12-01 02:46:41-- https://download-endpoint.minergate.com/xfast-ubuntu-cli Resolving download-endpoint.minergate.com (download-endpoint.minergate.com)... 88.99.142.163, 136.243.102.167, 136.243.102.154, ... Connecting to download-endpoint.minergate.com (download-endpoint.minergate.com)|88.99.142.163|:443... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://download.minergate.com/xfast-ubuntu-cli [following] --2018-12-01 02:46:42-- https://download.minergate.com/xfast-ubuntu-cli Resolving download.minergate.com (download.minergate.com)... 176.9.8.174 Connecting to download.minergate.com (download.minergate.com)|176.9.8.174|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 6432409 (6.1M) [application/octet-stream] Saving to: ‘xfast-ubuntu-cli’ xfast-ubuntu-cli 100%[===================>] 6.13M 3.57MB/s in 1.7s 2018-12-01 02:46:45 (3.57 MB/s) - ‘xfast-ubuntu-cli’ saved [6432409/6432409] root@ubuntu-512mb-tor1-01:~# |
するとxfast-ubuntu-cliといファイルがダウンロードされます。これまではubuntu用のインストーラがダウンロードされましたが、現在はZIP圧縮されているだけのようです。 unzipコマンドで解凍するだけで使用できます。 では解凍していきます。 unzipコマンドが入っていないと思います。「apt install unzip」コマンドを実行してインストールします。
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 |
root@ubuntu-512mb-tor1-01:~# apt install unzip Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: grub-pc-bin linux-headers-4.4.0-124 linux-headers-4.4.0-124-generic linux-headers-4.4.0-127 linux-headers-4.4.0-127-generic linux-headers-4.4.0-128 linux-headers-4.4.0-128-generic linux-headers-4.4.0-130 linux-headers-4.4.0-130-generic linux-headers-4.4.0-133 linux-headers-4.4.0-133-generic linux-headers-4.4.0-134 linux-headers-4.4.0-134-generic linux-headers-4.4.0-137 linux-headers-4.4.0-137-generic linux-image-4.4.0-124-generic linux-image-4.4.0-127-generic linux-image-4.4.0-128-generic linux-image-4.4.0-130-generic linux-image-4.4.0-133-generic linux-image-4.4.0-134-generic linux-image-4.4.0-137-generic Use 'apt autoremove' to remove them. Suggested packages: zip The following NEW packages will be installed: unzip 0 upgraded, 1 newly installed, 0 to remove and 71 not upgraded. Need to get 158 kB of archives. After this operation, 530 kB of additional disk space will be used. Get:1 http://sgp1.mirrors.digitalocean.com/ubuntu xenial/main amd64 unzip amd64 6.0-20ubuntu1 [158 kB] Fetched 158 kB in 0s (309 kB/s) Selecting previously unselected package unzip. (Reading database ... 306206 files and directories currently installed.) Preparing to unpack .../unzip_6.0-20ubuntu1_amd64.deb ... Unpacking unzip (6.0-20ubuntu1) ... Processing triggers for mime-support (3.59ubuntu1) ... Processing triggers for man-db (2.7.5-1) ... Setting up unzip (6.0-20ubuntu1) ... |
unzipコマンドがインストールされたので、さっそく解凍しましょう。 「unzip xfast-ubuntu-cli」コマンドを実行します。
1 2 3 4 5 |
root@ubuntu-512mb-tor1-01:~# unzip xfast-ubuntu-cli Archive: xfast-ubuntu-cli creating: minergate-cli/ inflating: minergate-cli/libOpenCL.so.1 inflating: minergate-cli/minergate-cli |
これでインストールが完了しました。 2018/5/1追記 —–ここから—– 最近試したところ、インストールで以下のようなエラーとなりました。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
root@ubuntu-512mb-tor1-01:~# dpkg -i deb-cli Selecting previously unselected package minergate-cli. (Reading database ... 54330 files and directories currently installed.) Preparing to unpack deb-cli ... Unpacking minergate-cli (8.2) ... dpkg: dependency problems prevent configuration of minergate-cli: minergate-cli depends on libpcre16-3; however: Package libpcre16-3 is not installed. dpkg: error processing package minergate-cli (--install): dependency problems - leaving unconfigured Errors were encountered while processing: minergate-cli |
「libpcre16-3」というライブラリが不足しています。「apt-get install libpcre16-3」コマンドを実行してからもう一度試してください。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
root@ubuntu-512mb-tor1-01:~# apt-get install libpcre16-3 Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: grub-pc-bin Use 'apt autoremove' to remove it. The following NEW packages will be installed: libpcre16-3 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. 1 not fully installed or removed. Need to get 144 kB of archives. After this operation, 541 kB of additional disk space will be used. Get:1 http://sgp1.mirrors.digitalocean.com/ubuntu xenial/main amd64 libpcre16-3 amd64 2:8.38-3.1 [144 kB] Fetched 144 kB in 0s (379 kB/s) Selecting previously unselected package libpcre16-3:amd64. (Reading database ... 54338 files and directories currently installed.) Preparing to unpack .../libpcre16-3_2%3a8.38-3.1_amd64.deb ... Unpacking libpcre16-3:amd64 (2:8.38-3.1) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Setting up libpcre16-3:amd64 (2:8.38-3.1) ... Setting up minergate-cli (8.2) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... |
—–ここまで—–
最後に「nohup minergate-cli -u hoge@hoge.com –xmr &」コマンドを実行します。「hoge@hoge.com」部分はMinerGate登録時のアドレスに変更してください。Moneroをマイニングするために「–xmr」としましたが、別の仮想通貨が良い場合は適宜変更してください。
1 2 3 |
root@ubuntu-512mb-tor1-01:~# nohup minergate-cli -u hoge@hoge.com --xmr & [1] 1780 root@ubuntu-512mb-tor1-01:~# nohup: ignoring input and appending output to 'nohup.out' |
実行結果はnohup.outというファイルに書き込まれていきます。 MinerGateのDashboardでActive workersの値が増えていれば成功です。 後は「exit」コマンドでログアウトすれば勝手にマイニングしてくれます。
コメント