ubuntu搭建Fabric环境

 

前言

       基础概念(简书:https://www.jianshu.com/p/a387fc40ff8b):超级账本Fabric是一个分布式解决方案平台,底层是模块化的架构,拥有高度的机密性、弹性(可以理解为抗攻击能力)、灵活性和可扩展性。Fabric支持可插拔的组建模式,并且可以改善经济系统中现有的一些复杂流程。

搭建流程

1、准本工作

1.1 安装 cURL(https://curl.haxx.se/download.html),curl --version 查询版本

1.2安装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`

注意:当“permission denied”显示时,说明当前用户直接操作docker时, 权限不够, 则需要走以下步骤将当前用户添加到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

1.3 安装docker-compose  

安装方式

#安装依赖工具
$ sudo apt-get install python-pip -y
#安装编排工具
$ sudo pip install docker-compose
#查看版本
$ sudo docker-compose version

1.4 安装go语言环境

国内镜像:https://studygolang.com/dl

安装方法:

$ 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.5   安装node.js环境

下载地址:https://nodejs.org/en/download/

安装

# 指定压缩包解压到/opt目录下
$ sudo tar xvf node-v8.11.4-linux-x64.tar.xz -C /opt
	- 在/opt目录下得到 node-v8.11.4-linux-x64 目录

# 设置为全局变量
# 打开系统级别的配置文件 /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 -> 设置环境变量的配置文件
	- 对当前系统下所有用户生效

# 测试是否安装成功
$ node -v

2 部署hyperledger Fabric

1.下载并执行fabric的引导脚本bootstrap.sh

下载

# 创建放置的目录,然后进入该目录,用curl下载脚本。
$ cd ~ # 这里在家目录下创建放置目录
$ mkdir hyperledger-fabric # 创建放置目录
$ cd hyperledger-fabric

# 使用该路径不用
$ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s 1.2.0 1.2.0 
# 说明:- 第一个(1.2.0): fabric的版本
#	- 第二个(1.2.0): fabric-ca的版本
#	- 0.4.10: 第三方库的版本

安装过程中输出的log信息

ubuntu@VM-0-4-ubuntu:~/hyperledger-fabric$ sudo curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s 1.2.0 1.2.0 0.4.10

Clone hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo and checkout v1.2.0
Cloning into 'fabric-samples'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 5420 (delta 3), reused 10 (delta 3), pack-reused 5405
Receiving objects: 100% (5420/5420), 3.34 MiB | 641.00 KiB/s, done.
Resolving deltas: 100% (2790/2790), done.
Note: checking out 'v1.2.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b 

HEAD is now at ed81d7b [FAB-10811] fabric-ca sample is broken on v1.2

Pull Hyperledger Fabric binaries

===> Downloading version 1.2.0 platform specific fabric binaries
===> Downloading:  https://github.com/hyperledger/fabric/releases/download/v1.2.0/hyperledger-fabric-linux-amd64-1.2.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   654  100   654    0     0    799      0 --:--:-- --:--:-- --:--:--   798
100 39.0M  100 39.0M    0     0  22542      0  0:30:15  0:30:15 --:--:-- 28039
==> Done.
===> Downloading version 1.2.0 platform specific fabric-ca-client binary
===> Downloading:  https://github.com/hyperledger/fabric-ca/releases/download/v1.2.0/hyperledger-fabric-ca-linux-amd64-1.2.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   657  100   657    0     0    734      0 --:--:-- --:--:-- --:--:--   734
100 4940k  100 4940k    0     0  22622      0  0:03:43  0:03:43 --:--:-- 63008
==> Done.

Pull Hyperledger Fabric docker images

FABRIC_IMAGES: peer orderer ccenv tools javaenv
===> Pulling fabric Images
====> hyperledger/fabric-peer:1.2.0
1.2.0: Pulling from hyperledger/fabric-peer
Digest: sha256:949b38bad9496d7694b54d30b90b72653804d761a44d721c4dc7a16a5cbcabe8
Status: Image is up to date for hyperledger/fabric-peer:1.2.0
docker.io/hyperledger/fabric-peer:1.2.0
====> hyperledger/fabric-orderer:1.2.0
1.2.0: Pulling from hyperledger/fabric-orderer
Digest: sha256:a10f6d1d4cbb5a0264634c8b5ec63ff6cbbfc7c9fb369a06cc6dfe504d976259
Status: Image is up to date for hyperledger/fabric-orderer:1.2.0
docker.io/hyperledger/fabric-orderer:1.2.0
====> hyperledger/fabric-ccenv:1.2.0
1.2.0: Pulling from hyperledger/fabric-ccenv
Digest: sha256:0a7fb37111cafce79cf89ca8d1af5ca6f721e60a8bd1b2b93521e671e3348af2
Status: Image is up to date for hyperledger/fabric-ccenv:1.2.0
docker.io/hyperledger/fabric-ccenv:1.2.0
====> hyperledger/fabric-tools:1.2.0
1.2.0: Pulling from hyperledger/fabric-tools
Digest: sha256:24cca44a2f2ab6325c6ccc1c91a10bd3e0e71764037a85a473f7e9621b3a0f91
Status: Image is up to date for hyperledger/fabric-tools:1.2.0
docker.io/hyperledger/fabric-tools:1.2.0
====> hyperledger/fabric-javaenv:1.2.0
Error response from daemon: manifest for hyperledger/fabric-javaenv:1.2.0 not found: manifest unknown: manifest unknown
Error response from daemon: No such image: hyperledger/fabric-javaenv:1.2.0
Error response from daemon: No such image: hyperledger/fabric-javaenv:1.2.0
===> Pulling fabric ca Image
====> hyperledger/fabric-ca:1.2.0
1.2.0: Pulling from hyperledger/fabric-ca
Digest: sha256:5fe6d502e52ec2a8d98ee5653e1ba31952098115fb57710ddae86f2c3cc82dad
Status: Image is up to date for hyperledger/fabric-ca:1.2.0
docker.io/hyperledger/fabric-ca:1.2.0
===> Pulling thirdparty docker images
等等等等等等等等等等

设置全局访问

# 进入到 ~/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的这些可执行程序就可以在全局范围内使用了

First-Network 环境测试,生成相应文件

# 进入该文件
cd ~/hyperledger-fabric/fabric-samples/first-network/
#执行./byfn.sh generate命令
ubuntu@VM-0-4-ubuntu:~/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/ubuntu/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/ubuntu/hyperledger-fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2020-06-16 09:46:08.892 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'.
2020-06-16 09:46:08.892 CST [common/tools/configtxgen] main -> INFO 002 Loading configuration
2020-06-16 09:46:08.899 CST [common/tools/configtxgen/encoder] NewChannelGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the channel group in configtx.yaml
2020-06-16 09:46:08.900 CST [common/tools/configtxgen/encoder] NewOrdererGroup -> WARN 004 Default policy emission is deprecated, please include policy specificiations for the orderer group in configtx.yaml
2020-06-16 09:46:08.900 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
2020-06-16 09:46:08.901 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2020-06-16 09:46:08.901 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
2020-06-16 09:46:08.901 CST [msp] getMspConfig -> INFO 008 Loading NodeOUs
2020-06-16 09:46:08.901 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
2020-06-16 09:46:08.901 CST [common/tools/configtxgen] doOutputBlock -> INFO 00a Generating genesis block
2020-06-16 09:46:08.902 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
2020-06-16 09:46:08.939 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2020-06-16 09:46:08.946 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2020-06-16 09:46:08.947 CST [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the application group in configtx.yaml
2020-06-16 09:46:08.947 CST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2020-06-16 09:46:08.947 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
2020-06-16 09:46:08.948 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2020-06-16 09:46:08.948 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
2020-06-16 09:46:08.949 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
2020-06-16 09:46:08.986 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2020-06-16 09:46:08.995 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2020-06-16 09:46:08.995 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
2020-06-16 09:46:09.034 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2020-06-16 09:46:09.042 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2020-06-16 09:46:09.043 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x

启动网络

# 执行以下命令
ubuntu@VM-0-4-ubuntu:~/hyperledger-fabric/fabric-samples/first-network$ ./byfn.sh up
#打印日志
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_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating peer0.org2.example.com ... done
Creating peer1.org1.example.com ... done
Creating peer0.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating orderer.example.com    ... done
Creating cli                    ... done

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

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
2020-06-16 01:47:27.605 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-06-16 01:47:27.661 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
2020-06-16 01:47:27.665 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-06-16 01:47:27.874 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
2020-06-16 01:47:27.962 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-06-16 01:47:28.060 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
2020-06-16 01:47:31.171 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-06-16 01:47:31.246 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
2020-06-16 01:47:34.322 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-06-16 01:47:34.394 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
2020-06-16 01:47:37.467 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-06-16 01:47:37.578 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
2020-06-16 01:47:40.659 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-06-16 01:47:40.670 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
2020-06-16 01:47:43.748 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-06-16 01:47:43.760 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
2020-06-16 01:47:46.834 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-16 01:47:46.834 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-06-16 01:47:47.891 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response: 
===================== 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
2020-06-16 01:47:47.969 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-16 01:47:47.969 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-06-16 01:47:48.144 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response: 
===================== 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
2020-06-16 01:47:48.227 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-16 01:47:48.227 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
2020-06-16 01:49:01.639 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
2020-06-16 01:49:01.719 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-06-16 01:49:01.719 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-06-16 01:49:01.911 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response: 
===================== 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时则表示该网络启动成功

$ docker ps   查看节点的启动情况

$ ./byfn.sh down  停止网络

 

 

 

 

 

你可能感兴趣的:(区块链)