LoginSignup
10
9

More than 5 years have passed since last update.

Hyperledger iroha 0.75 を4台構成で動かす

Posted at

2017/3/23現在の情報です。
irohaは日々開発が進んでいるので、最新の情報はレポジトリから読み解いてください。

Hyperledger iroha 0.75 を動かす on ubuntu with docker
では、irohaサーバー1台を動かしました。でもせっかくブロックチェーンなので複数台で協調動作をしているところを確かめたい、というわけで4台構成で動かすバージョンです。

オープンソースのブロックチェーン Hyperledger iroha をDockerで試してみた
がベースです。見比べながら手順を進めてください。

目指すところ

  • AWS上にirohaのサーバーが4台で協調動作している状態を作る
    • dockerで動作
    • iroha4台の構成(iroha1~4)
    • irohaのbranchはmasterが対象
  • 外部から、50051(gRPC)へ接続できる→iroha4がリクエストを受ける

AWSのインスタンス作成

ここでは、AWSにて構築します。ubuntuを選択します。

AWSのネットワーク設定

インバウンドのTCP50051ポートを開ける。
送信元はよしなに。

環境構築

今回は、
iroha-docker を利用します。ただし、ちと古いので、forkしたこちらを利用します。

準備

  • 必要なパッケージをインストールする
$ sudo apt-get update
$ sudo apt install build-essential automake autoconf
$ git clone -b feature/upgrade-to-0.75 --recursive https://github.com/hidehigo/iroha-docker.git iroha-docker

iroha-devのbuild

iroha-docker/iroha-dev はirohaコンテナのベースとなるイメージを作成するためのものです。

$ cd ~/iroha-docker/iroha-dev
$ sudo docker build -t hyperledger/iroha-dev .

irohaのbuild

iroha-docker/iroha はirohaが実際に動作するイメージです。

$ cd ~/iroha-docker/iroha
$ sudo docker build -t hyperledger/iroha .

irohaが動くために必要なconfig類、データディレクトリの用意

$ cd ~/iroha-docker/iroha
$ sudo mkdir /opt/iroha
$ sudo chown ubuntu:ubuntu /opt/iroha
$ rsync -av config /opt/iroha
$ sudo chmod -R 777 /opt/iroha/ledger/

補足

ホストの/opt/irohaは、dockerコンテナ上からmountされます。

/opt/iroha/
├── config
│   ├── config1            //config1はiroha1からmountされます。以下同様
│   │   ├── config.json    //基本設定。各フォルダで同一の内容
│   │   └── sumeragi.json  //自身と協調するサーバー毎の設定情報
│   ├── config2
│   │   ├── config.json 
│   │   └── sumeragi.json
│   ├── config3
│   │   ├── config.json
│   │   └── sumeragi.json
│   └── config4
│       ├── config.json
│       └── sumeragi.json
└── ledger
    ├── iroha_ledger1       //ブロックチェーンのデータ本体
    ├── iroha_ledger2
    ├── iroha_ledger3
    └── iroha_ledger4

コンテナの起動

$ cd ~/iroha-docker/iroha
$ sudo ./run_iroha.sh

で起動できます。iroha4が、50051で応答します。

できあがり

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                              NAMES
d2b94f414627        hyperledger/iroha   "/bin/su - iroha -..."   About an hour ago   Up About an hour    0.0.0.0:1204->1204/tcp, 0.0.0.0:50051->50051/tcp   iroha4
83bbc00dfde7        hyperledger/iroha   "/bin/su - iroha -..."   About an hour ago   Up About an hour                                                       iroha3
b3e2d7f72031        hyperledger/iroha   "/bin/su - iroha -..."   About an hour ago   Up About an hour                                                       iroha2
4ccdcd42146a        hyperledger/iroha   "/bin/su - iroha -..."   About an hour ago   Up About an hour                                                       iroha1

参考リンク

10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9