財布鯖をMacに置いたまま別マシンでマイニング
Monacoinの採掘をローカルでやってると、MBPが熱くなっていけません。
今は冬だから暖かくていいけど、全力ではないもののファンは常に回っているので、マシン寿命にもよくないですね。
そこで、遊んでいるMac miniにマイニングさせてみることにしました。
Mac miniは、Ubuntu Serverを入れたヘッドレスマシンになっているので、GUIがありません。
ここに財布をどうやって入れたらいいのか、まだよくわかりません。
X.org入れれば、Qtクライアントの財布が動くのでしょうが、それもめんどくさいです。
しかたがないので、今回はMacにある財布鯖につなぐことにしました。
minerdのビルド
今回もCPUマイニングにします。
Ubuntu 12.04LTSには、minerdのパッケージはないようです。
ビルドすることにします。
ビルドに必要なパッケージは、どれが必須かよくわからないのですが、とりあえずサンプルにあったものをチェックして入れておきます。
make, build-essential, git, pkg-config, libncurses5-devはすでに最新。
別にインストールが必要なのは、automake libcurl4-openssl-dev yasm libdb4.8-dev。
$ sudo apt-get install automake libcurl4-openssl-dev yasm libdb4.8-dev The following NEW packages will be installed: autoconf automake autotools-dev comerr-dev krb5-multidev libcurl4-openssl-dev libdb4.8 libdb4.8-dev libgcrypt11-dev libgnutls-dev libgnutls-openssl27 libgnutlsxx27 libgpg-error-dev libgssrpc4 libidn11-dev libkadm5clnt-mit8 libkadm5srv-mit8 libkdb5-6 libkrb5-dev libldap2-dev libp11-kit-dev librtmp-dev libssl-dev libssl-doc libtasn1-3-dev yasm The following packages will be upgraded: libcurl3 libcurl3:i386 libssl1.0.0 libssl1.0.0:i386
ソースをダウンロードして、ビルドします。
$ git clone https://github.com/pooler/cpuminer.git Cloning into 'cpuminer'... remote: Counting objects: 1232, done. remote: Compressing objects: 100% (653/653), done. remote: Total 1232 (delta 575), reused 1232 (delta 575) Receiving objects: 100% (1232/1232), 985.04 KiB | 210 KiB/s, done. Resolving deltas: 100% (575/575), done. $ cd cpuminer $ ./autogen.sh configure.ac:15: installing `./compile' configure.ac:4: installing `./config.guess' configure.ac:4: installing `./config.sub' configure.ac:6: installing `./install-sh' configure.ac:6: installing `./missing' compat/jansson/Makefile.am: installing `./depcomp' Makefile.am: installing `./INSTALL'
ビルドオプションには、一般的に「CFLAGS="-O3"」を渡しているようですが、ここはi7搭載のMac mini Late2012なので、「CFLAGS="-march=corei7-avx -O3"」で行きましょう。
$ ./configure CFLAGS="-march=corei7-avx -O3" checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether to enable maintainer-specific portions of Makefiles... no checking for style of include used by make... GNU checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking dependency style of gcc... gcc3 checking for gcc option to accept ISO C99... -std=gnu99 checking how to run the C preprocessor... gcc -std=gnu99 -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking whether gcc -std=gnu99 needs -traditional... no checking whether gcc -std=gnu99 and cc understand -c and -o together... yes checking dependency style of gcc -std=gnu99... gcc3 checking for ranlib... ranlib checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking sys/endian.h usability... no checking sys/endian.h presence... no checking for sys/endian.h... no checking sys/param.h usability... yes checking sys/param.h presence... yes checking for sys/param.h... yes checking syslog.h usability... yes checking syslog.h presence... yes checking for syslog.h... yes checking for sys/sysctl.h... yes checking whether be32dec is declared... no checking whether le32dec is declared... no checking whether be32enc is declared... no checking whether le32enc is declared... no checking for size_t... yes checking for working alloca.h... yes checking for alloca... yes checking for getopt_long... yes checking whether we can compile AVX code... yes checking whether we can compile XOP code... yes checking whether we can compile AVX2 code... yes checking for json_loads in -ljansson... no checking for pthread_create in -lpthread... yes checking for gawk... (cached) mawk checking for curl-config... /usr/bin/curl-config checking for the version of libcurl... 7.22.0 checking for libcurl >= version 7.15.2... yes checking whether libcurl is usable... yes checking for curl_free... yes configure: creating ./config.status config.status: creating Makefile config.status: creating compat/Makefile config.status: creating compat/jansson/Makefile config.status: creating cpuminer-config.h config.status: executing depfiles commands $ make (snip) $ ls -lh minerd -rwxr-xr-x 1 kinneko kinneko 367K Feb 25 21:58 minerd
出来ました。
財布サーバーを外部アクセス可能にする
先日設定したminerdは、同じPC内部だけから接続可能な設定がされていました。
外部からアクセスできるように、設定を変更する必要があります。
鯖が止まると、minerdはこんなログを吐きました。
[2014-02-25 21:59:44] HTTP request failed: Operation timed out after 30028 milliseconds with 0 out of -1 bytes received [2014-02-25 21:59:44] json_rpc_call failed, retry after 30 seconds
設定を書き換えて、財布鯖を再起動します。
$ vi /Users/kinneko/Library/Application\ Support/Monacoin/monacoin.conf rpcallowip=all $ Monacoin-Qt.app/Contents/MacOS/Monacoin-Qt -server
ローカルのminerdから接続試験をしてみますが、うまく接続できなくなりました。
netstatで調べると、まだ前のサーバーが動いているようです。
25042 ttys000 32:57.98 Monacoin-Qt.app/Contents/MacOS/Monacoin-Qt -server 27488 ttys000 0:00.82 Monacoin-Qt.app/Contents/MacOS/Monacoin-Qt -server
killコマンドでプロセスを消して、再起動します。
minerdを再起動すると、ローカルからの接続は問題なくできました。
リモートから試します。
$ ./minerd -o 192.168.1.101:9302 --userpass [user]:[pass] [2014-02-25 22:17:22] Binding thread 5 to cpu 5 [2014-02-25 22:17:22] Binding thread 3 to cpu 3 [2014-02-25 22:17:22] Binding thread 0 to cpu 0 [2014-02-25 22:17:22] Binding thread 1 to cpu 1 [2014-02-25 22:17:22] 8 miner threads started, using 'scrypt' algorithm. [2014-02-25 22:17:22] Binding thread 2 to cpu 2 [2014-02-25 22:17:22] Binding thread 7 to cpu 7 [2014-02-25 22:17:22] Binding thread 6 to cpu 6 [2014-02-25 22:17:22] Binding thread 4 to cpu 4 [2014-02-25 22:17:22] HTTP request failed: The requested URL returned error: 403 [2014-02-25 22:17:22] json_rpc_call failed, retry after 30 seconds
接続できません。
鯖の口があいているか、調べてみましょう。
$ wget http://192.168.1.101:9302/ --2014-02-25 22:19:14-- http://192.168.1.101:9302/ Connecting to 192.168.1.101:9302... connected. HTTP request sent, awaiting response... 403 Forbidden 2014-02-25 22:19:15 ERROR 403: Forbidden.
http接続は受け付けるようです。
$ telnet 192.168.1.101 9302 Trying 192.168.1.101... Connected to 192.168.1.101. Escape character is '^]'. HTTP/1.1 403 Forbidden Date: Tue, 25 Feb 2014 13:21:08 +0000 Connection: close Content-Length: 0 Content-Type: application/json Server: monacoin-json-rpc/v0.8.6.1-g88e2a2e-beta Connection closed by foreign host.
ちゃんと機能はしているようです。
403なので認証エラーですかね。
rpcallowipを設定しなければいいのでしょうか?
$ telnet 192.168.1.101 9302 Trying 192.168.1.101... telnet: Unable to connect to remote host: Connection refused
この場合は、完全にはじかれました。
rpcallowip="localhost, 192.168.1.100"でもダメでした。
複数列記できる仕様ではないということはないと思いますが、とりあえず rpcallowip=192.168.1.100 にしてみると、動きました。
$ ./minerd -a scrypt -o 192.168.1.101:9302/ --userpass=[user]:[pass] [2014-02-25 22:25:59] Binding thread 0 to cpu 0 [2014-02-25 22:25:59] Binding thread 6 to cpu 6 [2014-02-25 22:25:59] Binding thread 4 to cpu 4 [2014-02-25 22:25:59] Binding thread 1 to cpu 1 [2014-02-25 22:25:59] Binding thread 7 to cpu 7 [2014-02-25 22:25:59] Binding thread 3 to cpu 3 [2014-02-25 22:25:59] Binding thread 5 to cpu 5 [2014-02-25 22:25:59] 8 miner threads started, using 'scrypt' algorithm. [2014-02-25 22:25:59] Binding thread 2 to cpu 2 [2014-02-25 22:26:00] thread 6: 4104 hashes, 5.34 khash/s [2014-02-25 22:26:00] thread 1: 4104 hashes, 5.34 khash/s [2014-02-25 22:26:00] thread 0: 4104 hashes, 5.22 khash/s [2014-02-25 22:26:00] thread 4: 4104 hashes, 5.25 khash/s [2014-02-25 22:26:00] thread 7: 4104 hashes, 5.24 khash/s [2014-02-25 22:26:00] thread 2: 4104 hashes, 5.34 khash/s [2014-02-25 22:26:00] thread 3: 4104 hashes, 5.26 khash/s
設定ファイルは、JSON形式なので、配列渡しは、
rpcallowip=[ local , 192.168.1.100 ]
と書く必要があるのかもしれません。
スピードは、だいたい毎スレッド5khash/s前後でした。
i7のMBPと変わりありません。
ただ、8コアで動いているので、処理は倍速になりました。
CPU温度・スレッド数とパフォーマンスの関係は、どうなっている?
動き始めると、Mac miniのファンもすぐに回り始めています。
こうなるとCPUの温度が心配になります。
$ sudo modprobe coretemp $ lsmod Module Size Used by coretemp 13554 0 $ cat /sys/devices/platform/coretemp.0/temp?_input 100000 94000 100000 100000 99000
しばらく見ていると、100度前後をウロウロしているようです。
$ cat /sys/devices/platform/coretemp.0/temp?_max 87000 87000 87000 87000 87000
クロックダウンなどのスレッショルドは、87度に設定されていますので、クロックは下げて運用されています。
$ cat /proc/cpuinfo | grep "cpu MHz" cpu MHz : 1400.000 cpu MHz : 1400.000 cpu MHz : 1400.000 cpu MHz : 1400.000 cpu MHz : 1400.000 cpu MHz : 1400.000 cpu MHz : 1400.000 cpu MHz : 1400.000
1.4GHzで動作しています。
クロックが2.3GHzから下に動いても、マイニングのパフォーマンスに差はありませんでした。
CPUマイニングはクロック依存ではないようです。
低クロックで並列度を上げたほうが、戦略的にはいいのかもしれません。
ちょっと試してみました。
-t 16を付けて、倍のスレッドで動かしてみます。
[2014-02-25 22:44:11] thread 1: 13296 hashes, 2.62 khash/s [2014-02-25 22:44:11] thread 8: 12984 hashes, 2.62 khash/s [2014-02-25 22:44:11] thread 9: 13128 hashes, 2.61 khash/s [2014-02-25 22:44:11] thread 4: 12912 hashes, 2.56 khash/s [2014-02-25 22:44:11] thread 12: 12888 hashes, 2.56 khash/s [2014-02-25 22:44:11] thread 0: 12864 hashes, 2.61 khash/s [2014-02-25 22:44:11] thread 5: 12816 hashes, 2.56 khash/s [2014-02-25 22:44:11] thread 2: 13152 hashes, 2.58 khash/s [2014-02-25 22:44:11] thread 7: 13248 hashes, 2.55 khash/s [2014-02-25 22:44:11] thread 14: 12960 hashes, 2.57 khash/s [2014-02-25 22:44:11] thread 13: 12804 hashes, 2.57 khash/s [2014-02-25 22:44:11] thread 11: 13044 hashes, 2.59 khash/s [2014-02-25 22:44:11] thread 15: 12972 hashes, 2.56 khash/s [2014-02-25 22:44:11] thread 3: 13116 hashes, 2.59 khash/s [2014-02-25 22:44:11] thread 10: 12912 hashes, 2.58 khash/s [2014-02-25 22:44:11] thread 6: 12816 hashes, 2.57 khash/s
ちょうど半分くらいかなと思ったのですが、時間を置いてみると2khash/sを切るようなこともあって、効率的ではありませんでした。
残念。
逆に半分の4スレッドで動かしてみます。
[2014-02-25 22:49:02] thread 0: 42396 hashes, 8.39 khash/s [2014-02-25 22:49:02] thread 1: 39060 hashes, 8.70 khash/s [2014-02-25 22:49:02] thread 2: 40860 hashes, 8.39 khash/s [2014-02-25 22:49:03] thread 3: 46596 hashes, 8.11 khash/s
基本的にはコア数以上には、パフォーマンスが上がらないことがわかりました。
sysの下を毎度見るのも見にくいですので、sensorsコマンドを入れてみます。
$ sudo apt-get install lm-sensors $ sensors coretemp-isa-0000 coretemp-isa-0000 Adapter: ISA adapter Physical id 0: +101.0 C (high = +87.0 C, crit = +105.0 C) Core 0: +98.0 C (high = +87.0 C, crit = +105.0 C) Core 1: +100.0 C (high = +87.0 C, crit = +105.0 C) Core 2: +101.0 C (high = +87.0 C, crit = +105.0 C) Core 3: +98.0 C (high = +87.0 C, crit = +105.0 C)
上限105度で強制停止させらる設定になっています。
結構微妙なところで動いている模様です。
気温の低い冬はいいですが、夏場は無理そうですね。
ローカルと合わせて、3倍速の処理ができるようになったのですが、採掘のほうは一向に成果が上がりません。
最初に出たのは、ビギナーズラックだったのですね... orz
Monacoin: MEFfn469EWqYNAHwn3rhuFWiT53EFKnBpb