Hyperledger Fabric入門實戰(二)——環境搭建

1. Fabric環境搭建

準備工作

  1. 官方幫助文檔:https://hyperledger-fabric.readthedocs.io/en/release-1.2/
  2. 安裝 cURL(https://curl.haxx.se/download.html),curl --version 查詢版本
  3. 安裝docker,docker --version 查詢版本
  4. 安裝docker-compose,docker-compose --version 查詢版本
  5. 安裝 go 語言環境,go version 查詢版本
  6. 安裝node.js, node -v 查詢版本
  7. Python 版本要求爲 2.7,python --version 查詢版本

1.1 安裝docker

  1. 基礎軟件安裝

    # 安裝基本軟件
    $ sudo apt-get update
    $ sudo apt-get install apt-transport-https ca-certificates curl git software-properties-common lrzsz -y
    
  2. 添加阿里的docker鏡像倉庫

    # 添加阿里的docker鏡像倉庫
    $ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
    $ sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
    # 更新軟件源
    $ sudo apt-get update
    
  3. 安裝docker

    # 安裝docker
    $ sudo apt-get install docker-ce -y
    # 查看安裝的docker版本
    $ docker version
    	Client:
             Version:           18.06.1-ce
             API version:       1.38
             Go version:        go1.10.3
             Git commit:        e68fc7a
             Built:             Tue Aug 21 17:24:51 2018
             OS/Arch:           linux/amd64
             Experimental:      false
        Got permission denied while trying to connect to the Docker daemon socket at
        unix:///var/run/docker.sock: Get
        http://%2Fvar%2Frun%2Fdocker.sock/v1.38/version: 
        dial unix /var/run/docker.sock: connect: `permission denied`
    # 當前用戶直接操作docker時, 權限不夠, 需要做下面的第4不操作
    #配置加速器
    加速器網址 http://dashboard.daocloud.io/build-flows ,點擊小火箭, 複製一下linux代碼,然後將代碼在在Ubuntu的shell上運行
     注:進入  /etc/docker 修改damon.json裏的內容爲{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],"insecure-registries":[]}
     重啓docker:
      sudo  systemctl restart docker
    
  4. 將當前用戶添加到docker組

    # 將用戶加入該 group 內。然後退出並重新登錄就生效啦。
    $ sudo gpasswd -a ${USER} docker
    # 重啓docker服務
    $ systemctl restart docker
    # 當前用戶切換到docker羣組
    $ newgrp - docker
    $ docker version
    	Client:
             Version:           18.06.1-ce
             API version:       1.38
             Go version:        go1.10.3
             Git commit:        e68fc7a
             Built:             Tue Aug 21 17:24:51 2018
             OS/Arch:           linux/amd64
             Experimental:      false
    
        Server:
             Engine:
             Version:          18.06.1-ce
             API version:      1.38 (minimum version 1.12)
             Go version:       go1.10.3
             Git commit:       e68fc7a
             Built:            Tue Aug 21 17:23:15 2018
             OS/Arch:          linux/amd64
             Experimental:     false
    
  5. 安裝docker-compose

    #安裝依賴工具
    $ sudo apt-get install python-pip -y
    #安裝編排工具
    $ sudo pip install docker-compose
    #查看版本
    $ sudo docker-compose version
    

1.2 安裝go

# 1. 使用wget工具下載安裝包
$ wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz
# 2. 解壓tar包到/usr/local
$ sudo tar zxvf go1.11.linux-amd64.tar.gz -C /usr/local
# 3. 創建Go目錄
$ mkdir $HOME/go
# 4. 用vi打開~./bashrc,配置環境變量
$ vim ~/.bashrc
# 5. 增加下面的環境變量,保存退出
	export GOROOT=/usr/local/go
    export GOPATH=$HOME/go
    export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
# 6. 使環境變量立即生效, 一些命令二選一
$ source ~/.bashrc  
$ . ~/.bashrc
# 7. 檢測go是否安裝好
$ go version

1.3 安裝Node.js

  1. 下載二進制源碼包

    $ wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz
    
  2. 解壓並安裝

    # 指定壓縮包解壓到/opt目錄下
    $ sudo tar xvf node-v8.11.4-linux-x64.tar.xz -C /opt
    	- 在/opt目錄下得到 node-v8.11.4-linux-x64 目錄
    
  3. 將node.js設置爲全局可用

    # 打開系統級別的配置文件 /etc/profile
    $ sudo vim /etc/profile
    # 添加如下配置項, 保存退出
        export NODEJS_HOME=/opt/node-v8.11.4-linux-x64
        export PATH=$PATH:$NODEJS_HOME/bin
    # 重新加載配置文件
    $ . /etc/profile
    /etc/profile -> 設置環境變量的配置文件
    	- 對當前系統下所有用戶生效
    
  4. 測試

    $ node -v
    

1.4 部署hyperledger Fabric

  1. 下載並執行fabric的引導腳本bootstrap.sh
    這個過程會很漫長很漫長… 快的話一兩個小時,慢的話一兩天 …

    # 創建放置的目錄,然後進入該目錄,用curl下載腳本。
    $ cd ~ # 這裏在家目錄下創建放置目錄
    $ mkdir hyperledger-fabric # 創建放置目錄
    $ cd hyperledger-fabric
    # ***這裏本人電腦連接無線網無法下載,一直報錯,電腦要開vpn才能下載,但是按理說服務器上的網和本機的網應該沒有任何關係纔對,有些玄學... 建議電腦連接網線 try a try***
    $ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s 1.2.0 1.2.0 0.4.10
      #-s後面三個參數,分別爲:
      	- fabric: fabric的版本
    	- fabric-ca: fabric-ca的版本
    	- thirdparty: 第三方庫的版本
    # 該腳本啓動之後會下載兩個壓縮包和一些鏡像文件, 整個過程會比較長, 耐心等待...
    # 溫馨提示: 這個過程會讓你產生想要砸電腦的衝動, 控制好你的情緒!!!!
    # 上述命令剛開始會下載以下兩個壓縮包, 這兩個包下載速度特別慢慢慢慢慢慢慢.......
    # 	1. hyperledger-fabric-linux-amd64-1.2.0.tar.gz
    # 	2. hyperledger-fabric-ca-linux-amd64-1.2.0.tar.gz
    以上兩個壓縮包下載下來之後會被解壓, 解壓目錄:
    ~/hyperledger-fabric/fabric-samples
    可以將事先下載好的兩個壓縮包放到該目錄下, 提高下載速度 (強烈建議), 放好之後再重新執行上邊的curl命令
    

    通過上述操作拉取的docker鏡像爲:

    鏡像文件名稱 用途
    hyperledger/fabric-peer peer模塊鏡像文件
    hyperledger/fabric-orderer orderer節點庫鏡像文件
    hyperledger/fabric-ccenv Go語言chaincode運行環境庫鏡像文件
    hyperledger/fabric-tools 相關工具鏡像文件包含了cryptogen, configtxgen等工具
    hyperledger/fabric-ca CA模塊鏡像文件
    hyperledger/fabric-couchdb couchdb數據庫鏡像文件
    hyperledger/fabric-kafka kafka庫鏡像文件
    hyperledger/fabric-zookeeper zookeeper庫鏡像文件

    下載完,可以看到已經下載的docker相關鏡像

    ===> List out hyperledger docker images

    hyperledger/fabric-ca 1.2.0 66cc132bd09c 2 months ago 252MB

    hyperledger/fabric-ca latest 66cc132bd09c 2 months ago 252MB
    hyperledger/fabric-tools 1.2.0 379602873003 2 months ago 1.51GB
    hyperledger/fabric-tools latest 379602873003 2 months ago 1.51GB
    hyperledger/fabric-ccenv 1.2.0 6acf31e2d9a4 2 months ago 1.43GB
    hyperledger/fabric-ccenv latest 6acf31e2d9a4 2 months ago 1.43GB
    hyperledger/fabric-orderer 1.2.0 4baf7789a8ec 2 months ago 152MB
    hyperledger/fabric-orderer latest 4baf7789a8ec 2 months ago 152MB
    hyperledger/fabric-peer 1.2.0 82c262e65984 2 months ago 159MB
    hyperledger/fabric-peer latest 82c262e65984 2 months ago 159MB
    hyperledger/fabric-zookeeper 0.4.10 2b51158f3898 2 months ago 1.44GB
    hyperledger/fabric-zookeeper latest 2b51158f3898 2 months ago 1.44GB
    hyperledger/fabric-kafka 0.4.10 936aef6db0e6 2 months ago 1.45GB
    hyperledger/fabric-kafka latest 936aef6db0e6 2 months ago 1.45GB
    hyperledger/fabric-couchdb 0.4.10 3092eca241fc 2 months ago 1.61GB
    hyperledger/fabric-couchdb latest 3092eca241fc 2 months ago 1.61GB

  2. 設置全局訪問

    # 進入到 ~/hyperledger-fabric/fabric-samples/bin 目錄
    $ cd ~/hyperledger-fabric/fabric-samples/bin
    itcast@ubuntu:~/hyperledger-fabric/fabric-samples/bin$ tree
        .
        ├── configtxgen
        ├── configtxlator
        ├── cryptogen
        ├── discover
        ├── fabric-ca-client
        ├── get-docker-images.sh
        ├── idemixgen
        ├── orderer
        └── peer
    # 將這些二進制文件拷貝到 /usr/local/bin 目錄下
    $ sudo cp * /usr/local/bin
    # 執行完上述操作之後, fabric的這些可執行程序就可以在全局範圍內使用了
    

###1.5 First-Network 環境測試

####1.5.1 生成相應文件

執行 ./byfn.sh generate 命令生成相應的文件

$ cd ~/hyperledger-fabric/fabric-samples/first-network/
$ ./byfn.sh generate	

Generating certs and genesis block for channel ‘mychannel’ with CLI timeout of ‘10’ seconds and CLI delay of ‘3’ seconds
Continue? [Y/n] y
proceeding …
/home/zoro/hyperledger-fabric/fabric-samples/first-network/…/bin/cryptogen

Generate certificates using cryptogen tool

  • cryptogen generate --config=./crypto-config.yaml
    org1.example.com
    org2.example.com
  • res=0
  • set +x

/home/zoro/hyperledger-fabric/fabric-samples/first-network/…/bin/configtxgen

Generating Orderer Genesis block

  • configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
    2018-09-23 11:03:32.183 CST [common/tools/configtxgen] main -> WARN 001 Omitting the channel ID for configtxgen is deprecated. Explicitly passing the channel ID will be required in the future, defaulting to ‘testchainid’.
    2018-09-23 11:03:32.183 CST [common/tools/configtxgen] main -> INFO 002 Loading configuration
    2018-09-23 11:03:32.190 CST [common/tools/configtxgen/encoder] NewChannelGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the channel group in configtx.yaml
    2018-09-23 11:03:32.191 CST [common/tools/configtxgen/encoder] NewOrdererGroup -> WARN 004 Default policy emission is deprecated, please include policy specificiations for the orderer group in configtx.yaml
    2018-09-23 11:03:32.191 CST [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 005 Default policy emission is deprecated, please include policy specificiations for the orderer org group OrdererOrg in configtx.yaml
    2018-09-23 11:03:32.192 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
    2018-09-23 11:03:32.192 CST [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 007 Default policy emission is deprecated, please include policy specificiations for the orderer org group Org1MSP in configtx.yaml
    2018-09-23 11:03:32.193 CST [msp] getMspConfig -> INFO 008 Loading NodeOUs
    2018-09-23 11:03:32.193 CST [common/tools/configtxgen/encoder] NewOrdererOrgGroup -> WARN 009 Default policy emission is deprecated, please include policy specificiations for the orderer org group Org2MSP in configtx.yaml
    2018-09-23 11:03:32.193 CST [common/tools/configtxgen] doOutputBlock -> INFO 00a Generating genesis block
    2018-09-23 11:03:32.194 CST [common/tools/configtxgen] doOutputBlock -> INFO 00b Writing genesis block
  • res=0
  • set +x

Generating channel configuration transaction ‘channel.tx’

  • configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
    2018-09-23 11:03:32.238 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
    2018-09-23 11:03:32.252 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
    2018-09-23 11:03:32.253 CST [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the application group in configtx.yaml
    2018-09-23 11:03:32.253 CST [msp] getMspConfig -> INFO 004 Loading NodeOUs
    2018-09-23 11:03:32.254 CST [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 005 Default policy emission is deprecated, please include policy specificiations for the application org group Org1MSP in configtx.yaml
    2018-09-23 11:03:32.254 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
    2018-09-23 11:03:32.254 CST [common/tools/configtxgen/encoder] NewApplicationOrgGroup -> WARN 007 Default policy emission is deprecated, please include policy specificiations for the application org group Org2MSP in configtx.yaml
    2018-09-23 11:03:32.257 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 008 Writing new channel tx
  • res=0
  • set +x

Generating anchor peer update for Org1MSP

  • configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
    2018-09-23 11:03:32.298 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
    2018-09-23 11:03:32.307 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
    2018-09-23 11:03:32.307 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
  • res=0
  • set +x

Generating anchor peer update for Org2MSP

  • configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
    2018-09-23 11:03:32.350 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
    2018-09-23 11:03:32.362 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
    2018-09-23 11:03:32.363 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
  • res=0
  • set +x

1.5.2 啓動網路

執行 ./byfn.sh up 啓動網絡

# byfn == build your first network
$ ./byfn.sh up

當我們看到START的時候,表示啓動成功。

Starting for channel ‘mychannel’ with CLI timeout of ‘10’ seconds and CLI delay of ‘3’ seconds
Continue? [Y/n] y
proceeding …
LOCAL_VERSION=1.2.0
DOCKER_IMAGE_VERSION=1.2.0
Creating network “net_byfn” with the default driver
Creating volume “net_peer0.org2.example.com” with default driver
Creating volume “net_peer1.org2.example.com” with default driver
Creating volume “net_peer1.org1.example.com” with default driver
Creating volume “net_peer0.org1.example.com” with default driver
Creating volume “net_orderer.example.com” with default driver
Creating peer1.org1.example.com … done
Creating peer0.org1.example.com … done
Creating peer0.org2.example.com … done
Creating orderer.example.com … done
Creating peer1.org2.example.com … done
Creating cli … done

START

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

Channel name : mychannel
Creating channel…

  • peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --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
  • res=0
  • set +x
    2018-09-23 03:03:55.350 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-09-23 03:03:55.420 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
    2018-09-23 03:03:55.422 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
    2018-09-23 03:03:55.629 UTC [cli/common] readBlock -> INFO 004 Received block: 0
    ===================== Channel ‘mychannel’ created =====================

Having all peers join the channel…

  • peer channel join -b mychannel.block
  • res=0
  • set +x
    2018-09-23 03:03:55.699 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-09-23 03:03:55.807 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
    ===================== peer0.org1 joined channel ‘mychannel’ =====================
  • peer channel join -b mychannel.block
  • res=0
  • set +x
    2018-09-23 03:03:58.874 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-09-23 03:03:58.976 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
    ===================== peer1.org1 joined channel ‘mychannel’ =====================
  • peer channel join -b mychannel.block
  • res=0
  • set +x
    2018-09-23 03:04:02.058 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-09-23 03:04:02.169 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
    ===================== peer0.org2 joined channel ‘mychannel’ =====================
  • peer channel join -b mychannel.block
  • res=0
  • set +x
    2018-09-23 03:04:05.231 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-09-23 03:04:05.339 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
    ===================== peer1.org2 joined channel ‘mychannel’ =====================

Updating anchor peers for org1…

  • peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --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
  • res=0
  • set +x
    2018-09-23 03:04:08.406 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-09-23 03:04:08.422 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
    ===================== Anchor peers updated for org ‘Org1MSP’ on channel ‘mychannel’ =====================

Updating anchor peers for org2…

  • peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --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
  • res=0
  • set +x
    2018-09-23 03:04:11.503 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2018-09-23 03:04:11.519 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
    ===================== Anchor peers updated for org ‘Org2MSP’ on channel ‘mychannel’ =====================

Installing chaincode on peer0.org1…

  • peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
  • res=0
  • set +x
    2018-09-23 03:04:14.610 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2018-09-23 03:04:14.610 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    2018-09-23 03:04:15.000 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:“OK” >
    ===================== Chaincode is installed on peer0.org1 =====================

Install chaincode on peer0.org2…

  • peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
  • res=0
  • set +x
    2018-09-23 03:04:15.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2018-09-23 03:04:15.069 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    2018-09-23 03:04:15.203 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:“OK” >
    ===================== Chaincode is installed on peer0.org2 =====================

Instantiating chaincode on peer0.org2…

  • peer chaincode instantiate -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 -l golang -v 1.0 -c ‘{“Args”:[“init”,“a”,“100”,“b”,“200”]}’ -P ‘AND (’’‘Org1MSP.peer’’’,’’‘Org2MSP.peer’’’)’
  • res=0
  • set +x
    2018-09-23 03:04:15.284 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2018-09-23 03:04:15.284 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    ===================== Chaincode is instantiated on peer0.org2 on channel ‘mychannel’ =====================

Querying chaincode on peer0.org1…
===================== Querying on peer0.org1 on channel ‘mychannel’… =====================
Attempting to Query peer0.org1 …3 secs

  • peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,“a”]}’
  • res=0
  • set +x

100
===================== Query successful on peer0.org1 on channel ‘mychannel’ =====================
Sending invoke transaction on peer0.org1 peer0.org2…

  • 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 --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ‘{“Args”:[“invoke”,“a”,“b”,“10”]}’
  • res=0
  • set +x
    2018-09-23 03:05:17.876 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
    ===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel ‘mychannel’ =====================

Installing chaincode on peer1.org2…

  • peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
  • res=0
  • set +x
    2018-09-23 03:05:17.966 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
    2018-09-23 03:05:17.966 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
    2018-09-23 03:05:18.340 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:“OK” >
    ===================== Chaincode is installed on peer1.org2 =====================

Querying chaincode on peer1.org2…
===================== Querying on peer1.org2 on channel ‘mychannel’… =====================
Attempting to Query peer1.org2 …3 secs

  • peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,“a”]}’
  • res=0
  • set +x

90
===================== Query successful on peer1.org2 on channel ‘mychannel’ =====================

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

END

執行結束,顯示END

  1. 通過docker ps命令可以查看到節點的啓動情況。

    $ docker ps
    
  2. 如果我們要停止網絡,可以執行./byfn.sh down 命令來停止

    $ ./byfn.sh down
    

    Stopping for channel ‘mychannel’ with CLI timeout of ‘10’ seconds and CLI delay of ‘3’ seconds
    Continue? [Y/n] y
    proceeding …
    Stopping cli … done
    Stopping orderer.example.com … done
    Stopping peer1.org2.example.com … done
    Stopping peer1.org1.example.com … done
    Stopping peer0.org2.example.com … done
    Stopping peer0.org1.example.com … done
    Removing cli … done
    Removing orderer.example.com … done
    Removing peer1.org2.example.com … done
    Removing peer1.org1.example.com … done
    Removing peer0.org2.example.com … done
    Removing peer0.org1.example.com … done
    Removing network net_byfn
    Removing volume net_peer0.org3.example.com
    WARNING: Volume net_peer0.org3.example.com not found.
    Removing volume net_peer1.org3.example.com
    WARNING: Volume net_peer1.org3.example.com not found.
    Removing volume net_orderer.example.com
    Removing volume net_peer0.org2.example.com
    Removing volume net_peer0.org1.example.com
    Removing volume net_peer1.org1.example.com
    Removing volume net_peer1.org2.example.com
    80510c01c3e8
    3625e4ce1b01
    43b4b0dfb14f
    Untagged: dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab:latest
    Deleted: sha256:3c7cf25f6520e39afe9ca0770821bcf8892c398ffa8fafaa4d39d4b18bf9a7af
    Deleted: sha256:ac116d2c1fbb503f766149a2acf422b754d59ba4be58902981d03b2969ef21c1
    Deleted: sha256:3e07d57882218fc26936d29deefba9e3bb0230d63b5e82d727ddbc92c59d942d
    Deleted: sha256:9c88b5b791167d2d37be1fc39886e5efa00d522aad7df03869b8eb30aa564b5f
    Untagged: dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9:latest
    Deleted: sha256:16229f944e6c2e665587638a47c80d9594693aede0d25d736d7225370efc67ae
    Deleted: sha256:6a5c627fbc23a646b17a493a6b7df67a2535501b8d77915aab6ac2c1ba97b1b3
    Deleted: sha256:4d0d3e96c80a3e0ee4c3553a125c99bbaffe6f1b487348f87ffb3059d6eb7f2e
    Deleted: sha256:a9600d47e71d3abb5f5afcbf56b6b21955e1bbe7fcb92040f1349667cf712bc0
    Untagged: dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latest
    Deleted: sha256:5f7c63593550d018ab28312c3d040b27a53f2d1e844ddd7d50a2fcf63454594b
    Deleted: sha256:a00c5883309d6a80aaf22f8b704b594c6129150c5048fd00d742077f212b28f7
    Deleted: sha256:71fae53aba930c88450ff286a5e54bceece45ea7aee465a8f2806aa967ab2b21
    Deleted: sha256:08fe44e007fd3d5377b44cca32e8f78d2249b0a1d9ce9312c68636fdacda2edc

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章