ラズパイでFactomのフルノードを運用してみる手順メモ
ラズパイにFactomをインストールして常時運用してみます。MacBook AirでFactom(FCT)の管理のためにWalletを動かしてましたが、使うたびにブロックチェーンを同期するのが面倒&時間がかかるので、常時起動のラズパイにデーモンを稼働しておいて、Macbook AirはFactomのWalletGUIのみ使用する。
参考文献:https://docs.factom.com/#welcome
1.ブロックチェンデータのダウンロード
まずは同期時間を短縮するためブロックチェーンデータをダウンロードしておきます。2017年4月現在5G以上ありますのでそこそこ時間がかかります。
$ mkdir ~/.factom $ wget https://www.factom.com/assets/site/factom_bootstrap.zip
ファイルを解凍する
$ unzip factom_bootstrap.zip
2.Factom ソフトウェアをダウンロード
Githubから最新版のソフトウェアをダウンロードします。執筆時点の最新版はRelease v0.4.1.2(2017/5/1現在)ですが、バージョンによってい下のコマンドのリンクを変更してください。
https://github.com/FactomProject/distribution/releases
https://github.com/FactomProject/FactomDocs/blob/master/installFromSourceDirections.md
gitをインストール(まだインストールされていない場合)
$ sudo apt-get install git
GO言語をダウンロードしてインストール (https://golang.org/dl/)
$ cd ~/bin $ wget https://storage.googleapis.com/golang/go1.8.1.linux-armv6l.tar.gz $ sudo tar -C /usr/local -xzf go1.8.1.linux-armv6l.tar.gz $ export PATH=$PATH:/usr/local/go/bin $ export GOPATH=$HOME/go $ export PATH=$PATH:$GOPATH/bin
注)パスは .profileにも追加しておきます。
Goのパッケージマネージャglideをインストール
$ go get -u github.com/Masterminds/glide
Factomのソースコードをダウンロード(すでにインストール済みでバージョンアップの場合はここから)
$ git clone https://github.com/FactomProject/factomd $GOPATH/src/github.com/FactomProject/factomd $ git clone https://github.com/FactomProject/factom-cli $GOPATH/src/github.com/FactomProject/factom-cli
Wallet機能を使いたい場合(私はMacでWalletを使うのでスキップ)
$ git clone https://github.com/FactomProject/factom-walletd $GOPATH/src/github.com/FactomProject/factom-walletd $ git clone https://github.com/FactomProject/enterprise-wallet $GOPATH/src/github.com/FactomProject/enterprise-wallet
特定のバージョンを選びたい場合
$ git checkout v0.4.0.3
依存関係をチェックしてビルドする
$ glide cc
factomd(サーバー)とfactom-cli(クライアントコマンド)のインストール
$ cd $GOPATH/src/github.com/FactomProject/factomd $ glide install $ go install -v -ldflags "-X github.com/FactomProject/factomd/engine.Build=`git rev-parse HEAD`" $ cd $GOPATH/src/github.com/FactomProject/factom-cli $ glide install $ go install -v
以下はWallet機能を使いたい場合だが、Wallet GUIはMac bookを使う予定なので必要ない
$ cd $GOPATH/src/github.com/FactomProject/factom-walletd $ glide install $ go install -v $ cd $GOPATH/src/github.com/FactomProject/enterprise-wallet $ glide install $ go install -v
3.factomdの起動
Factomサーバーを起動(nohupコマンドでバックグランドで起動させる)
$ nohup /usr/local/go/bin/factomd > /home/pi/.factom/factomd.log" & $ tail -f /home/pi/.factom/factomd.log
//////////////////////// Copyright 2017 Factom Foundation //////////////////////// Use of this source code is governed by the MIT //////////////////////// license that can be found in the LICENSE file. Go compiler version: go1.8.1 Using build: 987d865b3ac4a2a672fbbf11fdc04fb4a7b170fe
ログが表示されれば成功
ラズパイの起動時に自動起動したい場合は以下を/etc/rc.localの最後(exit0の前)に追加
printf "Starting factomd....\n" (sleep 10; sudo su - pi -c "nohup /usr/local/go/bin/factomd > /home/pi/.factom/factomd.log" ) &
サーバーの起動確認
パソコンから https://192.168.0.2(ラズパイIP):8090/ でFactomサーバーの画面が表示されれば成功!
3.MacBookへEnterprise Walletをインストール
https://docs.factom.com/#install-enterprise-wallet