LoginSignup
5
3

More than 5 years have passed since last update.

Hyperledger Fabric 1.0 環境構築 (Ubuntu, VirtualBox, Windows10)

Last updated at Posted at 2018-02-18

はじめに

ブロックチェーンテクノジーの1つであるHyperledgerの環境を作り、実際にトランザクションを登録してみる予定です。今回はHyperledger Fabricを使って環境構築をしてみます。Hyperledger Fabricは、Hyperledgerを実用化するプロジェクトのうちの1つで、IBMが主導しているプロジェクトのようです。

※トランザクション発生はこちらにて。

1. 前提

以下の環境で動作した内容を記述しています。

Windows 10 Home (64bit)
Vagrant 2.0.2
VirtualBox 5.2
bento/ubuntu-16.04
Hyperledger Fabric 1.1.0-rc1

2. VgrantでUbuntu環境を構築

以下をインストール
https://www.vagrantup.com/
https://www.virtualbox.org/

Vagrant Boxは以下を使用します。
https://app.vagrantup.com/bento/boxes/ubuntu-16.04

Vagrant initで初期設定。

c:\dev\vagrant>vagrant -v
Vagrant 2.0.2

c:\dev\vagrant>vagrant init bento/ubuntu-16.04
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

Vagrantfileが作成されるので、config.vm.networkの部分をコメントアウトします。

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "private_network", ip: "192.168.33.10"

vagrant upで起動します。

c:\dev\vagrant>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'bento/ubuntu-16.04' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'bento/ubuntu-16.04'
    default: URL: https://vagrantcloud.com/bento/ubuntu-16.04
==> default: Adding box 'bento/ubuntu-16.04' (v201802.02.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/bento/boxes/ubuntu-16.04/versions/201802.02.0/providers/virtualbox.box
<<中略>>
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/dev/vagrant

3. dockerとdocker-composeをインストール

sshでUbuntuにログインします。
User ID: vagrant, Password: vagrantでログインできます。
パスワードはログイン後に変更しましょう。

login as: vagrant
vagrant@192.168.33.10's password:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-87-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.


vagrant@vagrant:~$

dockerとdocker-composeをインストール。

sudo apt-get update
sudo apt install docker.io
sudo apt install docker-compose

でdocker関連で必要なものをインストールします。
(docker-composeをインストールすればdocker.ioもインストールされます)
以下、実行結果です。

vagrant@vagrant:~$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
<<中略>>
Fetched 4,947 kB in 15s (323 kB/s)
Reading package lists... Done
vagrant@vagrant:~$
vagrant@vagrant:~$
vagrant@vagrant:~$ sudo apt install docker-compose
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  bridge-utils cgroupfs-mount containerd docker.io libyaml-0-2
  python-backports.ssl-match-hostname python-cached-property
<<中略>>
Setting up docker.io (1.13.1-0ubuntu1~16.04.2) ...
Adding group `docker' (GID 117) ...
Done.
Setting up python-cffi-backend (1.5.2-1ubuntu1) ...
Setting up python-idna (2.0-3) ...
Setting up python-pyasn1 (0.1.9-1) ...
Setting up python-cryptography (1.2.3-1ubuntu0.1) ...
Setting up python-openssl (0.15.1-2build1) ...
Setting up python-ndg-httpsclient (0.4.0-3) ...
Setting up ubuntu-fan (0.12.8~16.04.2) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
vagrant@vagrant:~$ 

以下のコマンドで、rootではなく自分のユーザーでdockerを起動します。

sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart

以下、実行結果です。

vagrant@vagrant:~$ sudo groupadd docker
groupadd: group 'docker' already exists
vagrant@vagrant:~$ sudo gpasswd -a ${USER} docker
Adding user vagrant to group docker
vagrant@vagrant:~$ sudo service docker restart
vagrant@vagrant:~$
vagrant@vagrant:~$
vagrant@vagrant:~$ docker --version
Docker version 1.13.1, build 092cba3
vagrant@vagrant:~$ docker-compose version
docker-compose version 1.8.0, build unknown
docker-py version: 1.9.0
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016

4. Go言語のインストール

Hyperledger Fabricでは、Go言語のversion 1.7.x以上が必要となるため、aptではなく手動でインストールします。

wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz && \
sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz && \
rm go1.8.3.linux-amd64.tar.gz && \
echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile && \
echo 'export GOPATH=$HOME/go' | tee -a $HOME/.bashrc && \
echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' | tee -a $HOME/.bashrc && \
mkdir -p $HOME/go/{src,pkg,bin}

を実施します。

以下、実行結果です。

vagrant@vagrant:~$ wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz && \
> sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz && \
> rm go1.8.3.linux-amd64.tar.gz && \
> echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile && \
> echo 'export GOPATH=$HOME/go' | tee -a $HOME/.bashrc && \
> echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' | tee -a $HOME/.bashrc && \
> mkdir -p $HOME/go/{src,pkg,bin}
--2018-02-18 01:10:00--  https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
Resolving storage.googleapis.com (storage.googleapis.com)... 216.58.200.176
Connecting to storage.googleapis.com (storage.googleapis.com)|216.58.200.176|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 90029041 (86M) [application/x-gzip]
Saving to: ‘go1.8.3.linux-amd64.tar.gz’

go1.8.3.linux-amd64 100%[===================>]  85.86M  6.39MB/s    in 13s

2018-02-18 01:10:13 (6.74 MB/s) - ‘go1.8.3.linux-amd64.tar.gz’ saved [90029041/90029041]

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

ここで一度ログインし直し、GO言語のバージョンが正常に表示されればOKです。

vagrant@vagrant:~$ go version
go version go1.8.3 linux/amd64

5. Hyperledger Fabric環境を構築

sudo curl -sSL https://goo.gl/byy2Qj | bash -s 1.1.0-rc1

で必要なバイナリーをダウンロードします。

vagrant@vagrant:~$ sudo curl -sSL https://goo.gl/byy2Qj | bash -s 1.1.0-rc1
===> Downloading platform binaries
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 35.4M  100 35.4M    0     0  2764k      0  0:00:13  0:00:13 --:--:-- 3264k
===> Pulling fabric Images
==> FABRIC IMAGE: peer

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-peer
1be7f2b886e8: Pull complete
6fbc4a21b806: Pull complete
<<中略>>
c1815d6e0dbd: Pull complete
df397132c393: Pull complete
Digest: sha256:2cd593c5821b7b30997eebd87284d766501c1c98ba0838c6478fe45bb4ae9552
Status: Downloaded newer image for hyperledger/fabric-peer:x86_64-1.1.0-rc1
==> FABRIC IMAGE: orderer

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-orderer
1be7f2b886e8: Already exists
<<中略>>
e74a3a99fe86: Already exists
e87f5fb58ad0: Pull complete
a31db65119a3: Pull complete
Digest: sha256:fd5549b24c1ebd1b69ac9863aafe36220d9c554066ba48f49dc4bbb6cb8d7bdb
Status: Downloaded newer image for hyperledger/fabric-orderer:x86_64-1.1.0-rc1
==> FABRIC IMAGE: couchdb

Error response from daemon: manifest for hyperledger/fabric-couchdb:x86_64-1.1.0                                                                 -rc1 not found
Error response from daemon: no such id: hyperledger/fabric-couchdb:x86_64-1.1.0-                                                                 rc1
==> FABRIC IMAGE: ccenv

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-ccenv
1be7f2b886e8: Already exists
6fbc4a21b806: Already exists
<<中略>>
161da62af955: Pull complete
154d29a2fc56: Pull complete
Digest: sha256:62a9a37d3bb00fc945b9284eaf018d8a2f99eb6c80c400ac012a7d0f8b6cda92
Status: Downloaded newer image for hyperledger/fabric-ccenv:x86_64-1.1.0-rc1
==> FABRIC IMAGE: javaenv

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-javaenv
1be7f2b886e8: Already exists
6fbc4a21b806: Already exists
<<中略>>
04569d868e5a: Pull complete
8cd1a2bc9ab0: Pull complete
Digest: sha256:ec7ba4d49f0f24c2e78d715b4ce6e0ece83f1bb9f655e1fba5689c5b6a85505d
Status: Downloaded newer image for hyperledger/fabric-javaenv:x86_64-1.1.0-rc1
==> FABRIC IMAGE: kafka

Error response from daemon: manifest for hyperledger/fabric-kafka:x86_64-1.1.0-r                                                                 c1 not found
Error response from daemon: no such id: hyperledger/fabric-kafka:x86_64-1.1.0-rc                                                                 1
==> FABRIC IMAGE: zookeeper

Error response from daemon: manifest for hyperledger/fabric-zookeeper:x86_64-1.1                                                                 .0-rc1 not found
Error response from daemon: no such id: hyperledger/fabric-zookeeper:x86_64-1.1.                                                                 0-rc1
==> FABRIC IMAGE: tools

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-tools
1be7f2b886e8: Already exists
6fbc4a21b806: Already exists
<<中略>>
6e94cdba0791: Pull complete
cf5d44fff6fe: Pull complete
Digest: sha256:e80b049473792fe82c18418f2b06541b84ed7b0ccf90d24f61872773ecff4a72
Status: Downloaded newer image for hyperledger/fabric-tools:x86_64-1.1.0-rc1
===> Pulling fabric ca Image
==> FABRIC CA IMAGE

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-ca
1be7f2b886e8: Already exists
6fbc4a21b806: Already exists
<<中略>>
23385c4db996: Pull complete
946161ef2f63: Pull complete
Digest: sha256:fb458b405ea1aaf7570a10cc1f914de2ca5ddb683f13138e380c00d180683afc
Status: Downloaded newer image for hyperledger/fabric-ca:x86_64-1.1.0-rc1

===> List out hyperledger docker images
hyperledger/fabric-ca        latest              8a6c8c2e2ebf        2 days ago                                                                           283 MB
hyperledger/fabric-ca        x86_64-1.1.0-rc1    8a6c8c2e2ebf        2 days ago                                                                           283 MB
hyperledger/fabric-tools     latest              006c689ec08e        2 days ago                                                                           1.46 GB
hyperledger/fabric-tools     x86_64-1.1.0-rc1    006c689ec08e        2 days ago                                                                           1.46 GB
hyperledger/fabric-orderer   latest              10afc128d402        2 days ago                                                                           180 MB
hyperledger/fabric-orderer   x86_64-1.1.0-rc1    10afc128d402        2 days ago                                                                           180 MB
hyperledger/fabric-peer      latest              6b44b1d021cb        2 days ago                                                                           187 MB
hyperledger/fabric-peer      x86_64-1.1.0-rc1    6b44b1d021cb        2 days ago                                                                           187 MB
hyperledger/fabric-javaenv   latest              ea263125afb1        2 days ago                                                                           1.52 GB
hyperledger/fabric-javaenv   x86_64-1.1.0-rc1    ea263125afb1        2 days ago                                                                           1.52 GB
hyperledger/fabric-ccenv     latest              65c951b9681f        2 days ago                                                                           1.39 GB
hyperledger/fabric-ccenv     x86_64-1.1.0-rc1    65c951b9681f        2 days ago                                                                           1.39 GB
vagrant@vagrant:~$

6.Hyperledger Fabric Samplesを使って起動

6.1 サンプルのサウンロード

gitでサンプルをダウロードし、first-networkにあるスクリプトでHyperledger Fabric networkを起動します。
ここでは4つのpeerで構成される2つの組織とordererのnodeが起動します。

fabric-samples/first-networkフォルダへ移動します。

vagrant@vagrant:~$ git clone https://github.com/hyperledger/fabric-samples.git
Cloning into 'fabric-samples'...
remote: Counting objects: 1067, done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 1067 (delta 25), reused 39 (delta 8), pack-reused 1010
Receiving objects: 100% (1067/1067), 375.35 KiB | 398.00 KiB/s, done.
Resolving deltas: 100% (428/428), done.
Checking connectivity... done.
vagrant@vagrant:~$ cd fabric-samples/
vagrant@vagrant:~/fabric-samples$ cd first-network
vagrant@vagrant:~/fabric-samples/first-network$

6.2 ネットワークの生成

./byfn.sh -m generateでネットワークを生成します。

vagrant@vagrant:~/fabric-samples/first-network$ ./byfn.sh -m generate
Generating certs and genesis block for with channel 'mychannel' and CLI timeout of '10'
Continue (y/n)? y
proceeding ...
/home/vagrant/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
org2.example.com

/home/vagrant/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
2018-03-04 10:05:14.254 UTC [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-03-04 10:05:14.261 UTC [common/tools/configtxgen] doOutputBlock -> INFO 002 Generating genesis block
2018-03-04 10:05:14.262 UTC [common/tools/configtxgen] doOutputBlock -> INFO 003 Writing genesis block

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2018-03-04 10:05:14.271 UTC [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-03-04 10:05:14.280 UTC [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-03-04 10:05:14.303 UTC [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
2018-03-04 10:05:14.314 UTC [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-03-04 10:05:14.321 UTC [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-04 10:05:14.322 UTC [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
2018-03-04 10:05:14.331 UTC [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-03-04 10:05:14.337 UTC [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-04 10:05:14.338 UTC [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

6.3 ネットワーク起動(Bring Up the Network)

./byfn.sh -m upでネットワークを起動してみます。StartとEndが表示されれば成功です。

vagrant@vagrant:~/fabric-samples/first-network$ ./byfn.sh -m up
Starting with channel 'mychannel' and CLI timeout of '10'
Continue (y/n)? y
proceeding ...
Creating network "net_byfn" with the default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_orderer.example.com" with default driver
Creating orderer.example.com
Creating peer0.org2.example.com
Creating peer1.org2.example.com
Creating peer0.org1.example.com
Creating peer1.org1.example.com
Creating cli

 ____    _____      _      ____    _____
/ ___|  |_   _|    / \    |  _ \  |_   _|
\___ \    | |     / _ \   | |_) |   | |
 ___) |   | |    / ___ \  |  _ <    | |
|____/    |_|   /_/   \_\ |_| \_\   |_|

Build your first network (BYFN) end-to-end test

Channel name : mychannel
Creating channel...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2018-03-04 10:06:06.719 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-03-04 10:06:06.719 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-03-04 10:06:06.725 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-03-04 10:06:06.725 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-03-04 10:06:06.725 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-03-04 10:06:06.725 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-03-04 10:06:06.725 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-03-04 10:06:06.725 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AA2060A074F7267314D53501296062D...53616D706C65436F6E736F727469756D
2018-03-04 10:06:06.725 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: F24FE259C6F5943C52CCA947C907E21BE6A9E0BD7578B8BA37907817D8383F66
2018-03-04 10:06:06.726 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-03-04 10:06:06.726 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-03-04 10:06:06.726 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-03-04 10:06:06.726 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-03-04 10:06:06.726 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AD9060A1508021A06088E8AEFD40522...0479CFD46DE624B58ECEE22EFB75E9CD
2018-03-04 10:06:06.726 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 8AF3756F05B2BD478678C61818B31D0D7C2BFE34D9425B4D77D34B15FF8D5A3E
2018-03-04 10:06:06.769 UTC [msp] GetLocalMSP -> DEBU 010 Returning existing local MSP
2018-03-04 10:06:06.769 UTC [msp] GetDefaultSigningIdentity -> DEBU 011 Obtaining default signing identity
2018-03-04 10:06:06.769 UTC [msp] GetLocalMSP -> DEBU 012 Returning existing local MSP
2018-03-04 10:06:06.769 UTC [msp] GetDefaultSigningIdentity -> DEBU 013 Obtaining default signing identity
2018-03-04 10:06:06.769 UTC [msp/identity] Sign -> DEBU 014 Sign: plaintext: 0AD9060A1508021A06088E8AEFD40522...AE8C0798124B12080A021A0012021A00
2018-03-04 10:06:06.769 UTC [msp/identity] Sign -> DEBU 015 Sign: digest: 80A92A9E86D2803860523AAAA5F9965BE080474969616525FAA9A207190A134F
2018-03-04 10:06:06.787 UTC [channelCmd] readBlock -> DEBU 016 Received block: 0
2018-03-04 10:06:06.788 UTC [main] main -> INFO 017 Exiting.....
===================== Channel "mychannel" is created successfully =====================

Having all peers join the channel...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2018-03-04 10:06:06.860 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-03-04 10:06:06.860 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-03-04 10:06:06.863 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-03-04 10:06:06.863 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AA0070A5C08011A0C088E8AEFD40510...A50A76048F1D1A080A000A000A000A00
2018-03-04 10:06:06.863 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: C5CDDEFA1DED339DF89F26EDFDD8ABCDC7DB4C910DA4C889F1A11100C661F6DD
2018-03-04 10:06:06.922 UTC [channelCmd] executeJoin -> INFO 006 Successfully submitted proposal to join channel
2018-03-04 10:06:06.922 UTC [main] main -> INFO 007 Exiting.....
===================== PEER0 joined on the channel "mychannel" =====================

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org1.example.com:7051
2018-03-04 10:06:09.971 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-03-04 10:06:09.971 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-03-04 10:06:09.974 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-03-04 10:06:09.975 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0AA0070A5C08011A0C08918AEFD40510...A50A76048F1D1A080A000A000A000A00
2018-03-04 10:06:09.975 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: E433AE5D9040F6756DF8A4B1D167677FE460EFFC106C06ADA912FC7C8B7FBC5C
2018-03-04 10:06:10.025 UTC [channelCmd] executeJoin -> INFO 006 Successfully submitted proposal to join channel
2018-03-04 10:06:10.025 UTC [main] main -> INFO 007 Exiting.....
===================== PEER1 joined on the channel "mychannel" =====================

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
<<中略>>
2018-03-04 10:06:13.137 UTC [channelCmd] executeJoin -> INFO 006 Successfully submitted proposal to join channel
2018-03-04 10:06:13.137 UTC [main] main -> INFO 007 Exiting.....
===================== PEER2 joined on the channel "mychannel" =====================

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
<<中略>>
2018-03-04 10:06:16.266 UTC [channelCmd] executeJoin -> INFO 006 Successfully submitted proposal to join channel
2018-03-04 10:06:16.266 UTC [main] main -> INFO 007 Exiting.....
===================== PEER3 joined on the channel "mychannel" =====================

Updating anchor peers for org1...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
<<中略>>
2018-03-04 10:06:19.350 UTC [channelCmd] update -> INFO 010 Successfully submitted channel update
2018-03-04 10:06:19.350 UTC [main] main -> INFO 011 Exiting.....
===================== Anchor peers for org "Org1MSP" on "mychannel" is updated successfully =====================

Updating anchor peers for org2...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
<<中略>>
2018-03-04 10:06:22.426 UTC [channelCmd] update -> INFO 010 Successfully submitted channel update
2018-03-04 10:06:22.426 UTC [main] main -> INFO 011 Exiting.....
===================== Anchor peers for org "Org2MSP" on "mychannel" is updated successfully =====================

Installing chaincode on org1/peer0...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
<<中略>>
2018-03-04 10:06:26.111 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: F8CFDC6287D373416EB95179DC64D604AD0F0C6769798DDB0F7476D01ABA76BC
2018-03-04 10:06:26.115 UTC [chaincodeCmd] install -> DEBU 010 Installed remotely response:<status:200 payload:"OK" >
2018-03-04 10:06:26.115 UTC [main] main -> INFO 011 Exiting.....
===================== Chaincode is installed on remote peer PEER0 =====================

Install chaincode on org2/peer2...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
<<中略>>
2018-03-04 10:06:26.350 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 9089660023E5DA9DCB629A601141D3E0B1FD0788A0F4D866CB16C784F4E2B1CD
2018-03-04 10:06:26.355 UTC [chaincodeCmd] install -> DEBU 010 Installed remotely response:<status:200 payload:"OK" >
2018-03-04 10:06:26.355 UTC [main] main -> INFO 011 Exiting.....
===================== Chaincode is installed on remote peer PEER2 =====================

Instantiating chaincode on org2/peer2...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
<<中略>>
2018-03-04 10:06:55.596 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 1FD114CF4B088AAA2F3F59D4D50540F7A9535172F503DCB752F44584AE23B978
2018-03-04 10:06:55.631 UTC [main] main -> INFO 00a Exiting.....
===================== Chaincode Instantiation on PEER2 on channel 'mychannel' is successful =====================

Querying chaincode on org1/peer0...
===================== Querying on PEER0 on channel 'mychannel'... =====================
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
<<中略>>
2018-03-04 10:06:58.720 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 1F76226211C07448BAEF72073764A7F15CF5328E97692D78B35EE46E7E837AF9
Query Result: 100
2018-03-04 10:07:23.542 UTC [main] main -> INFO 008 Exiting.....
===================== Query on PEER0 on channel 'mychannel' is successful =====================
Sending invoke transaction on org1/peer0...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
<<中略>>
2018-03-04 10:07:23.683 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200
2018-03-04 10:07:23.683 UTC [main] main -> INFO 00c Exiting.....
===================== Invoke transaction on PEER0 on channel 'mychannel' is successful =====================

Installing chaincode on org2/peer3...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
<<中略>>
2018-03-04 10:07:24.032 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 73FEFBF7D9F5426BC609A83068EECB4D4545D7189D1D3D0217535D10ED29BD3A
2018-03-04 10:07:24.043 UTC [chaincodeCmd] install -> DEBU 010 Installed remotely response:<status:200 payload:"OK" >
2018-03-04 10:07:24.043 UTC [main] main -> INFO 011 Exiting.....
===================== Chaincode is installed on remote peer PEER3 =====================

Querying chaincode on org2/peer3...
===================== Querying on PEER3 on channel 'mychannel'... =====================
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
<<中略>>
2018-03-04 10:07:27.103 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: C80264C159E9F949D3A6A8835B85FD24CC15731934627BA16304C76BD74F4926
Query Result: 90
2018-03-04 10:07:51.745 UTC [main] main -> INFO 008 Exiting.....
===================== Query on PEER3 on channel 'mychannel' is successful =====================

========= All GOOD, BYFN execution completed ===========


 _____   _   _   ____
| ____| | \ | | |  _ \
|  _|   |  \| | | | | |
| |___  | |\  | | |_| |
|_____| |_| \_| |____/

vagrant@vagrant:~/fabric-samples/first-network$

dockerのプロセスをみてみます。fabric-ordererが1つとfabric-peerが4つ起動しています。その他にも3つコンテナが起動していますが、chaincode -peerとなっているのでチェーンコードを実行しているのではないかと思います。

vagrant@vagrant:~/fabric-samples/first-network$ docker ps
CONTAINER ID        IMAGE                                                                                                  COMMAND                  CREATED             STATUS              PORTS                                              NAMES
e5b48a6a8a68        dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab   "chaincode -peer.a..."   4 minutes ago       Up 4 minutes                                                           dev-peer1.org2.example.com-mycc-1.0
ce5d0c7e989e        dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9   "chaincode -peer.a..."   5 minutes ago       Up 5 minutes                                                           dev-peer0.org1.example.com-mycc-1.0
6a0ae7a6cac2        dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b   "chaincode -peer.a..."   5 minutes ago       Up 5 minutes                                                           dev-peer0.org2.example.com-mycc-1.0
75a68232c4b5        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
a597a5de51b0        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com
39f6450dd370        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
88d3fe9067c2        hyperledger/fabric-peer:latest                                                                         "peer node start"        6 minutes ago       Up 6 minutes        0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
2ed2f18ac12f        hyperledger/fabric-orderer:latest                                                                      "orderer"                6 minutes ago       Up 6 minutes        0.0.0.0:7050->7050/tcp                             orderer.example.com

6.4 ネットワーク停止(Bring Down the Network)

./byfn.sh -m downでネットワークを停止してみます。

vagrant@vagrant:~/fabric-samples/first-network$ ./byfn.sh -m down
Stopping with channel 'mychannel' and CLI timeout of '10'
Continue (y/n)? y
proceeding ...
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The DELAY variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
Stopping peer1.org1.example.com ... done
Stopping peer0.org1.example.com ... done
Stopping peer1.org2.example.com ... done
Stopping peer0.org2.example.com ... done
Stopping orderer.example.com ... done
Removing cli ... done
Removing peer1.org1.example.com ... done
Removing peer0.org1.example.com ... done
Removing peer1.org2.example.com ... done
Removing peer0.org2.example.com ... done
Removing orderer.example.com ... done
Removing network net_byfn
Removing volume net_peer0.org2.example.com
Removing volume net_peer1.org2.example.com
Removing volume net_peer1.org1.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_orderer.example.com
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The DELAY variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
Removing network net_byfn
WARNING: Network net_byfn not found.
Removing volume net_peer0.org2.example.com
WARNING: Volume net_peer0.org2.example.com not found.
Removing volume net_peer1.org2.example.com
WARNING: Volume net_peer1.org2.example.com not found.
Removing volume net_peer1.org1.example.com
WARNING: Volume net_peer1.org1.example.com not found.
Removing volume net_peer0.org1.example.com
WARNING: Volume net_peer0.org1.example.com not found.
Removing volume net_orderer.example.com
WARNING: Volume net_orderer.example.com not found.
e5b48a6a8a68
ce5d0c7e989e
6a0ae7a6cac2
Untagged: dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab:latest
Deleted: sha256:bec67c1f276b79252d352460366fe6954d82ef90db20edff5e07a16d221336b0
Deleted: sha256:13dd2cabb38c21a0c106cf5fc75abc81dfe39c367c9671bdc7948156e82ce6d6
Deleted: sha256:61e1631946fbccb4d26a65221da8c043cbc67a3305e450db4a1cf55efb38ea77
Deleted: sha256:92f3247f8bbdbd503d5aa54a0dc2bfb59c7d95efe1ae044986a359de71e8adb7
Untagged: dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9:latest
Deleted: sha256:bfa6e5e249dd314c1c0353ea08e27705f6887289be8de737c8e1fc5a5ed60fb5
Deleted: sha256:589dcd74ec1649c360fb05f33ed0ffd44b0e35eb39c083bad5fc5481f2972d91
Deleted: sha256:feb93b88741188048c357b6a577a89f7fee61aac15b42ced481e7ad7bcfb2b85
Deleted: sha256:caaae45e158fbea0b8cba5be414365c10199ba07176a5dcae4eef98a37a83689
Untagged: dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latest
Deleted: sha256:6c141642c23b8d3d5ba9f052c99e26204b1deeb1ab605bc19e7a6c16b3a24189
Deleted: sha256:fbb2efa199069d6908f549abdfa6e3f370535a497377836843f64ee8e155bc28
Deleted: sha256:a5468401a221afe400b928cff80c2e898984ffa0dab692bbd26cb2fc36fd17ac
Deleted: sha256:fb915c01fbf49a3f28e8588014ed9c171030ebe94a04e9483d509220c4a23434
vagrant@vagrant:~/fabric-samples/first-network$

7. 終わりに

これでHyperledger Fabricが稼働する環境ができました。
最初はWindows10で直接環境を構築しようとしましたが、Home versionで環境構築するには、情報が少なくいろいろと障害にぶつかったのでUbuntu on VirtualBoxを使うことにしました。
次回はGO、Node.js、Javaいずれかでトランザクションを発生させてみたいと思います。

※続きはこちらから。

参考URL

http://hyperledger-fabric.readthedocs.io/
https://www.hyperledger.org/projects/fabric
Hyperledger Fabric 1.0 概要
https://chainhero.io/2017/07/tutorial-build-blockchain-app/

5
3
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
5
3