搭建fabric开发环境

1. 准备运行 Fabric 所需工具

本文所述运行环境均在 centos 系统下进行。

搭建开发环境需要安装以下工具:

  • docker
  • docker-compose
  • git
  • golang

安装 docker:

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo systemctl start docker

安装 docker-compose:

$ yum install docker-compose

安装 git:

$ yum install git

安装 golang:

$ wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
$ tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz

$HOME/.bash_profile 添加:

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

生效变量修改:

$ source $HOME/.bash_profile

2. 准备 Fabric 镜像、程序以及测试代码

运行 byfn 测试网的准备工作,也是搭建开发环境的过程,最终,测试网能成功运行也说明环境搭建成功。

新建一个目录并进入:

$ mkdir hyperledger && cd hyperledger

下载执行脚本,此脚本用来自动化下载 fabric 镜像、程序和测试网运行脚本等工具:

$ wget https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh
--2020-12-15 14:07:12--  https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.76.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.76.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6521 (6.4K) [text/plain]
Saving to: ‘bootstrap.sh’

bootstrap.sh              100%[==================================>]   6.37K  --.-KB/s    in 0s

2020-12-15 14:07:12 (102 MB/s) - ‘bootstrap.sh’ saved [6521/6521]

给脚本添加执行权限:

$ chmod +x bootstrap.sh

执行脚本,指定下载 v1.3.0 版本的相关工具:

$ ./bootstrap.sh 1.3.0 1.3.0
点击查看脚本执行结果
Clone hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo
Cloning into 'fabric-samples'...
remote: Enumerating objects: 6935, done.
remote: Total 6935 (delta 0), reused 0 (delta 0), pack-reused 6935
Receiving objects: 100% (6935/6935), 4.05 MiB | 2.07 MiB/s, done.
Resolving deltas: 100% (3608/3608), done.
===> Checking out v1.3.0 of hyperledger/fabric-samples

Pull Hyperledger Fabric binaries

===> Downloading version 1.3.0 platform specific fabric binaries
===> Downloading:  https://github.com/hyperledger/fabric/releases/download/v1.3.0/hyperledger-fabric-linux-amd64-1.3.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   667  100   667    0     0   1450      0 --:--:-- --:--:-- --:--:--  1450
100 43.3M  100 43.3M    0     0  2411k      0  0:00:18  0:00:18 --:--:-- 3436k
==> Done.
===> Downloading version 1.3.0 platform specific fabric-ca-client binary
===> Downloading:  https://github.com/hyperledger/fabric-ca/releases/download/v1.3.0/hyperledger-fabric-ca-linux-amd64-1.3.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   670  100   670    0     0   1196      0 --:--:-- --:--:-- --:--:--  1196
100 5109k  100 5109k    0     0  1602k      0  0:00:03  0:00:03 --:--:-- 2321k
==> Done.

Pull Hyperledger Fabric docker images

FABRIC_IMAGES: peer orderer ccenv tools
===> Pulling fabric Images
====> hyperledger/fabric-peer:1.3.0
1.3.0: Pulling from hyperledger/fabric-peer
3b37166ec614: Pull complete
504facff238f: Pull complete
ebbcacd28e10: Pull complete
c7fb3351ecad: Pull complete
2e3debadcbf7: Pull complete
8ff2951c3d3f: Pull complete
1fe35bf6bbad: Pull complete
9c1ac744ea5e: Pull complete
8bbadd32d9dc: Pull complete
2c5a546e366f: Pull complete
Digest: sha256:6756c7c48234ae6b0a8822a378681017cf6dbfeadfbf1f8a528ee6c4db343621
Status: Downloaded newer image for hyperledger/fabric-peer:1.3.0
docker.io/hyperledger/fabric-peer:1.3.0
====> hyperledger/fabric-orderer:1.3.0
1.3.0: Pulling from hyperledger/fabric-orderer
3b37166ec614: Already exists
504facff238f: Already exists
ebbcacd28e10: Already exists
c7fb3351ecad: Already exists
2e3debadcbf7: Already exists
8ff2951c3d3f: Already exists
1fe35bf6bbad: Already exists
9c1ac744ea5e: Already exists
245ee9cc02c1: Pull complete
d904630190ca: Pull complete
Digest: sha256:6ee1abcfd84031765d67544e5d6b4f3af08c3f064312c65715587d392fe7c3eb
Status: Downloaded newer image for hyperledger/fabric-orderer:1.3.0
docker.io/hyperledger/fabric-orderer:1.3.0
====> hyperledger/fabric-ccenv:1.3.0
1.3.0: Pulling from hyperledger/fabric-ccenv
3b37166ec614: Already exists
504facff238f: Already exists
ebbcacd28e10: Already exists
c7fb3351ecad: Already exists
2e3debadcbf7: Already exists
8ff2951c3d3f: Already exists
1fe35bf6bbad: Already exists
f3bda0ed3a94: Pull complete
bd61b4bf6419: Pull complete
e8dc2740dfec: Pull complete
4f3dcdea854d: Pull complete
bfb507a16746: Pull complete
9b1c9eb92240: Pull complete
f161031e61cc: Pull complete
Digest: sha256:05fce5513fcae3110ac041469ed9e0e4c9661f44782f52ef5d8930eb416c2197
Status: Downloaded newer image for hyperledger/fabric-ccenv:1.3.0
docker.io/hyperledger/fabric-ccenv:1.3.0
====> hyperledger/fabric-tools:1.3.0
1.3.0: Pulling from hyperledger/fabric-tools
3b37166ec614: Already exists
504facff238f: Already exists
ebbcacd28e10: Already exists
c7fb3351ecad: Already exists
2e3debadcbf7: Already exists
8ff2951c3d3f: Already exists
1fe35bf6bbad: Already exists
f3bda0ed3a94: Already exists
bd61b4bf6419: Already exists
e8dc2740dfec: Already exists
4f3dcdea854d: Already exists
8aa8fc04c03e: Pull complete
d5b255748f84: Pull complete
8c54f840b9e3: Pull complete
Digest: sha256:058cff3b378c1f3ebe35d56deb7bf33171bf19b327d91b452991509b8e9c7870
Status: Downloaded newer image for hyperledger/fabric-tools:1.3.0
docker.io/hyperledger/fabric-tools:1.3.0
===> Pulling fabric ca Image
====> hyperledger/fabric-ca:1.3.0
1.3.0: Pulling from hyperledger/fabric-ca
3b37166ec614: Already exists
504facff238f: Already exists
ebbcacd28e10: Already exists
c7fb3351ecad: Already exists
2e3debadcbf7: Already exists
8ff2951c3d3f: Already exists
1fe35bf6bbad: Already exists
439bddb5d064: Pull complete
2c28e4d49d97: Pull complete
457b98c91ee8: Pull complete
45b3e17861f4: Pull complete
2b1b8d679889: Pull complete
Digest: sha256:83abc367c5273a12d59ef9777637eb6c1abf04a5d00d66a0bffc55c40075850e
Status: Downloaded newer image for hyperledger/fabric-ca:1.3.0
docker.io/hyperledger/fabric-ca:1.3.0
===> List out hyperledger docker images
hyperledger/fabric-ca        1.3       5c6b20ba944f   2 years ago   244MB
hyperledger/fabric-ca        1.3.0     5c6b20ba944f   2 years ago   244MB
hyperledger/fabric-ca        latest    5c6b20ba944f   2 years ago   244MB
hyperledger/fabric-tools     1.3       c056cd9890e7   2 years ago   1.5GB
hyperledger/fabric-tools     1.3.0     c056cd9890e7   2 years ago   1.5GB
hyperledger/fabric-tools     latest    c056cd9890e7   2 years ago   1.5GB
hyperledger/fabric-ccenv     1.3       953124d80237   2 years ago   1.38GB
hyperledger/fabric-ccenv     1.3.0     953124d80237   2 years ago   1.38GB
hyperledger/fabric-ccenv     latest    953124d80237   2 years ago   1.38GB
hyperledger/fabric-orderer   1.3       f430f581b46b   2 years ago   145MB
hyperledger/fabric-orderer   1.3.0     f430f581b46b   2 years ago   145MB
hyperledger/fabric-orderer   latest    f430f581b46b   2 years ago   145MB
hyperledger/fabric-peer      1.3       f3ea63abddaa   2 years ago   151MB
hyperledger/fabric-peer      1.3.0     f3ea63abddaa   2 years ago   151MB
hyperledger/fabric-peer      latest    f3ea63abddaa   2 years ago   151MB

从以上脚本执行结果不难发现除了下载 v1.3.0 的 docker 镜像外,还下载相关二进制程序:

$ ll fabric-samples/bin
total 184944
-rwxrwxr-x 1 1001 1001 18551624 Oct 10  2018 configtxgen
-rwxrwxr-x 1 1001 1001 19693584 Oct 10  2018 configtxlator
-rwxrwxr-x 1 1001 1001 11909544 Oct 10  2018 cryptogen
-rwxrwxr-x 1 1001 1001 19532432 Oct 10  2018 discover
-rwxr-xr-x 1 1001 1001 22956616 Oct  1 03:51 fabric-ca-client
-rwxr-xr-x 1 1001 1001 30289504 Oct  1 03:52 fabric-ca-server
-rwxrwxr-x 1 1001 1001      810 Oct 10  2018 get-docker-images.sh
-rwxrwxr-x 1 1001 1001 10724192 Oct 10  2018 idemixgen
-rwxrwxr-x 1 1001 1001 23890528 Oct 10  2018 orderer
-rwxrwxr-x 1 1001 1001 31812608 Oct 10  2018 peer

将这些程序复制到 GOPATH/bin 路径下以供之后的开发使用:

$ cp fabric-samples/bin/* $GOPATH/bin

至此,fabric v1.3.0 的开发和测试环境就算搭建完毕,接下来就可以运行一个简单的测试网络来检验环境搭建是否成功。

3. 运行一个简单的 byfn 测试网

fabric-samples 目录下包含多个测试用例,最简单的测试用例即为 first-network 下的 byfn.sh 脚本的测试网络:

$ cd 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]
proceeding ...
LOCAL_VERSION=1.3.0
DOCKER_IMAGE_VERSION=1.3.0
/root/hyperledger/fabric-samples/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
+ res=0
+ set +x

/root/hyperledger/fabric-samples/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2020-12-22 16:58:04.720 CST [common/tools/configtxgen] main -> WARN 001 Omitting the channel ID for configtxgen for output operations is deprecated.  Explicitly passing the channel ID will be required in the future, defaulting to 'testchainid'.
2020-12-22 16:58:04.720 CST [common/tools/configtxgen] main -> INFO 002 Loading configuration
2020-12-22 16:58:04.749 CST [common/tools/configtxgen] doOutputBlock -> INFO 003 Generating genesis block
2020-12-22 16:58:04.750 CST [common/tools/configtxgen] doOutputBlock -> INFO 004 Writing genesis block
+ res=0
+ set +x

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2020-12-22 16:58:04.798 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2020-12-22 16:58:04.823 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2020-12-22 16:58:04.825 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 003 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-12-22 16:58:04.872 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2020-12-22 16:58:04.900 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2020-12-22 16:58:04.900 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-12-22 16:58:04.939 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2020-12-22 16:58:04.965 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2020-12-22 16:58:04.965 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x

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 orderer.example.com    ... done
Creating peer1.org2.example.com ... done
Creating peer1.org1.example.com ... done
Creating peer0.org1.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-12-22 08:58:08.849 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-12-22 08:58:08.883 UTC [cli/common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created =====================

Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-12-22 08:58:08.962 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-12-22 08:58:09.000 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-12-22 08:58:12.085 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-12-22 08:58:12.123 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-12-22 08:58:15.212 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-12-22 08:58:15.255 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-12-22 08:58:18.333 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-12-22 08:58:18.369 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-12-22 08:58:21.447 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-12-22 08:58:21.458 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-12-22 08:58:24.535 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-12-22 08:58:24.547 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-12-22 08:58:27.630 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-12-22 08:58:27.630 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-12-22 08:58:27.841 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
2020-12-22 08:58:27.920 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-12-22 08:58:27.920 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-12-22 08:58:28.112 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
2020-12-22 08:58:28.195 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-12-22 08:58:28.195 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'... =====================
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Attempting to Query peer0.org1 ...3 secs
+ 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-12-22 08:59:01.751 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-12-22 08:59:01.833 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-12-22 08:59:01.833 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-12-22 08:59:02.046 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'... =====================
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Attempting to Query peer1.org2 ...3 secs
+ res=0
+ set +x

90
===================== Query successful on peer1.org2 on channel 'mychannel' =====================

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


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

从上面的运行结果可发现 fabric 环境搭建成功,同时后台正在运行一个由多个容器组成的测试网,可查看容器状态:

$ docker ps
CONTAINER ID   IMAGE                                                                                                  COMMAND                  CREATED              STATUS              PORTS                                              NAMES
0d491d9af2ab   dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab   "chaincode -peer.add…"   About a minute ago   Up About a minute                                                      dev-peer1.org2.example.com-mycc-1.0
adcc2532ea01   dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9   "chaincode -peer.add…"   About a minute ago   Up About a minute                                                      dev-peer0.org1.example.com-mycc-1.0
90fb7eaa241e   dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b   "chaincode -peer.add…"   About a minute ago   Up About a minute                                                      dev-peer0.org2.example.com-mycc-1.0
06fd0733952b   hyperledger/fabric-tools:latest                                                                        "/bin/bash"              2 minutes ago        Up 2 minutes                                                           cli
86f35856f630   hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes        0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
6683350bd5ba   hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes        0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com
84b00d07df34   hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes        0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
046558652c66   hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes        0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
c0769f29999b   hyperledger/fabric-orderer:latest                                                                      "orderer"                2 minutes ago        Up 2 minutes        0.0.0.0:7050->7050/tcp                             orderer.example.com

想要停止测试网也很简单:

$ ./byfn.sh down
点击查看脚本执行结果
Stopping for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n]
proceeding ...
Stopping cli                    ... done
Stopping peer1.org1.example.com ... done
Stopping peer0.org1.example.com ... done
Stopping peer1.org2.example.com ... done
Stopping peer0.org2.example.com ... done
Stopping orderer.example.com    ... done
Removing cli                    ... done
Removing peer1.org1.example.com ... done
Removing peer0.org1.example.com ... done
Removing peer1.org2.example.com ... done
Removing peer0.org2.example.com ... done
Removing orderer.example.com    ... done
Removing network net_byfn
Removing volume net_orderer.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_peer1.org1.example.com
Removing volume net_peer0.org2.example.com
Removing volume net_peer1.org2.example.com
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.
0d491d9af2ab
adcc2532ea01
90fb7eaa241e
Untagged: dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab:latest
Deleted: sha256:c429727b979706dfc6eddf82e2938e8d450cb08097e9d5de6b71a398f0a3160a
Deleted: sha256:53f46be463bfc6eda48964fd9258402f18bef463523dedcddeced57f0976f6af
Deleted: sha256:d52ef5e6b976d0f9611f4a8e266ee156662165bdc0d8bd015010b898249a72cb
Deleted: sha256:8cd50d43c21f01469a48085a851df1327068e9c6d61818f7679501611e755c03
Untagged: dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9:latest
Deleted: sha256:1e8ab6007eab1542f9d1963d6cfb434c4b13e4e723c44c3f7e0b820f223b3499
Deleted: sha256:dadb5ad33ad330a0113cf3ab2aa264d9508b1043d2495c69d62161f08d0c8d67
Deleted: sha256:d12ba73262a090d3142ea2dbe3c788f6c1b669449cc45e575a9c4a8d54e2f3d0
Deleted: sha256:b8c6e9529351ed44fae47e62c0b0a1a0103d8d1dc03192f0c913a2afae4b1865
Untagged: dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latest
Deleted: sha256:981325df75500ce39d8c3b5caa09b4620bd5fe56c07c2a641c8e0b1aeb793487
Deleted: sha256:bbad1e5da01ee190fbfef8c76863a8253e7a3dad3b4511a7e450fea307c2a211
Deleted: sha256:69dfd4702a9dca81b474fc8966248c164ee3bd650d94e0cabe26f4190666e32c
Deleted: sha256:fb45098007c68bdc6031e15829926dd76ede880e925cb8b029f1553e5295fd2f

4. 参考资料

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值