Geth環境のじゅんび
どうも、ぺろりんです。
前回に引き続き、「はじめてのブロックチェーン・アプリケーション Ethereumによるスマートコントラクト開発入門 (DEV Engineer's Books)」でのお勉強のつづきをやっていきます。
今回は、テスト環境の構築です。
教科書にしている上記の本がUbuntu(Linux)だったので、普段Windowsな私の場合、VMwareの仮想環境で仮想マシンを作成してゲストOSとしてUbuntuを入れることにしました。
というわけで、手順としては
VMware Player導入→仮想マシン作成&Ubuntuインストール→Gethインストール
と進みます。
VMware Player導入
VMware Playerのダウンロードページからダウンロードしてインストール…なんですが、以前入れたときに手順残してなかったので、ここは参考サイトを挙げるにとどめさせていただきます。。
いくつか挙げておきますので、参考にされる方はご自分がわかりやすいと思うのをご参照ください。
(参考)
・VMware Workstation Player ダウンロードとインストール方法(ネットワークエンジニアとして)
・仮想マシン構築ソフト「VMware Player」のインストール方法(寝ログ)
・【ゼロからわかる】VMwareのインストール方法と使い方(エンジニアの入り口)
仮想マシン作成&Ubuntuインストール
まずはUbuntuをダウンロードしておきましょう。

[日本語 Remix イメージのダウンロード]かisoファイルを落とします。

導入しておいたVMware Playerを立ち上げて、[新規仮想マシンの作成]。

[インストーラ ディスク イメージ ファイル]で先ほど落としてきたUbuntuのisoファイルを[参照]させます。

[フルネーム]とかユーザー名やパスワードなど適当に設定しておきます。

テスト環境作りたいだけなので、基本的にデフォルトで進行。


ここは一応、[ハードウェアをカスタマイズ]しておきます。

これの設定は、「ブロックチェーン 仕組みと理論 サンプルで学ぶFinTechのコア技術」
でEthereumの章に記載されているスペックを参考にしています。たぶんこんなもんで大丈夫でしょう。。

こーいうのはとりあえず気にせず[OK]にしときます。

インストールできたらこんな感じになるので、先ほど設定したパスワードを入力してログインします。


なんか出てきても気にしない。[キャンセル]でいきます。

デフォルトだと画面ちっちゃいので、これを解消しましょう。
左にあるギアを開き、[ディスプレイ]を選択。


解像度を大きくします。こんなもんかな?


で、こんな感じになりました。

次に、root(Linuxの管理者ユーザー)の設定を一応しておきましょう。
普通のユーザーでGethをインストールしようとしたらうまくいかなかったので、本の通りすすんでみてうまいかない方がいたら参考にしてみてください。
左上のアイコンを選んで「te」くらいを入力すると出てくる端末(terminal)を選びます。これがWindowsのコマンドプロンプトに対応するやつで、コマンド入れるときは毎回これを使います。


端末を開くとこんな画面になります。(上の文はあまり気にしないでください)

「sudo passwd root」と入力してやると、こんな感じで今入っているユーザーのパスワードを入力させられ、そのあとにrootユーザーのパスワードの変更ができます。忘れないようにしましょう。

終わったら、「su -」(「-」はオプションなのでなくても良い)と打ってパスワードを入力するとrootユーザーとしてログインできることを確認します。「$」から「#」になったらOKです。

これで仮想マシンまでの準備が終わりました。
Gethインストール
さてここまではOSのおはなしでしたが、ここからEthereumの環境づくりをしましょう。
ここからは基本、「はじめてのブロックチェーン・アプリケーション Ethereumによるスマートコントラクト開発入門 (DEV Engineer's Books)」に忠実にすすみたい…!
私はGitとかLinuxは慣れてないので、環境づくりはひとまず「おまじない」と思って内容はあまり気にせずすすみます。
あとになって戻れたら戻ります。さしあたりスマートコントラクトのお勉強がしたいので。
本のとおり、以下のコマンドで必要なものをインストールします。
参考までに、コマンドたたいたらこんな感じになりました。
次はソースをクローンだそうです。
参考までに。
バージョンの切り替え。
参考。
ビルド。
参考。
バージョンは問題なさそうです。
gethを/usr/local/binにコピー。
一応コピーできたか確認。
これはPathの確認だそうです。
これでGethのインストールが終わったみたいです。(まだあんまわかってない)
まとめ
今回は、勉強環境を作りました。
VMwareで仮想マシンを作成してUbuntuをインストールし、そこにGethをインストールしました。
次回はテストネットワークでGethの起動です。
※ちなみに、このページのコード部分はSyntaxhighlighter(v3.0.83)を使っております。…ハイライトがうまくいかねぇ。。
導入はこことここの手順を参考にさせていただきました。
Git慣れてないので、とくに2つ目のサイトの人、かゆいところに手が届く内容でマジGJです。
fc2にファイルをうpするときは、フォルダじゃなくてファイル自体を上げないと、上記のサイトで書いてくれていたHTMLの内容を使えないので注意。まぁフォルダうpできないんでしょうが。。
前回に引き続き、「はじめてのブロックチェーン・アプリケーション Ethereumによるスマートコントラクト開発入門 (DEV Engineer's Books)」でのお勉強のつづきをやっていきます。
今回は、テスト環境の構築です。
教科書にしている上記の本がUbuntu(Linux)だったので、普段Windowsな私の場合、VMwareの仮想環境で仮想マシンを作成してゲストOSとしてUbuntuを入れることにしました。
というわけで、手順としては
VMware Player導入→仮想マシン作成&Ubuntuインストール→Gethインストール
と進みます。
VMware Player導入
VMware Playerのダウンロードページからダウンロードしてインストール…なんですが、以前入れたときに手順残してなかったので、ここは参考サイトを挙げるにとどめさせていただきます。。
いくつか挙げておきますので、参考にされる方はご自分がわかりやすいと思うのをご参照ください。
(参考)
・VMware Workstation Player ダウンロードとインストール方法(ネットワークエンジニアとして)
・仮想マシン構築ソフト「VMware Player」のインストール方法(寝ログ)
・【ゼロからわかる】VMwareのインストール方法と使い方(エンジニアの入り口)
仮想マシン作成&Ubuntuインストール
まずはUbuntuをダウンロードしておきましょう。

[日本語 Remix イメージのダウンロード]かisoファイルを落とします。

導入しておいたVMware Playerを立ち上げて、[新規仮想マシンの作成]。

[インストーラ ディスク イメージ ファイル]で先ほど落としてきたUbuntuのisoファイルを[参照]させます。

[フルネーム]とかユーザー名やパスワードなど適当に設定しておきます。

テスト環境作りたいだけなので、基本的にデフォルトで進行。


ここは一応、[ハードウェアをカスタマイズ]しておきます。

これの設定は、「ブロックチェーン 仕組みと理論 サンプルで学ぶFinTechのコア技術」

こーいうのはとりあえず気にせず[OK]にしときます。

インストールできたらこんな感じになるので、先ほど設定したパスワードを入力してログインします。


なんか出てきても気にしない。[キャンセル]でいきます。

デフォルトだと画面ちっちゃいので、これを解消しましょう。
左にあるギアを開き、[ディスプレイ]を選択。


解像度を大きくします。こんなもんかな?


で、こんな感じになりました。

次に、root(Linuxの管理者ユーザー)の設定を一応しておきましょう。
普通のユーザーでGethをインストールしようとしたらうまくいかなかったので、本の通りすすんでみてうまいかない方がいたら参考にしてみてください。
左上のアイコンを選んで「te」くらいを入力すると出てくる端末(terminal)を選びます。これがWindowsのコマンドプロンプトに対応するやつで、コマンド入れるときは毎回これを使います。


端末を開くとこんな画面になります。(上の文はあまり気にしないでください)

「sudo passwd root」と入力してやると、こんな感じで今入っているユーザーのパスワードを入力させられ、そのあとにrootユーザーのパスワードの変更ができます。忘れないようにしましょう。

終わったら、「su -」(「-」はオプションなのでなくても良い)と打ってパスワードを入力するとrootユーザーとしてログインできることを確認します。「$」から「#」になったらOKです。

これで仮想マシンまでの準備が終わりました。
Gethインストール
さてここまではOSのおはなしでしたが、ここからEthereumの環境づくりをしましょう。
ここからは基本、「はじめてのブロックチェーン・アプリケーション Ethereumによるスマートコントラクト開発入門 (DEV Engineer's Books)」に忠実にすすみたい…!
私はGitとかLinuxは慣れてないので、環境づくりはひとまず「おまじない」と思って内容はあまり気にせずすすみます。
あとになって戻れたら戻ります。さしあたりスマートコントラクトのお勉強がしたいので。
本のとおり、以下のコマンドで必要なものをインストールします。
root@ubuntu:~# sudo apt-get install -y build-essential libgmp3-dev golang git tree
参考までに、コマンドたたいたらこんな感じになりました。
.../tree_1.7.0-3_amd64.deb を展開する準備をしています ...
tree (1.7.0-3) を展開しています...
以前に未選択のパッケージ golang-1.6-race-detector-runtime を選択しています。
.../golang-1.6-race-detector-runtime_0.0+svn252922-0ubuntu1_amd64.deb を展開する準備をしています ...
golang-1.6-race-detector-runtime (0.0+svn252922-0ubuntu1) を展開しています...
以前に未選択のパッケージ golang-race-detector-runtime を選択しています。
.../golang-race-detector-runtime_2%3a1.6-1ubuntu4_amd64.deb を展開する準備をしています ...
golang-race-detector-runtime (2:1.6-1ubuntu4) を展開しています...
man-db (2.7.5-1) のトリガを処理しています ...
libc-bin (2.23-0ubuntu3) のトリガを処理しています ...
liberror-perl (0.17-1.2) を設定しています ...
git-man (1:2.7.4-0ubuntu1.3) を設定しています ...
git (1:2.7.4-0ubuntu1.3) を設定しています ...
golang-1.6-src (1.6.2-0ubuntu5~16.04.4) を設定しています ...
golang-1.6-go (1.6.2-0ubuntu5~16.04.4) を設定しています ...
golang-1.6-doc (1.6.2-0ubuntu5~16.04.4) を設定しています ...
golang-1.6 (1.6.2-0ubuntu5~16.04.4) を設定しています ...
golang-src (2:1.6-1ubuntu4) を設定しています ...
golang-go (2:1.6-1ubuntu4) を設定しています ...
golang-doc (2:1.6-1ubuntu4) を設定しています ...
golang (2:1.6-1ubuntu4) を設定しています ...
libgmpxx4ldbl:amd64 (2:6.1.0+dfsg-2) を設定しています ...
libgmp-dev:amd64 (2:6.1.0+dfsg-2) を設定しています ...
libgmp3-dev (2:6.1.0+dfsg-2) を設定しています ...
tree (1.7.0-3) を設定しています ...
golang-1.6-race-detector-runtime (0.0+svn252922-0ubuntu1) を設定しています ...
golang-race-detector-runtime (2:1.6-1ubuntu4) を設定しています ...
libc-bin (2.23-0ubuntu3) のトリガを処理しています ...
次はソースをクローンだそうです。
root@ubuntu:~# cd
root@ubuntu:~# git clone https://github.com/ethereum/go-ethereum.git
参考までに。
Cloning into 'go-ethereum'...
remote: Counting objects: 68949, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 68949 (delta 9), reused 14 (delta 5), pack-reused 68913
Receiving objects: 100% (68949/68949), 95.09 MiB | 275.00 KiB/s, done.
Resolving deltas: 100% (45835/45835), done.
Checking connectivity... done.
バージョンの切り替え。
root@ubuntu:~# cd go-ethereum/
root@ubuntu:~/go-ethereum# git checkout refs/tags/v1.5.5
参考。
Note: checking out 'refs/tags/v1.5.5'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b
HEAD is now at ff07d54... Merge pull request #3440 from karalabe/release-1.5.5
ビルド。
root@ubuntu:~/go-ethereum# make geth
参考。
build/env.sh go run build/ci.go install ./cmd/geth
>>> /usr/lib/go-1.6/bin/go install -ldflags -X main.gitCommit=ff07d54843ea7ed9997c420d216b4c007f9c80c3 -v ./cmd/geth
github.com/ethereum/go-ethereum/common/hexutil
github.com/ethereum/go-ethereum/common
github.com/ethereum/go-ethereum/crypto/randentropy
github.com/ethereum/go-ethereum/crypto/secp256k1
github.com/ethereum/go-ethereum/crypto/ecies
github.com/ethereum/go-ethereum/crypto/sha3
github.com/ethereum/go-ethereum/rlp
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/ripemd160
github.com/ethereum/go-ethereum/crypto
github.com/ethereum/go-ethereum/logger
github.com/ethereum/go-ethereum/logger/glog
github.com/ethereum/go-ethereum/common/math
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/httpu
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/scpd
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/soap
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/ssdp
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/atom
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal/identifier
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/transform
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/charmap
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/japanese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/korean
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/simplifiedchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/traditionalchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/utf8internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/runes
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/unicode
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/tag
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/htmlindex
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/charset
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway1
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway2
github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp
github.com/ethereum/go-ethereum/p2p/nat
github.com/ethereum/go-ethereum/p2p/netutil
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/cache
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/comparer
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/errors
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/filter
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/iterator
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/journal
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/memdb
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/opt
github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/table
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb
github.com/ethereum/go-ethereum/p2p/discover
github.com/ethereum/go-ethereum/vendor/github.com/aristanetworks/goarista/monotime
github.com/ethereum/go-ethereum/common/mclock
github.com/ethereum/go-ethereum/p2p/discv5
github.com/ethereum/go-ethereum/params
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru/simplelru
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru
github.com/ethereum/go-ethereum/core/vm
github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics
github.com/ethereum/go-ethereum/vendor/github.com/rcrowley/go-metrics/exp
github.com/ethereum/go-ethereum/metrics
github.com/ethereum/go-ethereum/ethdb
github.com/ethereum/go-ethereum/vendor/gopkg.in/karalabe/cookiejar.v2/collections/prque
github.com/ethereum/go-ethereum/trie
github.com/ethereum/go-ethereum/core/types
github.com/ethereum/go-ethereum/pow
github.com/ethereum/go-ethereum/vendor/github.com/ethereum/ethash
github.com/ethereum/go-ethereum/vendor/github.com/pborman/uuid
github.com/ethereum/go-ethereum/vendor/github.com/rjeczalik/notify
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/pbkdf2
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/scrypt
github.com/ethereum/go-ethereum/accounts
github.com/ethereum/go-ethereum/core/state
github.com/ethereum/go-ethereum/event
github.com/ethereum/go-ethereum/vendor/gopkg.in/fatih/set.v0
github.com/ethereum/go-ethereum/core
golang.org/x/net/context
github.com/ethereum/go-ethereum
github.com/ethereum/go-ethereum/vendor/github.com/rs/xhandler
github.com/ethereum/go-ethereum/vendor/github.com/rs/cors
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/websocket
github.com/ethereum/go-ethereum/rpc
github.com/ethereum/go-ethereum/eth/downloader
github.com/ethereum/go-ethereum/eth/fetcher
github.com/ethereum/go-ethereum/eth/filters
github.com/ethereum/go-ethereum/common/compiler
github.com/ethereum/go-ethereum/p2p
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1/base64vlq
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/file
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/token
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/ast
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/dbg
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/parser
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/registry
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto
github.com/ethereum/go-ethereum/internal/ethapi
github.com/ethereum/go-ethereum/eth/gasprice
github.com/ethereum/go-ethereum/miner
github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1
github.com/ethereum/go-ethereum/internal/debug
github.com/ethereum/go-ethereum/node
github.com/ethereum/go-ethereum/eth
github.com/ethereum/go-ethereum/les/flowcontrol
github.com/ethereum/go-ethereum/light
github.com/ethereum/go-ethereum/les
github.com/ethereum/go-ethereum/ethstats
github.com/ethereum/go-ethereum/event/filter
github.com/ethereum/go-ethereum/whisper/whisperv2
github.com/ethereum/go-ethereum/cmd/utils
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-colorable
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-isatty
github.com/ethereum/go-ethereum/vendor/github.com/fatih/color
github.com/ethereum/go-ethereum/internal/jsre
github.com/ethereum/go-ethereum/internal/web3ext
github.com/ethereum/go-ethereum/vendor/github.com/peterh/liner
github.com/ethereum/go-ethereum/console
github.com/ethereum/go-ethereum/accounts/abi
github.com/ethereum/go-ethereum/vendor/golang.org/x/tools/go/ast/astutil
github.com/ethereum/go-ethereum/vendor/golang.org/x/tools/imports
github.com/ethereum/go-ethereum/accounts/abi/bind
github.com/ethereum/go-ethereum/contracts/release
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-runewidth
github.com/ethereum/go-ethereum/vendor/github.com/mitchellh/go-wordwrap
github.com/ethereum/go-ethereum/vendor/github.com/nsf/termbox-go
github.com/ethereum/go-ethereum/vendor/github.com/gizak/termui
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "build/bin/geth" to launch geth.
バージョンは問題なさそうです。
root@ubuntu:~/go-ethereum# ./build/bin/geth version
Geth
Version: 1.5.5-stable
Git Commit: ff07d54843ea7ed9997c420d216b4c007f9c80c3
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.6.2
OS: linux
GOPATH=
GOROOT=/usr/lib/go-1.6
gethを/usr/local/binにコピー。
root@ubuntu:~/go-ethereum# sudo cp build/bin/geth /usr/local/bin/
一応コピーできたか確認。
root@ubuntu:~/go-ethereum# ls /usr/local/bin/
geth
これはPathの確認だそうです。
root@ubuntu:~/go-ethereum# which geth
/usr/local/bin/get
これでGethのインストールが終わったみたいです。(まだあんまわかってない)
まとめ
今回は、勉強環境を作りました。
VMwareで仮想マシンを作成してUbuntuをインストールし、そこにGethをインストールしました。
次回はテストネットワークでGethの起動です。
※ちなみに、このページのコード部分はSyntaxhighlighter(v3.0.83)を使っております。…ハイライトがうまくいかねぇ。。
導入はこことここの手順を参考にさせていただきました。
Git慣れてないので、とくに2つ目のサイトの人、かゆいところに手が届く内容でマジGJです。
fc2にファイルをうpするときは、フォルダじゃなくてファイル自体を上げないと、上記のサイトで書いてくれていたHTMLの内容を使えないので注意。まぁフォルダうpできないんでしょうが。。