Fabric開發(二) Ubuntu20.04.1快速搭建Fabric1.0.0 (排雷版)

2020-09-25 12:00:53

一、安裝Fabric前準備:

1、安裝ubuntu,建議virtualBox+ubuntu映象。

我所使用的版本:

1、virtualBox 5.2.20
#ubuntu桌面版,方便某些操作,例如修改源。(建議安裝英文版)
2、ubuntu-20.04.1-desktop-amd64.iso 

virtual版本
安裝注意點:

1、記憶體: 2048M
2、CPU: 2
3、磁碟: 位置放在D槽,大小50G。 fabric 安裝完需要10G
4、網路模式: 橋接

1、記憶體 視訊記憶體 儲存修改
在這裡插入圖片描述
在這裡插入圖片描述
2、網路修改
在這裡插入圖片描述
3、安裝完成後,九宮格找到Software&Update,修改源。
在這裡插入圖片描述

2、xshell6 連線 可以網站直接申請學校版本

1.採用xshell 進行操作,方便複製

sudo apt-get install openssh-server
ps -e|grep ssh

2.檢視ip

sudo apt install net-tools
ifconfig

檢視ip也可以直接點選 九宮格找到Setting ->Network
在這裡插入圖片描述
3.進行xshell連線

3、安裝 vim、git、curl、pip、npm

此處注意:python-pip安裝會報找不到,所以改為python3-pip

sudo apt-get update
sudo apt-get install vim
sudo apt-get install git
sudo apt-get install curl
sudo apt-get install python3-pip
pip3 install --upgrade pip
sudo apt-get install npm

4、安裝go

安裝版本:1.14.4

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

家目錄建立go資料夾

cd ~
mkdir go

編輯當前使用者的環境變數.(:x可以直接返回儲存。)

vim ~/.profile

末尾追加:

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

環境變數立即生效

source ~/.profile

檢驗go是否安裝成功(成功顯示go version go1.14.4 linux/amd64

go version

5、安裝Docker

1.解除安裝舊版本docker

sudo apt-get remove docker docker-engine docker.io

2.更新系統軟體

sudo apt-get update

3.安裝依賴包

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

4.新增官方金鑰

執行該命令時,如遇到長時間沒有響應說明網路連線不到docker網站,需要使用代-理進行。
顯示OK,表示新增成功.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

5.新增倉庫

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

6.修改倉庫源(如果要設定專屬阿里雲,自己先百度下哈)

sudo vim /etc/docker/daemon.json

填寫以下內容

{
    "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

重置docker服務

systemctl restart docker.service

7.再次更新軟體

sudo apt-get update

8.安裝docker

如果想指定安裝某一版本,可使用 sudo apt-get install docker-ce= 命令,把替換為具體版本即可。
以下命令沒有指定版本,預設就會安裝最新版

sudo apt-get install docker-ce

9.檢視docker版本

docker -v

10.安裝完成後需要修改當前使用者(我使用的使用者叫halfape)許可權:

sudo gpasswd -a halfape docker #正在將使用者「halfape」加入到「docker」組中
newgrp docker #更新使用者組

6、安裝docker-compose

1.下載docker-compose

sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

2.授權

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

3.檢視版本資訊

docker-compose --version

二、安裝Fabric

1、下載 Fabric原始碼

我們可以使用Git命令下載原始碼,首先需要建立對應的目錄,然後進入該目錄,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版本的原始碼即可:(這個下載過程比較慢,目前看到一種從gitee下載的方法 我沒有試)

cd ~/go/src/github.com/hyperledger/fabric
git checkout v1.0.0

2、Fabric Docker映象的下載

因為我們已經設定了Docker Hub映象地址,所以下載也會很快。官方檔案也提供了批次下載的指令碼。我們直接執行:

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

![在這裡插入圖片描述](https://img-blog.csdnimg.cn/20200924135347468.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Fpd2FzdG9u,size_16,color_FFFFFF,t_70#pic_center
可以看出,檔案還是蠻大的。
至此,下載 fabric 原始碼、fabric 映象的工作已經完成。

三、Fabric簡單偵錯

1、啟動Fabric網路並完成ChainCode的測試

我們仍然停留在e2e_cli資料夾,這裡提供了啟動、關閉Fabric網路的自動化指令碼。我們要啟動Fabric網路,並自動執行Example02 ChainCode的測試,執行一個命令:

./network_setup.sh up
1.1編譯生成Fabric公私鑰、證書的程式,程式在目錄:fabric/release/linux-amd64/bin
1.2基於configtx.yaml生成創世區塊和通道相關資訊,並儲存在channel-artifacts資料夾。
1.3基於crypto-config.yaml生成公私鑰和證書資訊,並儲存在crypto-config資料夾中。
1.4基於docker-compose-cli.yaml啟動1Orderer+4Peer+1CLI的Fabric容器。
1.5在CLI啟動的時候,會執行scripts/script.sh檔案,這個指令碼檔案包含了建立Channel,加入Channel,安裝Example02,執行Example02等功能。

最後執行完畢,我們可以看到這樣的介面:
在這裡插入圖片描述
看到這裡 恭喜你,說明我們整個Fabric網路已經OK了。

記錄下具體過程,以便於後續研究。

halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/examples/e2e_cli$ ./network_setup.sh up
setting to default channel 'mychannel'
mychannel

Building cryptogen
make: Entering directory '/home/halfape/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 /home/halfape/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 /home/halfape/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 /home/halfape/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 /home/halfape/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 /home/halfape/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 '/home/halfape/go/src/github.com/hyperledger/fabric'

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

Using configtxgen -> /home/halfape/go/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
2020-09-24 14:03:21.695 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2020-09-24 14:03:21.712 CST [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block
2020-09-24 14:03:21.714 CST [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2020-09-24 14:03:21.756 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2020-09-24 14:03:21.760 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2020-09-24 14:03:21.761 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
2020-09-24 14:03:21.793 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2020-09-24 14:03:21.798 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2020-09-24 14:03:21.798 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
2020-09-24 14:03:21.835 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2020-09-24 14:03:21.839 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2020-09-24 14:03:21.840 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.org1.example.com ... 
Creating peer1.org2.example.com ... 
Creating orderer.example.com ... 
Creating peer0.org1.example.com
Creating peer0.org2.example.com ... 
Creating peer1.org1.example.com
Creating orderer.example.com
Creating peer0.org2.example.com
Creating orderer.example.com ... done
Creating cli ... 
Creating cli ... done

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

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
2020-09-24 06:03:35.240 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:35.240 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:35.244 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 06:03:35.244 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2020-09-24 06:03:35.244 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2020-09-24 06:03:35.244 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2020-09-24 06:03:35.244 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2020-09-24 06:03:35.244 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A88060A074F7267314D535012FC052D...53616D706C65436F6E736F727469756D 
2020-09-24 06:03:35.244 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 13F31E852E3702746BDF69BB4E8101889C7FF20CCB0A369CB048D4F2366435B0 
2020-09-24 06:03:35.244 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2020-09-24 06:03:35.244 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2020-09-24 06:03:35.244 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2020-09-24 06:03:35.244 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2020-09-24 06:03:35.244 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0ABF060A1508021A0608B7EDB0FB0522...959D6EC845FCE532A9A3ADDAD6C1AD31 
2020-09-24 06:03:35.244 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: AE949BCE386EAABE88210C5FB64D2C525F9E74B8D8CF1554F4B806FA576574C1 
2020-09-24 06:03:35.493 UTC [msp] GetLocalMSP -> DEBU 010 Returning existing local MSP
2020-09-24 06:03:35.493 UTC [msp] GetDefaultSigningIdentity -> DEBU 011 Obtaining default signing identity
2020-09-24 06:03:35.493 UTC [msp] GetLocalMSP -> DEBU 012 Returning existing local MSP
2020-09-24 06:03:35.493 UTC [msp] GetDefaultSigningIdentity -> DEBU 013 Obtaining default signing identity
2020-09-24 06:03:35.493 UTC [msp/identity] Sign -> DEBU 014 Sign: plaintext: 0ABF060A1508021A0608B7EDB0FB0522...825BD6FDF69112080A021A0012021A00 
2020-09-24 06:03:35.493 UTC [msp/identity] Sign -> DEBU 015 Sign: digest: 8378ACEDEF10F25823178B4C1ECB0EA5C0157422A9EE3B2241623F02FC25C523 
2020-09-24 06:03:35.494 UTC [channelCmd] readBlock -> DEBU 016 Got status:*orderer.DeliverResponse_Status 
2020-09-24 06:03:35.494 UTC [msp] GetLocalMSP -> DEBU 017 Returning existing local MSP
2020-09-24 06:03:35.494 UTC [msp] GetDefaultSigningIdentity -> DEBU 018 Obtaining default signing identity
2020-09-24 06:03:35.496 UTC [channelCmd] InitCmdFactory -> INFO 019 Endorser and orderer connections initialized
2020-09-24 06:03:35.698 UTC [msp] GetLocalMSP -> DEBU 01a Returning existing local MSP
2020-09-24 06:03:35.698 UTC [msp] GetDefaultSigningIdentity -> DEBU 01b Obtaining default signing identity
2020-09-24 06:03:35.702 UTC [msp] GetLocalMSP -> DEBU 01c Returning existing local MSP
2020-09-24 06:03:35.702 UTC [msp] GetDefaultSigningIdentity -> DEBU 01d Obtaining default signing identity
2020-09-24 06:03:35.703 UTC [msp/identity] Sign -> DEBU 01e Sign: plaintext: 0ABF060A1508021A0608B7EDB0FB0522...E5E08F74893C12080A021A0012021A00 
2020-09-24 06:03:35.703 UTC [msp/identity] Sign -> DEBU 01f Sign: digest: 56339A77350C1A804A8058ACEF0550D108CCB7E266A5734533F7A286133E4D9C 
2020-09-24 06:03:35.732 UTC [channelCmd] readBlock -> DEBU 020 Received block:0 
2020-09-24 06:03:35.733 UTC [main] main -> INFO 021 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
2020-09-24 06:03:35.822 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:35.822 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:35.826 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 06:03:35.827 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A86070A5C08011A0C08B7EDB0FB0510...5F92D770B8D41A080A000A000A000A00 
2020-09-24 06:03:35.827 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 1FC95717CF159E5BF071FA4D741025AB9BC17E307B1E7F11364BE1976D03F700 
2020-09-24 06:03:35.895 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2020-09-24 06:03:35.896 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
2020-09-24 06:03:38.001 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:38.001 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:38.004 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 06:03:38.004 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A85070A5B08011A0B08BAEDB0FB0510...5F92D770B8D41A080A000A000A000A00 
2020-09-24 06:03:38.004 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: EF0E34FD2143F9EFFFB91C7593AABBCFC309C952E3AAB70DD675E67EBDBE0840 
2020-09-24 06:03:38.077 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2020-09-24 06:03:38.077 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
2020-09-24 06:03:40.144 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:40.144 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:40.148 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 06:03:40.148 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A85070A5B08011A0B08BCEDB0FB0510...5F92D770B8D41A080A000A000A000A00 
2020-09-24 06:03:40.148 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 7E3D9471CB81833879C4AAA68D07B99ED16F344BEBEB88BED2985D49C236C0DC 
2020-09-24 06:03:40.197 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2020-09-24 06:03:40.197 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
2020-09-24 06:03:42.277 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:42.277 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:42.280 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 06:03:42.280 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A86070A5C08011A0C08BEEDB0FB0510...5F92D770B8D41A080A000A000A000A00 
2020-09-24 06:03:42.280 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 307429B2F0A712EB734DC605111D796A5FDE454D649BCDF4D1D4CF282A863C55 
2020-09-24 06:03:42.317 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2020-09-24 06:03:42.317 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
2020-09-24 06:03:44.389 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:44.389 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:44.392 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 06:03:44.392 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2020-09-24 06:03:44.392 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2020-09-24 06:03:44.392 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2020-09-24 06:03:44.392 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2020-09-24 06:03:44.392 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A88060A074F7267314D535012FC052D...72731200220A0A0641646D696E731200 
2020-09-24 06:03:44.392 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: CE0BBEE6477F6F778EE453DD7F6172D57C855AD11FC332755829725A2E195930 
2020-09-24 06:03:44.392 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2020-09-24 06:03:44.392 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2020-09-24 06:03:44.392 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2020-09-24 06:03:44.393 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2020-09-24 06:03:44.393 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0ABF060A1508021A0608C0EDB0FB0522...71DB89122D78577A76A4201071ABD7A8 
2020-09-24 06:03:44.393 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 88B311AC32A7BEEF909651FEB7B79E909386ED503F0221447D0CEEAC27453BF1 
2020-09-24 06:03:44.456 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
2020-09-24 06:03:49.507 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:49.507 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:49.514 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 06:03:49.514 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2020-09-24 06:03:49.514 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2020-09-24 06:03:49.514 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2020-09-24 06:03:49.514 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2020-09-24 06:03:49.514 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A88060A074F7267324D535012FC052D...72731200220A0A0641646D696E731200 
2020-09-24 06:03:49.514 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: A8F3368AF8D87033B10CB75AC0171242483FBDDDF710623AEF2D1ECB6D246921 
2020-09-24 06:03:49.515 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2020-09-24 06:03:49.515 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2020-09-24 06:03:49.515 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2020-09-24 06:03:49.515 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2020-09-24 06:03:49.515 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0ABF060A1508021A0608C5EDB0FB0522...55111F568CFB353B048DB7829B697A59 
2020-09-24 06:03:49.515 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: DF93F35003104A57C7C8A59332669DEC2695B0EDAC5CA0A7E02256EF8B7AA20E 
2020-09-24 06:03:49.559 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
2020-09-24 06:03:54.637 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:54.638 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:54.638 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2020-09-24 06:03:54.638 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2020-09-24 06:03:55.266 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2020-09-24 06:03:55.822 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2020-09-24 06:03:55.822 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2020-09-24 06:03:55.822 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2020-09-24 06:03:55.822 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2020-09-24 06:03:55.822 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2020-09-24 06:03:55.824 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A86070A5C08031A0C08CBEDB0FB0510...8BAEFF040000FFFF84DB3255002C0000 
2020-09-24 06:03:55.824 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 96E6D9272AB1D988DE69DF975A28FB8F8A142EA54D938D198973C019BBBEF948 
2020-09-24 06:03:55.828 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" > 
2020-09-24 06:03:55.828 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
2020-09-24 06:03:55.939 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:55.940 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:55.940 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2020-09-24 06:03:55.940 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2020-09-24 06:03:56.002 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2020-09-24 06:03:56.175 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2020-09-24 06:03:56.175 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2020-09-24 06:03:56.175 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2020-09-24 06:03:56.175 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2020-09-24 06:03:56.175 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2020-09-24 06:03:56.179 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A85070A5B08031A0B08CCEDB0FB0510...8BAEFF040000FFFF84DB3255002C0000 
2020-09-24 06:03:56.179 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 2A11FA33DEFC09AF44B6DBD74145C6268B7B7F5D2D07DD79833515BBC4EB302B 
2020-09-24 06:03:56.186 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" > 
2020-09-24 06:03:56.186 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
2020-09-24 06:03:56.239 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:03:56.239 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:03:56.242 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2020-09-24 06:03:56.242 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2020-09-24 06:03:56.242 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A90070A6608031A0B08CCEDB0FB0510...324D53500A04657363630A0476736363 
2020-09-24 06:03:56.242 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 135B4574B3AB6306330828AD313204BBC9C2EF3E5D33572E7333F02F4C312733 
2020-09-24 06:04:20.617 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0A90070A6608031A0B08CCEDB0FB0510...1AA6B5B27683580A87310BC79AC46E3E 
2020-09-24 06:04:20.617 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: 77FD9776C5844429F4A45B4F98499A9F45AD33998FE8DF510DF62A781F339F22 
2020-09-24 06:04:20.621 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 ...3 secs

2020-09-24 06:04:23.794 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:04:23.795 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:04:23.795 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2020-09-24 06:04:23.795 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2020-09-24 06:04:23.798 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A91070A6708031A0C08E7EDB0FB0510...6D7963631A0A0A0571756572790A0161 
2020-09-24 06:04:23.798 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 21B941E99A3C8C6AD6FB5661499F8DE8045AE9FE6E403C7B59ADEE113F4C59D9 
Query Result: 100
2020-09-24 06:04:44.543 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
2020-09-24 06:04:44.700 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:04:44.700 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:04:44.702 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2020-09-24 06:04:44.702 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2020-09-24 06:04:44.702 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A91070A6708031A0C08FCEDB0FB0510...696E766F6B650A01610A01620A023130 
2020-09-24 06:04:44.702 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 0638FE536E7005EBCEA47F0CF3D65C8D441E7776CF800D3A4C3F2306CF3F681B 
2020-09-24 06:04:44.719 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0A91070A6708031A0C08FCEDB0FB0510...060BE069770A9E6C00A400AF6CB2E539 
2020-09-24 06:04:44.719 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: F039995E54AECAE7B91FCF2FA22CED099637CF87F6077BB49D662DA6AD4B933F 
2020-09-24 06:04:44.725 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 009 ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \rS-\342\361Y\335?*\201\351N\005\230o\277X\230i\272a\334^\344\210\234\033\316\200J_<\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\200\006-----BEGIN -----\nMIICGTCCAb+gAwIBAgIQIZPhuFKON7Dh0xFNWEO7AzAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0yMDA5MjQwNjAzMjFaFw0zMDA5MjIwNjAzMjFa\nMFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMR8wHQYDVQQDExZwZWVyMC5vcmcxLmV4YW1wbGUuY29tMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEXbaYHsF2xGrK5cBDcmglRok/AMWCcK9n\npkZXPTp0IG0ton3ymR3MPkQmdaM2r/SgB6mLdeqvGbOR++A0d5ordKNNMEswDgYD\nVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgv4/KeWE5IHBe\naPsMw/1zyM5IiduLeFOiwQtdspNmj7IwCgYIKoZIzj0EAwIDSAAwRQIhAJIKngNQ\nSg6LYwF3IKNPlzQV4smJYVHhiJ2duJYelbCnAiAaZgQkPDJ/noDgaEaYSr1OQDJ0\nTNAFAC2ewt9H5qoObw==\n-----END -----\n" signature:"0D\002 n\357HA\236\3571o\336\215\334\362\341\354}?W\301\027\246=bn(\034J\246\213g\224KT\002 )\303\236\313\347c\003_C8\306\315<\367j\316\006\013\340iw\n\236l\000\244\000\257l\262\3459" > 
2020-09-24 06:04:44.726 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00a Chaincode invoke successful. result: status:200 
2020-09-24 06:04:44.726 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
2020-09-24 06:04:44.821 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:04:44.821 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:04:44.821 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2020-09-24 06:04:44.821 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2020-09-24 06:04:45.003 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2020-09-24 06:04:45.239 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2020-09-24 06:04:45.239 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2020-09-24 06:04:45.239 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2020-09-24 06:04:45.239 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2020-09-24 06:04:45.239 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2020-09-24 06:04:45.260 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A85070A5B08031A0B08FDEDB0FB0510...8BAEFF040000FFFF84DB3255002C0000 
2020-09-24 06:04:45.260 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: A67215B0359AC06B8937C654F6AC7CA853C6DBCBA9D4ACA38758FACAFD448734 
2020-09-24 06:04:45.280 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" > 
2020-09-24 06:04:45.280 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

2020-09-24 06:04:48.368 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2020-09-24 06:04:48.368 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2020-09-24 06:04:48.368 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2020-09-24 06:04:48.368 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2020-09-24 06:04:48.368 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A91070A6708031A0C0880EEB0FB0510...6D7963631A0A0A0571756572790A0161 
2020-09-24 06:04:48.368 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 4A1E7EE3E79A10E47F765C9832AC153022C90FFFAECD020608AEBBD33CD2277B 
Query Result: 90
2020-09-24 06:05:07.907 UTC [main] main -> INFO 007 Exiting.....
===================== Query on PEER3 on channel 'mychannel' is successful ===================== 

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


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

2、手動測試一下Fabric網路

我們仍然是以現在安裝好的Example02為例,在官方例子中,channel名字是mychannel,鏈碼的名字是mycc。我們首先進入CLI,我們重新開啟一個命令列視窗,輸入:

docker exec -it cli bash

執行以下命令可以查詢a賬戶的餘額:

peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

在這裡插入圖片描述
然後,我們試一試把a賬戶的餘額再轉80元給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","80"]}'

執行結果如下圖:
在這裡插入圖片描述
現在轉賬完畢, 我們試一試再查詢一下a賬戶的餘額,沒問題的話,應該是隻剩下10塊大洋了。我們看看實際情況:
在這裡插入圖片描述
bingo,正如我們所願。

3、關閉Fabric網路

最後我們要關閉Fabric網路,首先需要執行exit命令退出cli容器。關閉Fabric的命令與啟動類似,命令為:

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

過程如下:

halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/examples/e2e_cli$ ./network_setup.sh down
setting to default channel 'mychannel'
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
Stopping cli                    ... done
Stopping peer0.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Stopping orderer.example.com    ... done
Stopping peer1.org2.example.com ... done
Stopping peer1.org1.example.com ... done
Removing cli                    ... done
Removing peer0.org1.example.com ... done
Removing peer0.org2.example.com ... done
Removing orderer.example.com    ... done
Removing peer1.org2.example.com ... done
Removing peer1.org1.example.com ... done
Removing network e2ecli_default
49c35a7144ed
1757636a5f53
425fba1bd2d7
Untagged: dev-peer1.org2.example.com-mycc-1.0:latest
Deleted: sha256:9e7b2495f4433d5b0f5eb3a876f74a246cb37af919e5b47d567505ae77f83df4
Deleted: sha256:fd93b79a499dc6e372009449bfe7a913a8695941052467c1f63eb6b86a001786
Deleted: sha256:66d9b3022ef4fc06246be09a9dfe1afe493d6cecff955f77fa8ad583b1ecbbbf
Deleted: sha256:64ec50d0ff3b4c6f1eb678ddc8ec8c0866cf98f300a925175e964fa45090c930
Deleted: sha256:cb08a8077c6f7451b589da007ea0877f1bf7393fcf3f773e4907e7e0985890ef
Deleted: sha256:f53aee1e74e529c3af7bb8d5acb750bf00f85e27af7b49f47ff8095ff5c8d575
Deleted: sha256:fe91dc1cbc204858760cc561b545038d9d8b5965ffca853ece60a59deb7eba92
Untagged: dev-peer0.org1.example.com-mycc-1.0:latest
Deleted: sha256:107d6723dd0cd2633ecf004dc6612fca57709d2dba90a657d9072534a6477c9b
Deleted: sha256:bfc9fc6475aac3b7f446171b677a6554227a3e8a0c066d28c2af679c060a6e1d
Deleted: sha256:2a5d86ab68ff3d8b4fe320754f844daef9ad76e5b8a14ec1bd09f87570cd6165
Deleted: sha256:917f297dddfd0bb4fa50928e9a43a3eea526b3b985bcccda01bafdd3f4a1b90f
Deleted: sha256:f423d7575cb773000a2fbe0dca51aa215d00bd91d8fbb37c4c26378af8134813
Deleted: sha256:fa96f0e5805e6b00d2e95b6e798dfa7470fb7431855eed4399a22bc2fc270c0c
Deleted: sha256:6586cb10d4d95034a464d7dba9f2fe509bf80413e6c30ac3119330d92f20cb40
Untagged: dev-peer0.org2.example.com-mycc-1.0:latest
Deleted: sha256:8370b1cd876644e610eb2ff362f29c96538370f7d4f513e010801cfce3a63ace
Deleted: sha256:f2190cdc9c8235ab0d9f37975a71923c7fd498fa517533e527d87bbaddbbf4ea
Deleted: sha256:e5d2ead105e3246c0cdcc1be6c8ac78fb11d959564839a2b41c147962e37cbb4
Deleted: sha256:a592dd4f7d4346b5921d6dc7fd48652bfa70907e40e04942382cdd16329be9ef
Deleted: sha256:92bae31265fc9a8bbcf394328f7855a64ef8c13b1885e21015b5accc7b9e487c
Deleted: sha256:5b34425a5f4db01b75d04a1b4f9acd367a9378a5834f77b99c441df323d1e52b
Deleted: sha256:4298b29759ca67c745a5fca6da441dd2e74d1a4802159afd1fd001a354b33d73
halfape@halfape-VirtualBox:~/go/src/github.com/hyperledger/fabric/examples/e2e_cli$ 

參考文章:

https://blog.csdn.net/jambeau/article/details/103712408
https://www.cnblogs.com/studyzy/p/7437157.html

寫在最後

感謝上面兩位大佬的貢獻,我個人在此基礎上進行了整合,自己也是排了很多雷,終於成功了。如果你覺得這篇文章對你有所幫助,關注微信公眾號半路猿,拉你進我們的學習交流群,一起學習,一同成長。