Hyperledger Fabric 1.0 环境搭建

区块链

一.安装GO语言

下载最新版的go

wget https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz

编辑当前用户的环境变量

vi /etc/profile

添加以下内容

export PATH=$PATH:/usr/local/go/bin 

export GOROOT=/usr/local/go 

export GOPATH=$HOME/go 

export PATH=$PATH:$HOME/go/bin

编辑保存并退出vi后,记得使这些环境变量生效

source /etc/profile

把go的目录GOPATH设置为当前用户的文件夹下,所以记得创建go文件夹

cd ~

mkdir go

二.安装Docker

使用官方提供的脚本来安装docker

curl -sSl https://get.docker.com/ | sh

安装成功后启动docker服务:

service docker start

三.安装Docker-compose

Docker-compose是支持通过模板脚本批量创建Docker容器的一个组件。在安装Docker-Compose之前,需要安装Python-pip,运行脚本:

 yum  -y install python-pip

然后是安装docker-compose,我们从官方网站(https://github.com/docker/compose/releases)下载也可以从国内的进行DaoClound下载,为了速度快接下来从DaoClound安装Docker-compose,运行脚本:

curl -L https://get.daocloud.io/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose

mv ~/docker-compose /usr/local/bin/docker-compose 

chmod +x /usr/local/bin/docker-compose

四.Fabric源码下载

可以用go get命令下载源码

go get github.com/hyperledger/fabric

如果下载失败也可以使用git命令下载源码

mkdir -p ~/go/src/github.com/hyperledger 

cd ~/go/src/github.com/hyperledger 

git clone https://github.com/hyperledger/fabric.git

由于Fabric一直在更新,所有我们并不需要最新最新的源码,需要切换到v1.0.0版本的源码即可:

cd ~/go/src/github.com/hyperledger/fabric

git checkout v1.0.0

五.下载Fabric镜像

官方文件提供了批量下载的脚本。我们直接运行:

cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/

source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0

所有会用到的Fabric docker镜像都会下载下来了。

下载完毕后,我们运行以下命令检查下载的镜像列表:

docker images

REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
hyperledger/fabric-tools       latest              0403fd1c72c7        16 months ago       1.32GB
hyperledger/fabric-tools       x86_64-1.0.0        0403fd1c72c7        16 months ago       1.32GB
hyperledger/fabric-kafka       latest              dbd3f94de4b5        16 months ago       1.3GB
hyperledger/fabric-kafka       x86_64-1.0.0        dbd3f94de4b5        16 months ago       1.3GB
hyperledger/fabric-zookeeper   latest              e545dbf1c6af        16 months ago       1.31GB
hyperledger/fabric-zookeeper   x86_64-1.0.0        e545dbf1c6af        16 months ago       1.31GB
hyperledger/fabric-orderer     latest              e317ca5638ba        16 months ago       179MB
hyperledger/fabric-orderer     x86_64-1.0.0        e317ca5638ba        16 months ago       179MB
hyperledger/fabric-peer        latest              6830dcd7b9b5        16 months ago       182MB
hyperledger/fabric-peer        x86_64-1.0.0        6830dcd7b9b5        16 months ago       182MB
hyperledger/fabric-javaenv     latest              8948126f0935        16 months ago       1.42GB
hyperledger/fabric-javaenv     x86_64-1.0.0        8948126f0935        16 months ago       1.42GB
hyperledger/fabric-ccenv       latest              7182c260a5ca        16 months ago       1.29GB
hyperledger/fabric-ccenv       x86_64-1.0.0        7182c260a5ca        16 months ago       1.29GB
hyperledger/fabric-ca          latest              a15c59ecda5b        16 months ago       238MB
hyperledger/fabric-ca          x86_64-1.0.0        a15c59ecda5b        16 months ago       238MB

六、启动Fabric网络并完成ChainCode的测试

在e2e_cli文件夹,这里提供了启动、关闭Fabric网络的自动化脚本。我们要启动Fabric网络,并自动运行Example02 ChainCode的测试,执行一个命令:

bash network_setup.sh up

这个做了以下操作:

6.1编译生成Fabric公私钥、证书的程序,程序在目录:fabric/release/linux-amd64/bin

6.2基于configtx.yaml生成创世区块和通道相关信息,并保存在channel-artifacts文件夹。

6.3基于crypto-config.yaml生成公私钥和证书信息,并保存在crypto-config文件夹中。

6.4基于docker-compose-cli.yaml启动1Orderer+4Peer+1CLI的Fabric容器。

6.5在CLI启动的时候,会运行scripts/script.sh文件,这个脚本文件包含了创建Channel,加入Channel,安装Example02,运行Example02等功能。

setting to default channel 'mychannel'
mychannel

Building cryptogen
make: Entering directory `/root/go/src/github.com/hyperledger/fabric'
Building release/linux-amd64/bin/configtxgen for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxgen -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/configtx/tool/configtxgen/metadata.Version=1.0.0" github.com/hyperledger/fabric/common/configtx/tool/configtxgen
Building release/linux-amd64/bin/cryptogen for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/cryptogen -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/tools/cryptogen/metadata.Version=1.0.0" github.com/hyperledger/fabric/common/tools/cryptogen
Building release/linux-amd64/bin/configtxlator for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxlator -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/tools/configtxlator/metadata.Version=1.0.0" github.com/hyperledger/fabric/common/tools/configtxlator
Building release/linux-amd64/bin/peer for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/peer -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.0 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.1 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/peer
Building release/linux-amd64/bin/orderer for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/orderer -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/orderer/metadata.Version=1.0.0" github.com/hyperledger/fabric/orderer
mkdir -p release/linux-amd64/bin
make: Leaving directory `/root/go/src/github.com/hyperledger/fabric'

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

Using configtxgen -> /root/go/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
2018-11-08 00:58:43.242 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-11-08 00:58:43.269 CST [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block
2018-11-08 00:58:43.271 CST [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2018-11-08 00:58:46.465 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-11-08 00:58:46.469 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-11-08 00:58:46.469 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
2018-11-08 00:58:46.814 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-11-08 00:58:46.818 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-11-08 00:58:46.818 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
2018-11-08 00:58:46.882 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-11-08 00:58:46.886 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-11-08 00:58:46.887 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

Creating network "e2ecli_default" with the default driver
Creating peer0.org1.example.com
Creating peer1.org2.example.com
Creating peer0.org2.example.com
Creating peer1.org1.example.com
Creating orderer.example.com
Creating cli

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

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-11-07 16:58:57.891 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:58:57.891 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:58:57.955 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-07 16:58:57.955 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-11-07 16:58:57.955 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-11-07 16:58:57.955 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-11-07 16:58:57.955 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-11-07 16:58:57.955 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267314D53501280062D...53616D706C65436F6E736F727469756D 
2018-11-07 16:58:57.955 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: C1C7424D580A6AFC8F7D1C8738F757ADAF419D75DAC35E05892A7AFF8A40389A 
2018-11-07 16:58:57.955 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-11-07 16:58:57.955 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-11-07 16:58:57.955 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-11-07 16:58:57.956 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-11-07 16:58:57.956 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A0608D1B38CDF0522...94FDA0CB9F6D8BD1C75D36C0B7AEAD2A 
2018-11-07 16:58:57.956 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: AE4AADE096E392EA356584CF83E6768F4E303AB9F45E41BFD12DB802DDEEAFF7 
2018-11-07 16:58:58.422 UTC [msp] GetLocalMSP -> DEBU 010 Returning existing local MSP
2018-11-07 16:58:58.422 UTC [msp] GetDefaultSigningIdentity -> DEBU 011 Obtaining default signing identity
2018-11-07 16:58:58.422 UTC [msp] GetLocalMSP -> DEBU 012 Returning existing local MSP
2018-11-07 16:58:58.422 UTC [msp] GetDefaultSigningIdentity -> DEBU 013 Obtaining default signing identity
2018-11-07 16:58:58.422 UTC [msp/identity] Sign -> DEBU 014 Sign: plaintext: 0AC3060A1508021A0608D2B38CDF0522...772C7E1FA83812080A021A0012021A00 
2018-11-07 16:58:58.422 UTC [msp/identity] Sign -> DEBU 015 Sign: digest: B0993B80DD1A6808E711E23841E3FB0ED7D9DAEDC5ED9FEFE165FE3A2DA105DC 
2018-11-07 16:58:58.425 UTC [channelCmd] readBlock -> DEBU 016 Got status:*orderer.DeliverResponse_Status 
2018-11-07 16:58:58.425 UTC [msp] GetLocalMSP -> DEBU 017 Returning existing local MSP
2018-11-07 16:58:58.425 UTC [msp] GetDefaultSigningIdentity -> DEBU 018 Obtaining default signing identity
2018-11-07 16:58:58.523 UTC [channelCmd] InitCmdFactory -> INFO 019 Endorser and orderer connections initialized
2018-11-07 16:58:58.753 UTC [msp] GetLocalMSP -> DEBU 01a Returning existing local MSP
2018-11-07 16:58:58.753 UTC [msp] GetDefaultSigningIdentity -> DEBU 01b Obtaining default signing identity
2018-11-07 16:58:58.753 UTC [msp] GetLocalMSP -> DEBU 01c Returning existing local MSP
2018-11-07 16:58:58.753 UTC [msp] GetDefaultSigningIdentity -> DEBU 01d Obtaining default signing identity
2018-11-07 16:58:58.753 UTC [msp/identity] Sign -> DEBU 01e Sign: plaintext: 0AC3060A1508021A0608D2B38CDF0522...6CA58B7E6B5012080A021A0012021A00 
2018-11-07 16:58:58.753 UTC [msp/identity] Sign -> DEBU 01f Sign: digest: 388C0251450BF7E79A2B547B41D01A6AB61C60EE3E5D794093D66EE1881FCB30 
2018-11-07 16:58:58.793 UTC [channelCmd] readBlock -> DEBU 020 Got status:*orderer.DeliverResponse_Status 
2018-11-07 16:58:58.793 UTC [msp] GetLocalMSP -> DEBU 021 Returning existing local MSP
2018-11-07 16:58:58.793 UTC [msp] GetDefaultSigningIdentity -> DEBU 022 Obtaining default signing identity
2018-11-07 16:58:58.836 UTC [channelCmd] InitCmdFactory -> INFO 023 Endorser and orderer connections initialized
2018-11-07 16:58:59.042 UTC [msp] GetLocalMSP -> DEBU 024 Returning existing local MSP
2018-11-07 16:58:59.042 UTC [msp] GetDefaultSigningIdentity -> DEBU 025 Obtaining default signing identity
2018-11-07 16:58:59.042 UTC [msp] GetLocalMSP -> DEBU 026 Returning existing local MSP
2018-11-07 16:58:59.042 UTC [msp] GetDefaultSigningIdentity -> DEBU 027 Obtaining default signing identity
2018-11-07 16:58:59.042 UTC [msp/identity] Sign -> DEBU 028 Sign: plaintext: 0AC3060A1508021A0608D3B38CDF0522...D3456D76FB2C12080A021A0012021A00 
2018-11-07 16:58:59.042 UTC [msp/identity] Sign -> DEBU 029 Sign: digest: AC478D6714869E55CC40FFFD3754578A0C7B40609EB783ABE89D980D76367C81 
2018-11-07 16:58:59.044 UTC [channelCmd] readBlock -> DEBU 02a Got status:*orderer.DeliverResponse_Status 
2018-11-07 16:58:59.044 UTC [msp] GetLocalMSP -> DEBU 02b Returning existing local MSP
2018-11-07 16:58:59.044 UTC [msp] GetDefaultSigningIdentity -> DEBU 02c Obtaining default signing identity
2018-11-07 16:58:59.061 UTC [channelCmd] InitCmdFactory -> INFO 02d Endorser and orderer connections initialized
2018-11-07 16:58:59.271 UTC [msp] GetLocalMSP -> DEBU 02e Returning existing local MSP
2018-11-07 16:58:59.271 UTC [msp] GetDefaultSigningIdentity -> DEBU 02f Obtaining default signing identity
2018-11-07 16:58:59.271 UTC [msp] GetLocalMSP -> DEBU 030 Returning existing local MSP
2018-11-07 16:58:59.271 UTC [msp] GetDefaultSigningIdentity -> DEBU 031 Obtaining default signing identity
2018-11-07 16:58:59.271 UTC [msp/identity] Sign -> DEBU 032 Sign: plaintext: 0AC3060A1508021A0608D3B38CDF0522...78B2520C619612080A021A0012021A00 
2018-11-07 16:58:59.271 UTC [msp/identity] Sign -> DEBU 033 Sign: digest: 2C9994D54AEE913C90F1DB0C3EB7ACAC14C9176B39977758B37BF0AE953B915A 
2018-11-07 16:58:59.274 UTC [channelCmd] readBlock -> DEBU 034 Received block:0 
2018-11-07 16:58:59.274 UTC [main] main -> INFO 035 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-11-07 16:58:59.610 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:58:59.611 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:58:59.655 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-07 16:58:59.655 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A8A070A5C08011A0C08D3B38CDF0510...4A5A77EA43DC1A080A000A000A000A00 
2018-11-07 16:58:59.655 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 261FBBBF7723859AFC5201B108581AE0005D9A9E2D536C100FF6918983B35614 
2018-11-07 16:58:59.888 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-11-07 16:58:59.888 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-11-07 16:59:02.334 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:02.334 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:02.377 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-07 16:59:02.378 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A8A070A5C08011A0C08D6B38CDF0510...4A5A77EA43DC1A080A000A000A000A00 
2018-11-07 16:59:02.378 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 741C3E2C3CB7BA6F747C85DE0273EE2D6A7FD61CD32F37E9CC81AC53091071BF 
2018-11-07 16:59:02.636 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-11-07 16:59:02.636 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
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/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-11-07 16:59:05.024 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:05.024 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:05.059 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-07 16:59:05.060 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A85070A5B08011A0B08D9B38CDF0510...4A5A77EA43DC1A080A000A000A000A00 
2018-11-07 16:59:05.060 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 2796E8A30841D4E66C20128F1D29F67B225B5D083A417BF777761247C97E637C 
2018-11-07 16:59:05.263 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-11-07 16:59:05.263 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
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/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
2018-11-07 16:59:07.773 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:07.773 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:07.798 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-07 16:59:07.798 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A86070A5C08011A0C08DBB38CDF0510...4A5A77EA43DC1A080A000A000A000A00 
2018-11-07 16:59:07.798 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 89D681801BC103EF85A716311F353AD6ABCDECA5485E59DF0F95BAC7F264EDDA 
2018-11-07 16:59:08.080 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-11-07 16:59:08.080 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
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-11-07 16:59:10.509 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:10.509 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:10.556 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-07 16:59:10.557 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-11-07 16:59:10.557 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-11-07 16:59:10.557 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-11-07 16:59:10.557 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-11-07 16:59:10.557 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267314D53501280062D...72731200220A0A0641646D696E731200 
2018-11-07 16:59:10.557 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: A985934A2673A45EF097D7D8D6676495AB5D6D370855A90D1FF7CCCE8A992668 
2018-11-07 16:59:10.557 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-11-07 16:59:10.557 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-11-07 16:59:10.557 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-11-07 16:59:10.557 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-11-07 16:59:10.557 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A0608DEB38CDF0522...DCE696CA63649ED2522FAF9E1DB9EB9F 
2018-11-07 16:59:10.557 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 53650FB95AD17F2BEA50C08441922428295D9DAA08CF1FA7B52CBCB4EAB1C48F 
2018-11-07 16:59:10.759 UTC [main] main -> INFO 010 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
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
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/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-11-07 16:59:16.254 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:16.254 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:16.286 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-07 16:59:16.286 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-11-07 16:59:16.286 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-11-07 16:59:16.286 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-11-07 16:59:16.286 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-11-07 16:59:16.286 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A88060A074F7267324D535012FC052D...72731200220A0A0641646D696E731200 
2018-11-07 16:59:16.286 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 7ABD52C43988026D44ED409A99224941399258654BD4347A5DB8B1EB7B411F88 
2018-11-07 16:59:16.286 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-11-07 16:59:16.286 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-11-07 16:59:16.286 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-11-07 16:59:16.286 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-11-07 16:59:16.286 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0ABF060A1508021A0608E4B38CDF0522...7EA1813B3F9735F55EC81375757234D4 
2018-11-07 16:59:16.286 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: E748A3FCE8CC5537680EFEA1A3E2F942CAB2FB19F01E9D1DD1DD991E58216594 
2018-11-07 16:59:16.474 UTC [main] main -> INFO 010 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
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-11-07 16:59:21.924 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:21.924 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:21.924 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 16:59:21.924 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 16:59:22.607 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-11-07 16:59:24.462 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2018-11-07 16:59:24.462 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-11-07 16:59:24.462 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-11-07 16:59:24.462 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2018-11-07 16:59:24.462 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2018-11-07 16:59:24.478 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A8A070A5C08031A0C08ECB38CDF0510...5F74FD270000FFFFCEF44F9B002C0000 
2018-11-07 16:59:24.478 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 95E6A9BAB7F77361839177D8B6428C70C280FE756028395A1DA46C168EBBF063 
2018-11-07 16:59:24.609 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" > 
2018-11-07 16:59:24.609 UTC [main] main -> INFO 00e 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
CORE_PEER_LOCALMSPID=Org2MSP
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/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-11-07 16:59:25.097 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:25.097 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:25.097 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 16:59:25.097 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 16:59:25.840 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-11-07 16:59:27.644 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2018-11-07 16:59:27.644 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-11-07 16:59:27.644 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-11-07 16:59:27.644 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2018-11-07 16:59:27.644 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2018-11-07 16:59:27.657 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A86070A5C08031A0C08EFB38CDF0510...5F74FD270000FFFFCEF44F9B002C0000 
2018-11-07 16:59:27.657 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 6576FF33CD40FCA58DE33BAEBFD863FF78322F2E50CB7CE7780776C2F7479AB0 
2018-11-07 16:59:27.707 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" > 
2018-11-07 16:59:27.707 UTC [main] main -> INFO 00e 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
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
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/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
2018-11-07 16:59:28.285 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 16:59:28.285 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 16:59:28.327 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 16:59:28.327 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 16:59:28.327 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A91070A6708031A0C08F0B38CDF0510...324D53500A04657363630A0476736363 
2018-11-07 16:59:28.327 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 2D4C633CB789867CDBA9A8BBB4B5AEB05490DFEF5DEFB210C54C5BD68AE9A39B 
2018-11-07 17:01:53.754 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0A91070A6708031A0C08F0B38CDF0510...E495107A0650DE243E0867FF3984F3CC 
2018-11-07 17:01:53.754 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: 218D9B8E57ADE36258233EECBA35114D4C930283FB7CB16C49B4281FA84AA983 
2018-11-07 17:01:53.921 UTC [main] main -> INFO 009 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
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
Attempting to Query PEER0 ...4 secs

2018-11-07 17:01:57.672 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 17:01:57.672 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 17:01:57.672 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 17:01:57.672 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 17:01:57.672 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C0885B58CDF0510...6D7963631A0A0A0571756572790A0161 
2018-11-07 17:01:57.672 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 765CF60BC842186D5C285D43B7BF2CAC9C265C30C828AC7F7D0E93AAADBDB6E7 
Query Result: 100
2018-11-07 17:04:12.168 UTC [main] main -> INFO 007 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
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-11-07 17:04:12.634 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 17:04:12.634 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 17:04:12.657 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 17:04:12.657 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 17:04:12.657 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C088CB68CDF0510...696E766F6B650A01610A01620A023130 
2018-11-07 17:04:12.657 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: FA538E15FD8BBC9A0EDA044B5B7E0BCA38794C72C50668DAFFA8DD9F3BD20BB6 
2018-11-07 17:04:12.675 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0A95070A6708031A0C088CB68CDF0510...56A8C6BEFB0A0959F3300CB3677508E3 
2018-11-07 17:04:12.675 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: F128724C58C8118B7A588CD2BEAC6C984E272A788E06C20D9F6FA0C0DAAB9C58 
2018-11-07 17:04:12.711 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 009 ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \341\017\023Q\355\255\030\300\316\250\200\002\253I\274\267\027\337\302\020\035\200\t\016\025@\276\324s\001[=\022Y\nE\022\024\n\004lscc\022\014\n\n\n\004mycc\022\002\010\003\022-\n\004mycc\022%\n\007\n\001a\022\002\010\003\n\007\n\001b\022\002\010\003\032\007\n\001a\032\00290\032\010\n\001b\032\003210\032\003\010\310\001\"\013\022\004mycc\032\0031.0" endorsement:<endorser:"\n\007Org1MSP\022\374\005-----BEGIN -----\nMIICGDCCAb+gAwIBAgIQcIaMdoELpMZzXm+vpL+eITAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0xODExMDcxNjU4NDJaFw0yODExMDQxNjU4NDJa\nMFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMR8wHQYDVQQDExZwZWVyMC5vcmcxLmV4YW1wbGUuY29tMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEsYgHXBgebTR4JkHxIEsRH4E8j15TemTh\nZsP/mCtaGVlChMjlLMff280bAGxbcdGHJdBJqeTIqtvY08h1erQVcqNNMEswDgYD\nVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgFqj/Ozo15BZX\nkdVZqDIoi1cYb3BQnOo8jMSjpLMU2zAwCgYIKoZIzj0EAwIDRwAwRAIgUK3UqaWc\nu+fB8tUiZpkh8cgtHlsFwGtxn29GMbkofnsCIHxN6+npX3ZgNHrqXQF5Ywxl1GaI\nvdUwambR+FmEjn/w\n-----END -----\n" signature:"0D\002 YX\374\n1\035^#\214\342\241\345G\246\005\302\230\347?\200\212s\343\212\373\013\020-\370\324\034\024\002 w\374fl\243\362\245\304\243\250\240Z\345\217\204uV\250\306\276\373\n\tY\3630\014\263gu\010\343" > 
2018-11-07 17:04:12.711 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00a Chaincode invoke successful. result: status:200 
2018-11-07 17:04:12.711 UTC [main] main -> INFO 00b 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
CORE_PEER_LOCALMSPID=Org2MSP
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/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
2018-11-07 17:04:13.480 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 17:04:13.480 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 17:04:13.480 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 17:04:13.480 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 17:04:14.256 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-11-07 17:04:16.253 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2018-11-07 17:04:16.253 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-11-07 17:04:16.253 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-11-07 17:04:16.253 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2018-11-07 17:04:16.253 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2018-11-07 17:04:16.277 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A86070A5C08031A0C0890B68CDF0510...5F74FD270000FFFFCEF44F9B002C0000 
2018-11-07 17:04:16.277 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: B0FFAFE749CE4FAC2BF08C18EA54FC5D689A3FEEF1A2F9777832909BCBC4B6C4 
2018-11-07 17:04:16.390 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" > 
2018-11-07 17:04:16.390 UTC [main] main -> INFO 00e 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
CORE_PEER_LOCALMSPID=Org2MSP
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/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
Attempting to Query PEER3 ...3 secs

2018-11-07 17:04:20.094 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 17:04:20.094 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 17:04:20.094 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 17:04:20.094 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 17:04:20.095 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A90070A6608031A0B0894B68CDF0510...6D7963631A0A0A0571756572790A0161 
2018-11-07 17:04:20.095 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: A923057C3B6E48D67E5DB6A58C48B4F58EC69B7C9918D2B872005AAAFB80D97F 
Query Result: 90
2018-11-07 17:06:35.308 UTC [main] main -> INFO 007 Exiting.....
===================== Query on PEER3 on channel 'mychannel' is successful ===================== 

===================== All GOOD, End-2-End execution completed ===================== 


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

七.手动测试一下Fabric网络

我们仍然是以现在安装好的Example02为例,在官方例子中,channel名字是mychannel,链码的名字是mycc。我们首先进入CLI,我们重新打开一个命令行窗口,输入:

docker exec -it cli bash

[root@localhost e2e_cli]# docker exec -it cli bash
root@ad82f597cd88:/opt/gopath/src/github.com/hyperledger/fabric/peer#

运行以下命令可以查询a账户的余额,可以看到余额是90。

root@ad82f597cd88:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
2018-11-07 17:16:32.339 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 17:16:32.339 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 17:16:32.339 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 17:16:32.339 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 17:16:32.339 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C08F0BB8CDF0510...6D7963631A0A0A0571756572790A0161 
2018-11-07 17:16:32.339 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 6D6F1F4D3D1616FA94101D0C8B1839570EC9F6ADE53C786FEFA95FE9B1F894EF 
Query Result: 90
2018-11-07 17:16:32.360 UTC [main] main -> INFO 007 Exiting.....

试一试把a账户的余额再转20元给b账户,运行命令:

peer chaincode invoke -o orderer.example.com:7050  –tls true –cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem  -C mychannel -n mycc -c '{"Args":["invoke","a","b","20"]}'

root@ad82f597cd88:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode invoke -o orderer.example.com:7050  --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem  -C mychannel -n mycc -c '{"Args":["invoke","a","b","20"]}'
2018-11-07 17:25:03.003 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-07 17:25:03.003 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-07 17:25:03.016 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-07 17:25:03.016 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-07 17:25:03.016 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A94070A6608031A0B08EFBF8CDF0510...696E766F6B650A01610A01620A023230 
2018-11-07 17:25:03.016 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 379F72A98ED1F6CA511C2133B4B1E4AC0A5106409119A4A9F9F123E4E153A341 
2018-11-07 17:25:03.028 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0A94070A6608031A0B08EFBF8CDF0510...495E008A2C27ACEF39C6B8DE5684895F 
2018-11-07 17:25:03.039 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: 119403C7C59C6385ECA65549AA4C28832C4133217F40DECF28D1E19CE1C6243E 
2018-11-07 17:25:03.065 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 009 ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \306A\341p\354\231\315\231\355\022\245e\335q\334\3518\351\030\276\212@\317~\312\213\te\027\322\344p\022Y\nE\022\024\n\004lscc\022\014\n\n\n\004mycc\022\002\010\003\022-\n\004mycc\022%\n\007\n\001a\022\002\010\004\n\007\n\001b\022\002\010\004\032\007\n\001a\032\00270\032\010\n\001b\032\003230\032\003\010\310\001\"\013\022\004mycc\032\0031.0" endorsement:<endorser:"\n\007Org1MSP\022\374\005-----BEGIN -----\nMIICGDCCAb+gAwIBAgIQcIaMdoELpMZzXm+vpL+eITAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0xODExMDcxNjU4NDJaFw0yODExMDQxNjU4NDJa\nMFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMR8wHQYDVQQDExZwZWVyMC5vcmcxLmV4YW1wbGUuY29tMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEsYgHXBgebTR4JkHxIEsRH4E8j15TemTh\nZsP/mCtaGVlChMjlLMff280bAGxbcdGHJdBJqeTIqtvY08h1erQVcqNNMEswDgYD\nVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgFqj/Ozo15BZX\nkdVZqDIoi1cYb3BQnOo8jMSjpLMU2zAwCgYIKoZIzj0EAwIDRwAwRAIgUK3UqaWc\nu+fB8tUiZpkh8cgtHlsFwGtxn29GMbkofnsCIHxN6+npX3ZgNHrqXQF5Ywxl1GaI\nvdUwambR+FmEjn/w\n-----END -----\n" signature:"0E\002!\000\235\207\351hYk\255\364h\317\323\215\373\224_4\230\372]\360\251+@\001\316\347\317\006\300\001\030\301\002 P \376+\207\337\021\177.\344\316\242* \0164I^\000\212,'\254\3579\306\270\336V\204\211_" > 
2018-11-07 17:25:03.065 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00a Chaincode invoke successful. result: status:200

一切正常。最后我们要关闭Fabric网络,首先需要运行exit命令退出cli容器。关闭Fabric的命令与启动类似,命令为:

cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli

./network_setup.sh down

现在我们整个Fabric的环境已经测试完毕,恭喜,一切正常,接下来我们就是去做自己的区块链的开发。

发表评论