hyperledger环境搭建(mac11.1、ubunt20)

 

目录

1 准备工作

2 mac部署hyperledger Fabric

2.1 安装docker

2.2 安装golang

2.3 安装node.js

2.4 mac部署hyperledger的坑

2.4.1 坑1:curl脚本安装失败

2.4.2 坑2:两个安装包下载超级慢

2.4.3 坑3:docker拉取镜像巨慢

扫描二维码关注公众号,回复: 13713545 查看本文章

2.4.4 Docker版本过高,无法启动first-network

2.4.5 下载并执行fabric的引导脚本init.sh

2.4.6 启动下载

2.4.7 拉取的docker镜像含义

2.4.8 设置全局访问上述工具命令

2.5 First-Network 环境测试

2.5.1 生成相应文件

2.5.2 启动网路(第一次失败及解决)

2.5.3 部署完成,显示END

2.5.4 查看服务/停止服务

3 ubuntu20 部署hyperledger Fabric

3.1 前置条件docker,golang,node.js

3.1.1 ubuntu Docker 配置镜像加速器

3.2 部署hyperledger

3.2.1 bash init.sh 1.2.0 1.2.0 0.4.10

3.2.2 添加全局命令

3.2.3 启动测试

3.2.4 启动测试网络失败及解决

3.2.5 重新启动服务,测试成功


1 准备工作

写在开头——推荐ubuntu,环境搭建比Mac块

官方帮助文档,可以点左下角切换版本:

https://hyperledger-fabric.readthedocs.io/en/release-1.2/

github: https://github.com/hyperledger

环境文件:https://github.com/hyperledger/fabric-samples

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

安装docker,docker --version 查询版本

安装docker-compose,docker-compose --version 查询版本

安装 go 语言环境,go version 查询版本

安装node.js, node -v 查询版本

Python 版本要求为 2.7,python --version 查询版本

启动脚本:

https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh

本文用到的文件:

hyperledger-fabric-linux-amd64-1.2.0.tar.gz

hyperledger-fabric-ca-linux-amd64-1.2.0.tar.gz

hyperledger-fabric-darwin-amd64-1.4.0.tar.gz

hyperledger-fabric-ca-darwin-amd64-1.4.0.tar.gz

DockerForMac18.03.0.dmg

链接: https://pan.baidu.com/s/19Zfknu-a8Ze6srzQK4wwEg  密码: n97e

2 mac部署hyperledger Fabric

2.1 安装docker

注意,如果使用Fabric1.4,一定使用这个版本18.03.0-ce,否则无法启动。

安装过程忽略,请自行查找。

➜  first-network git:(bb39b6e) docker version
Client:
 Version:	18.03.0-ce
 API version:	1.37
 Go version:	go1.9.4
 Git commit:	0520e24
 Built:	Wed Mar 21 23:06:22 2018
 OS/Arch:	darwin/amd64
 Experimental:	false
 Orchestrator:	swarm

Server:
 Engine:
  Version:	18.03.0-ce
  API version:	1.37 (minimum version 1.12)
  Go version:	go1.9.4
  Git commit:	0520e24
  Built:	Wed Mar 21 23:14:32 2018
  OS/Arch:	linux/amd64
  Experimental:	true
➜  first-network git:(bb39b6e)

2.2 安装golang

安装过程忽略,请自行查找。

➜  first-network git:(bb39b6e) go version
go version go1.15.6 darwin/amd64

2.3 安装node.js

安装过程忽略,请自行查找。

➜  first-network git:(bb39b6e) node -v       
v12.18.3
➜  first-network git:(bb39b6e) 

2.4 mac部署hyperledger的坑

1.mac搭建hyperLedger,下载没问题,就是测试first-network怎么都无法启动。

2.使用hyperledger 1.4,一个因为新版github下载巨慢,二是旧版网上可能用别人遇到的各种坑,能轻松找到类似问题的解决方案。

MacOS最新版系统11.1。

安装部署过程中遇到一些坑及解决。

2.4.1 坑1:curl脚本安装失败

barry@u20:~/hyperledger-fabric$ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh|
bash -s 1.4.0 1.4.0 0.4.10 
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

解决方案:

https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh

启动脚本赋值粘贴到本地,保存为init.sh

2.4.2 坑2:两个安装包下载超级慢

barry@u20:~/hyperledger-fabric$ ./int.sh 1.4.0 1.4.0 0.4.10
//下载巨慢,这个搞的心态有点崩,此处忽略一万字。

解决方案:下载两个离线包,保存到本地

hyperledger-fabric-ca-darwin-amd64-1.4.0.tar.gz

hyperledger-fabric-darwin-amd64-1.4.0.tar.gz

2.4.3 坑3:docker拉取镜像巨慢

解决方案

1.docker源添加阿里源

Mac环境

在任务栏点击 Docker Desktop 应用图标 -> Perferences,在左侧导航菜单选择 Docker Engine,在右侧输入栏编辑 json 文件。将

https://gv1tx6mh.mirror.aliyuncs.com加到"registry-mirrors"的数组里,点击 Apply & Restart按钮,等待Docker重启并应用配置的镜像加速器。

2.4.4 Docker版本过高,无法启动first-network

解决方案:

降级,使用docker 18.03.0(资源在开头的网盘中)。

2.4.5 下载并执行fabric的引导脚本init.sh

网页打开网页,将shell脚本保存到本地

https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh

1.启动脚本赋值粘贴到本地,保存为init.sh

2.注释掉二进制下载 pullBinaries,并修改VERSION,CA_VERSION版本号。

➜  ~ cd $HOME
➜  ~ pwd
/Users/Barry
➜  ~ mkdir hyperledger-fabric
➜  ~ cd hyperledger-fabric 
➜  hyperledger-fabric vi init.sh

修改后的脚本如下:

#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

# if version not passed in, default to latest released version
VERSION=1.4.0
# if ca version not passed in, default to latest released version
CA_VERSION=1.4.0
ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')")
MARCH=$(uname -m)

printHelp() {
    echo "Usage: bootstrap.sh [version [ca_version]] [options]"
    echo
    echo "options:"
    echo "-h : this help"
    echo "-d : bypass docker image download"
    echo "-s : bypass fabric-samples repo clone"
    echo "-b : bypass download of platform-specific binaries"
    echo
    echo "e.g. bootstrap.sh 2.3.0 1.4.9 -s"
    echo "will download docker images and binaries for Fabric v2.3.0 and Fabric CA v1.4.9"
}

# dockerPull() pulls docker images from fabric and chaincode repositories
# note, if a docker image doesn't exist for a requested release, it will simply
# be skipped, since this script doesn't terminate upon errors.

dockerPull() {
    #three_digit_image_tag is passed in, e.g. "1.4.7"
    three_digit_image_tag=$1
    shift
    #two_digit_image_tag is derived, e.g. "1.4", especially useful as a local tag for two digit references to most recent baseos, ccenv, javaenv, nodeenv patch releases
    two_digit_image_tag=$(echo "$three_digit_image_tag" | cut -d'.' -f1,2)
    while [[ $# -gt 0 ]]
    do
        image_name="$1"
        echo "====> hyperledger/fabric-$image_name:$three_digit_image_tag"
        docker pull "hyperledger/fabric-$image_name:$three_digit_image_tag"
        docker tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name"
        docker tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name:$two_digit_image_tag"
        shift
    done
}

cloneSamplesRepo() {
    # clone (if needed) hyperledger/fabric-samples and checkout corresponding
    # version to the binaries and docker images to be downloaded
    if [ -d first-network ]; then
        # if we are in the fabric-samples repo, checkout corresponding version
        echo "==> Already in fabric-samples repo"
    elif [ -d fabric-samples ]; then
        # if fabric-samples repo already cloned and in current directory,
        # cd fabric-samples
        echo "===> Changing directory to fabric-samples"
        cd fabric-samples
    else
        echo "===> Cloning hyperledger/fabric-samples repo"
        git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples
    fi

    if GIT_DIR=.git git rev-parse v${VERSION} >/dev/null 2>&1; then
        echo "===> Checking out v${VERSION} of hyperledger/fabric-samples"
        git checkout -q v${VERSION}
    else
        echo "fabric-samples v${VERSION} does not exist, defaulting master"
        git checkout -q master
    fi
}

# This will download the .tar.gz
download() {
    local BINARY_FILE=$1
    local URL=$2
    echo "===> Downloading: " "${URL}"
    curl -L --retry 5 --retry-delay 3 "${URL}" | tar xz || rc=$?
    if [ -n "$rc" ]; then
        echo "==> There was an error downloading the binary file."
        return 22
    else
        echo "==> Done."
    fi
}

pullBinaries() {
    echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries"
    download "${BINARY_FILE}" "https://github.com/hyperledger/fabric/releases/download/v${VERSION}/${BINARY_FILE}"
    if [ $? -eq 22 ]; then
        echo
        echo "------> ${FABRIC_TAG} platform specific fabric binary is not available to download <----"
        echo
        exit
    fi

    echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary"
    download "${CA_BINARY_FILE}" "https://github.com/hyperledger/fabric-ca/releases/download/v${CA_VERSION}/${CA_BINARY_FILE}"
    if [ $? -eq 22 ]; then
        echo
        echo "------> ${CA_TAG} fabric-ca-client binary is not available to download  (Available from 1.1.0-rc1) <----"
        echo
        exit
    fi
}

pullDockerImages() {
    command -v docker >& /dev/null
    NODOCKER=$?
    if [ "${NODOCKER}" == 0 ]; then
        FABRIC_IMAGES=(peer orderer ccenv tools)
        case "$VERSION" in
        2.*)
            FABRIC_IMAGES+=(baseos)
            shift
            ;;
        esac
        echo "FABRIC_IMAGES:" "${FABRIC_IMAGES[@]}"
        echo "===> Pulling fabric Images"
        dockerPull "${FABRIC_TAG}" "${FABRIC_IMAGES[@]}"
        echo "===> Pulling fabric ca Image"
        CA_IMAGE=(ca)
        dockerPull "${CA_TAG}" "${CA_IMAGE[@]}"
        echo "===> List out hyperledger docker images"
        docker images | grep hyperledger
    else
        echo "========================================================="
        echo "Docker not installed, bypassing download of Fabric images"
        echo "========================================================="
    fi
}

DOCKER=true
SAMPLES=true
BINARIES=true

# Parse commandline args pull out
# version and/or ca-version strings first
if [ -n "$1" ] && [ "${1:0:1}" != "-" ]; then
    VERSION=$1;shift
    if [ -n "$1" ]  && [ "${1:0:1}" != "-" ]; then
        CA_VERSION=$1;shift
        if [ -n  "$1" ] && [ "${1:0:1}" != "-" ]; then
            THIRDPARTY_IMAGE_VERSION=$1;shift
        fi
    fi
fi

# prior to 1.2.0 architecture was determined by uname -m
if [[ $VERSION =~ ^1\.[0-1]\.* ]]; then
    export FABRIC_TAG=${MARCH}-${VERSION}
    export CA_TAG=${MARCH}-${CA_VERSION}
    export THIRDPARTY_TAG=${MARCH}-${THIRDPARTY_IMAGE_VERSION}
else
    # starting with 1.2.0, multi-arch images will be default
    : "${CA_TAG:="$CA_VERSION"}"
    : "${FABRIC_TAG:="$VERSION"}"
    : "${THIRDPARTY_TAG:="$THIRDPARTY_IMAGE_VERSION"}"
fi

BINARY_FILE=hyperledger-fabric-${ARCH}-${VERSION}.tar.gz
CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH}-${CA_VERSION}.tar.gz

# then parse opts
while getopts "h?dsb" opt; do
    case "$opt" in
        h|\?)
            printHelp
            exit 0
            ;;
        d)  DOCKER=false
            ;;
        s)  SAMPLES=false
            ;;
        b)  BINARIES=false
            ;;
    esac
done

if [ "$SAMPLES" == "true" ]; then
    echo
    echo "Clone hyperledger/fabric-samples repo"
    echo
    cloneSamplesRepo
fi
if [ "$BINARIES" == "true" ]; then
    echo
    echo "Pull Hyperledger Fabric binaries"
    echo
    #pullBinaries
fi
if [ "$DOCKER" == "true" ]; then
    echo
    echo "Pull Hyperledger Fabric docker images"
    echo
    pullDockerImages
fi

2.4.6 启动下载

./init.sh 1.4.0 1.4.0 0.4.10

➜  hyperledger-fabric ./init.sh 1.4.0 1.4.0 0.4.10

Clone hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo
正克隆到 'fabric-samples'...
remote: Enumerating objects: 7068, done.
remote: Total 7068 (delta 0), reused 0 (delta 0), pack-reused 7068
接收对象中: 100% (7068/7068), 4.09 MiB | 18.00 KiB/s, 完成.
处理 delta 中: 100% (3685/3685), 完成.
===> Checking out v1.4.0 of hyperledger/fabric-samples

Pull Hyperledger Fabric binaries


Pull Hyperledger Fabric docker images

FABRIC_IMAGES: peer orderer ccenv tools
===> Pulling fabric Images
====> hyperledger/fabric-peer:1.4.0
1.4.0: Pulling from hyperledger/fabric-peer
Digest: sha256:9707c97f787de1d4d6dd60994d6b8ea2e5cc28b0f42e6849df3fb41c64b41372
Status: Image is up to date for hyperledger/fabric-peer:1.4.0
docker.io/hyperledger/fabric-peer:1.4.0
====> hyperledger/fabric-orderer:1.4.0
1.4.0: Pulling from hyperledger/fabric-orderer
Digest: sha256:644265186b4887c7d9dcb91895124ccead3c0125c2c4f9eadc421dc9555d7495
Status: Image is up to date for hyperledger/fabric-orderer:1.4.0
docker.io/hyperledger/fabric-orderer:1.4.0
====> hyperledger/fabric-ccenv:1.4.0
1.4.0: Pulling from hyperledger/fabric-ccenv
Digest: sha256:6d797cac9fd39d4c9964fbcf02e47137ce8ae321af60832c41d511f0c7ed4d3e
Status: Image is up to date for hyperledger/fabric-ccenv:1.4.0
docker.io/hyperledger/fabric-ccenv:1.4.0
====> hyperledger/fabric-tools:1.4.0
1.4.0: Pulling from hyperledger/fabric-tools
Digest: sha256:aee256916d0cb938d8023fa32ed2745991d32cfe79018e360f1720707ebfbdb5
Status: Image is up to date for hyperledger/fabric-tools:1.4.0
docker.io/hyperledger/fabric-tools:1.4.0
===> Pulling fabric ca Image
====> hyperledger/fabric-ca:1.4.0
1.4.0: Pulling from hyperledger/fabric-ca
Digest: sha256:c1dce534d9e9202697e0aaad7c5521d958700fda0b05127dafb9333c22e15f74
Status: Image is up to date for hyperledger/fabric-ca:1.4.0
docker.io/hyperledger/fabric-ca:1.4.0
===> List out hyperledger docker images
hyperledger/fabric-peer      <none>              b31292eb8166        5 months ago        135MB
hyperledger/fabric-tools     1.4                 0a44f4261a55        2 years ago         1.56GB
hyperledger/fabric-tools     1.4.0               0a44f4261a55        2 years ago         1.56GB
hyperledger/fabric-tools     latest              0a44f4261a55        2 years ago         1.56GB
hyperledger/fabric-ccenv     1.4                 5b31d55f5f3a        2 years ago         1.43GB
hyperledger/fabric-ccenv     1.4.0               5b31d55f5f3a        2 years ago         1.43GB
hyperledger/fabric-ccenv     latest              5b31d55f5f3a        2 years ago         1.43GB
hyperledger/fabric-orderer   1.4                 54f372205580        2 years ago         150MB
hyperledger/fabric-orderer   1.4.0               54f372205580        2 years ago         150MB
hyperledger/fabric-orderer   latest              54f372205580        2 years ago         150MB
hyperledger/fabric-peer      1.4                 304fac59b501        2 years ago         157MB
hyperledger/fabric-peer      1.4.0               304fac59b501        2 years ago         157MB
hyperledger/fabric-peer      latest              304fac59b501        2 years ago         157MB
hyperledger/fabric-ca        1.4                 1a804ab74f58        2 years ago         244MB
hyperledger/fabric-ca        1.4.0               1a804ab74f58        2 years ago         244MB
hyperledger/fabric-ca        latest              1a804ab74f58        2 years ago         244MB
➜  hyperledger-fabric ls

2.4.7 拉取的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

2.4.8 设置全局访问上述工具命令

解压两个离线包,cp到fabric-samples

hyperledger-fabric-ca-darwin-amd64-1.4.0.tar.gz 

hyperledger-fabric-darwin-amd64-1.4.0.tar.gz

/Users/Barry/hyperledger-fabric
➜  hyperledger-fabric ls
fabric-samples                                  hyperledger-fabric-darwin-amd64-1.4.0           init.sh
hyperledger-fabric-ca-darwin-amd64-1.4.0.tar.gz hyperledger-fabric-darwin-amd64-1.4.0.tar.gz
# 进入到 ~/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的这些可执行程序就可以在全局范围内使用了

2.5 First-Network 环境测试

2.5.1 生成相应文件

执行 ./byfn.sh generate 命令生成相应的文件

➜  first-network git:(bb39b6e) ✗ ./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] 
proceeding ...
/Users/Barry/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

/Users/Barry/hyperledger-fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2021-01-16 11:55:21.378 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 11:55:21.412 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2021-01-16 11:55:21.412 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.438 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2021-01-16 11:55:21.438 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.441 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2021-01-16 11:55:21.442 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
+ set +x

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2021-01-16 11:55:21.477 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 11:55:21.506 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.534 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-16 11:55:21.534 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.534 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2021-01-16 11:55:21.537 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 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
2021-01-16 11:55:21.574 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 11:55:21.603 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.634 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-16 11:55:21.634 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.634 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2021-01-16 11:55:21.634 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 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
2021-01-16 11:55:21.670 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 11:55:21.715 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.769 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-16 11:55:21.769 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 11:55:21.769 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2021-01-16 11:55:21.769 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x

2.5.2 启动网路(第一次失败及解决)

降级docker到18,删除fabric-samples,重新下载,启动成功,问题解决。

执行 ./byfn.sh up 启动网络

第一次失败打印如下

irst-network git:(bb39b6e) ✗ ./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.4.0
DOCKER_IMAGE_VERSION=1.4.8
=================== WARNING ===================
  Local fabric binaries and docker images are  
  out of  sync. This may cause problems.       
===============================================
/Users/Barry/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

/Users/Barry/hyperledger-fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2021-01-15 18:21:51.370 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-15 18:21:51.425 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2021-01-15 18:21:51.425 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.459 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2021-01-15 18:21:51.460 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.469 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2021-01-15 18:21:51.470 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
+ set +x

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2021-01-15 18:21:51.509 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-15 18:21:51.539 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.571 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-15 18:21:51.571 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.571 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2021-01-15 18:21:51.573 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 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
2021-01-15 18:21:51.610 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-15 18:21:51.645 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.677 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-15 18:21:51.677 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.677 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2021-01-15 18:21:51.677 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 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
2021-01-15 18:21:51.716 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-15 18:21:51.743 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.776 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-15 18:21:51.776 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-15 18:21:51.776 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2021-01-15 18:21:51.777 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 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
Pulling orderer.example.com (hyperledger/fabric-orderer:latest)...
latest: Pulling from hyperledger/fabric-orderer
b8f262c62ec6: Pull complete
db9dbc6799b3: Pull complete
9c5c884a6020: Pull complete
41da273e0290: Pull complete
18fab9c57926: Pull complete
e8a2868a41d8: Pull complete
Digest: sha256:128cf1bca9368b38a401cbd06433852865fa2f1f7fecce160f43f5b5f2a293cf
Status: Downloaded newer image for hyperledger/fabric-orderer:latest
Pulling peer0.org1.example.com (hyperledger/fabric-peer:latest)...
latest: Pulling from hyperledger/fabric-peer
b8f262c62ec6: Already exists
db9dbc6799b3: Already exists
9c5c884a6020: Already exists
41da273e0290: Already exists
7e97b499c946: Pull complete
e1385183f793: Pull complete
Digest: sha256:ec8724d02e63f87f5439dbef240d7a6f34f0c0944b570af661af52882b5c8812
Status: Downloaded newer image for hyperledger/fabric-peer:latest
Creating peer0.org2.example.com ... done
Creating peer1.org2.example.com ... done
Creating peer1.org1.example.com ... done
Creating orderer.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
2021-01-15 10:22:13.628 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 10:22:13.669 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
2021-01-15 10:22:13.751 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 10:22:13.789 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
2021-01-15 10:22:16.858 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 10:22:16.907 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
2021-01-15 10:22:20.022 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 10:22:20.063 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
2021-01-15 10:22:23.172 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 10:22:23.216 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
2021-01-15 10:22:26.294 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 10:22:26.318 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
2021-01-15 10:22:29.431 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 10:22:29.460 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
2021-01-15 10:22:32.555 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-15 10:22:32.556 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-15 10:22:33.124 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
2021-01-15 10:22:33.223 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-15 10:22:33.223 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-15 10:22:33.443 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=1
+ set +x
2021-01-15 10:22:33.541 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-15 10:22:33.541 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Post http://unix.sock/containers/create?name=dev-peer0.org2.example.com-mycc-1.0: dial unix /host/var/run/docker.sock: connect: no such file or directory
!!!!!!!!!!!!!!! Chaincode instantiation on peer0.org2 on channel 'mychannel' failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========

ERROR !!!! Test failed

2.5.3 部署完成,显示END

降级docker 后启动成功,删除文件文件夹fabric-samples 重新init

./init.sh 1.4.0 1.4.0 0.4.10

执行结束,显示END

➜  hyperledger-fabric ./init.sh 1.4.0 1.4.0 0.4.10

Clone hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo
正克隆到 'fabric-samples'...
remote: Enumerating objects: 7068, done.
remote: Total 7068 (delta 0), reused 0 (delta 0), pack-reused 7068
接收对象中: 100% (7068/7068), 4.09 MiB | 16.00 KiB/s, 完成.
处理 delta 中: 100% (3684/3684), 完成.
===> Checking out v1.4.0 of hyperledger/fabric-samples

Pull Hyperledger Fabric binaries


Pull Hyperledger Fabric docker images

FABRIC_IMAGES: peer orderer ccenv tools
===> Pulling fabric Images
====> hyperledger/fabric-peer:1.4.0
1.4.0: Pulling from hyperledger/fabric-peer
3b37166ec614: Pull complete 
504facff238f: Pull complete 
ebbcacd28e10: Pull complete 
c7fb3351ecad: Pull complete 
2e3debadcbf7: Pull complete 
fc435e46e32e: Pull complete 
a4922bafdce8: Pull complete 
7d9964965066: Pull complete 
625153a09c48: Pull complete 
291344806a10: Pull complete 
Digest: sha256:9707c97f787de1d4d6dd60994d6b8ea2e5cc28b0f42e6849df3fb41c64b41372
Status: Downloaded newer image for hyperledger/fabric-peer:1.4.0
====> hyperledger/fabric-orderer:1.4.0
1.4.0: Pulling from hyperledger/fabric-orderer
3b37166ec614: Already exists 
504facff238f: Already exists 
ebbcacd28e10: Already exists 
c7fb3351ecad: Already exists 
2e3debadcbf7: Already exists 
fc435e46e32e: Already exists 
a4922bafdce8: Already exists 
7d9964965066: Already exists 
1aa1f5822ea4: Pull complete 
f3adcb95411e: Pull complete 
Digest: sha256:644265186b4887c7d9dcb91895124ccead3c0125c2c4f9eadc421dc9555d7495
Status: Downloaded newer image for hyperledger/fabric-orderer:1.4.0
====> hyperledger/fabric-ccenv:1.4.0
1.4.0: Pulling from hyperledger/fabric-ccenv
3b37166ec614: Already exists 
504facff238f: Already exists 
ebbcacd28e10: Already exists 
c7fb3351ecad: Already exists 
2e3debadcbf7: Already exists 
fc435e46e32e: Already exists 
a4922bafdce8: Already exists 
14675a1189ca: Pull complete 
33f930d7053e: Pull complete 
7aa21e006739: Pull complete 
806ba27e29bb: Pull complete 
0292b0ff822a: Pull complete 
5d4ce0f5fd82: Pull complete 
3bde20c14104: Pull complete 
Digest: sha256:6d797cac9fd39d4c9964fbcf02e47137ce8ae321af60832c41d511f0c7ed4d3e
Status: Downloaded newer image for hyperledger/fabric-ccenv:1.4.0
====> hyperledger/fabric-tools:1.4.0
1.4.0: Pulling from hyperledger/fabric-tools
3b37166ec614: Already exists 
504facff238f: Already exists 
ebbcacd28e10: Already exists 
c7fb3351ecad: Already exists 
2e3debadcbf7: Already exists 
fc435e46e32e: Already exists 
a4922bafdce8: Already exists 
14675a1189ca: Already exists 
33f930d7053e: Already exists 
7aa21e006739: Already exists 
806ba27e29bb: Already exists 
72b2b3c78600: Pull complete 
f36a6f470154: Pull complete 
19fc6d1044df: Pull complete 
Digest: sha256:aee256916d0cb938d8023fa32ed2745991d32cfe79018e360f1720707ebfbdb5
Status: Downloaded newer image for hyperledger/fabric-tools:1.4.0
===> Pulling fabric ca Image
====> hyperledger/fabric-ca:1.4.0
1.4.0: Pulling from hyperledger/fabric-ca
3b37166ec614: Already exists 
504facff238f: Already exists 
ebbcacd28e10: Already exists 
c7fb3351ecad: Already exists 
2e3debadcbf7: Already exists 
fc435e46e32e: Already exists 
a4922bafdce8: Already exists 
c8ec0cae397c: Pull complete 
3153e2e7116e: Pull complete 
d84abf263d15: Pull complete 
45ff112943d3: Pull complete 
c4678d50bc7a: Pull complete 
Digest: sha256:c1dce534d9e9202697e0aaad7c5521d958700fda0b05127dafb9333c22e15f74
Status: Downloaded newer image for hyperledger/fabric-ca:1.4.0
===> List out hyperledger docker images
hyperledger/fabric-tools     <none>              e642eef94cae        5 months ago        1.5GB
hyperledger/fabric-tools     1.4                 0a44f4261a55        2 years ago         1.56GB
hyperledger/fabric-tools     1.4.0               0a44f4261a55        2 years ago         1.56GB
hyperledger/fabric-tools     latest              0a44f4261a55        2 years ago         1.56GB
hyperledger/fabric-ccenv     1.4                 5b31d55f5f3a        2 years ago         1.43GB
hyperledger/fabric-ccenv     1.4.0               5b31d55f5f3a        2 years ago         1.43GB
hyperledger/fabric-ccenv     latest              5b31d55f5f3a        2 years ago         1.43GB
hyperledger/fabric-orderer   1.4                 54f372205580        2 years ago         150MB
hyperledger/fabric-orderer   1.4.0               54f372205580        2 years ago         150MB
hyperledger/fabric-orderer   latest              54f372205580        2 years ago         150MB
hyperledger/fabric-peer      1.4                 304fac59b501        2 years ago         157MB
hyperledger/fabric-peer      1.4.0               304fac59b501        2 years ago         157MB
hyperledger/fabric-peer      latest              304fac59b501        2 years ago         157MB
hyperledger/fabric-ca        1.4                 1a804ab74f58        2 years ago         244MB
hyperledger/fabric-ca        1.4.0               1a804ab74f58        2 years ago         244MB
hyperledger/fabric-ca        latest              1a804ab74f58        2 years ago         244MB
➜  hyperledger-fabric 
➜  hyperledger-fabric 
➜  hyperledger-fabric ls                          
fabric-samples                                  hyperledger-fabric-ca-darwin-amd64-1.4.0.tar.gz init.sh
fabric-samples-bak                              hyperledger-fabric-darwin-amd64-1.4.0
fabric-samples-err1                             hyperledger-fabric-darwin-amd64-1.4.0.tar.gz
➜  hyperledger-fabric cd fabric-samples
➜  fabric-samples git:(bb39b6e) ls
CODE_OF_CONDUCT.md       LICENSE                  balance-transfer         chaincode                config                   high-throughput
CONTRIBUTING.md          MAINTAINERS.md           basic-network            chaincode-docker-devmode fabcar                   interest_rate_swaps
Jenkinsfile              README.md                bin                      commercial-paper         first-network            scripts
➜  fabric-samples git:(bb39b6e) 
➜  fabric-samples git:(bb39b6e) 
➜  fabric-samples git:(bb39b6e) 
➜  fabric-samples git:(bb39b6e) cd first-network 
➜  first-network git:(bb39b6e) ls
README.md                        configtx.yaml                    docker-compose-couch.yaml        eyfn.sh
base                             crypto-config.yaml               docker-compose-e2e-template.yaml org3-artifacts
byfn.sh                          docker-compose-cli.yaml          docker-compose-kafka.yaml        scripts
channel-artifacts                docker-compose-couch-org3.yaml   docker-compose-org3.yaml
➜  first-network git:(bb39b6e) 
➜  first-network git:(bb39b6e) 
➜  first-network git:(bb39b6e) 
➜  first-network git:(bb39b6e) ./byfn.sh 
Usage: 
  byfn.sh <mode> [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-l <language>] [-o <consensus-type>] [-i <imagetag>] [-v]
    <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'
      - 'up' - bring up the network with docker-compose up
      - 'down' - clear the network with docker-compose down
      - 'restart' - restart the network
      - 'generate' - generate required certificates and genesis block
      - 'upgrade'  - upgrade the network from version 1.3.x to 1.4.0
    -c <channel name> - channel name to use (defaults to "mychannel")
    -t <timeout> - CLI timeout duration in seconds (defaults to 10)
    -d <delay> - delay duration in seconds (defaults to 3)
    -f <docker-compose-file> - specify which docker-compose file use (defaults to docker-compose-cli.yaml)
    -s <dbtype> - the database backend to use: goleveldb (default) or couchdb
    -l <language> - the chaincode language: golang (default) or node
    -o <consensus-type> - the consensus-type of the ordering service: solo (default) or kafka
    -i <imagetag> - the tag to be used to launch the network (defaults to "latest")
    -v - verbose mode
  byfn.sh -h (print this message)

Typically, one would first generate the required certificates and 
genesis block, then bring up the network. e.g.:

	byfn.sh generate -c mychannel
	byfn.sh up -c mychannel -s couchdb
        byfn.sh up -c mychannel -s couchdb -i 1.4.0
	byfn.sh up -l node
	byfn.sh down -c mychannel
        byfn.sh upgrade -c mychannel

Taking all defaults:
	byfn.sh generate
	byfn.sh up
	byfn.sh down
➜  first-network git:(bb39b6e) ./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] 
proceeding ...
/Users/Barry/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

/Users/Barry/hyperledger-fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2021-01-16 20:43:31.693 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 20:43:31.724 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2021-01-16 20:43:31.724 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:31.751 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2021-01-16 20:43:31.751 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:31.755 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2021-01-16 20:43:31.756 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
+ set +x

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2021-01-16 20:43:31.806 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 20:43:31.840 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:31.869 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-16 20:43:31.869 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:31.869 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2021-01-16 20:43:31.873 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 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
2021-01-16 20:43:31.907 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 20:43:31.936 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:31.963 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-16 20:43:31.963 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:31.963 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2021-01-16 20:43:31.964 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 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
2021-01-16 20:43:32.003 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2021-01-16 20:43:32.034 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:32.067 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2021-01-16 20:43:32.067 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/Barry/hyperledger-fabric/fabric-samples/first-network/configtx.yaml
2021-01-16 20:43:32.067 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2021-01-16 20:43:32.067 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x

➜  first-network git:(bb39b6e) ./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.4.0
DOCKER_IMAGE_VERSION=1.4.0
Creating peer1.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating orderer.example.com    ... done
Creating peer1.org2.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
2021-01-16 12:44:05.563 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-16 12:44:05.616 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
2021-01-16 12:44:05.739 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-16 12:44:05.797 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
2021-01-16 12:44:08.944 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-16 12:44:08.998 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
2021-01-16 12:44:12.116 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-16 12:44:12.171 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
2021-01-16 12:44:15.295 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-16 12:44:15.356 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
2021-01-16 12:44:18.484 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-16 12:44:18.505 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
2021-01-16 12:44:21.654 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-16 12:44:21.676 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
2021-01-16 12:44:24.815 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-16 12:44:24.816 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-16 12:44:25.614 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
2021-01-16 12:44:25.763 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-16 12:44:25.763 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-16 12:44:26.011 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
2021-01-16 12:44:26.156 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-16 12:44:26.156 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
2021-01-16 12:45:11.864 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
2021-01-16 12:45:11.985 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-16 12:45:11.986 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-16 12:45:12.214 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 =========== 


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

➜  first-network git:(bb39b6e) 

2.5.4 查看服务/停止服务

  1. 通过docker ps命令可以查看到节点的启动情况
  2. 如果我们要停止网络,可以执行./byfn.sh down 命令来停止
➜  hyperledger-fabric docker ps
CONTAINER ID        IMAGE                                                                                                  COMMAND                  CREATED             STATUS              PORTS                                              NAMES
8180ba4f3431        dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab   "chaincode -peer.add…"   2 hours ago         Up 2 hours                                                             dev-peer1.org2.example.com-mycc-1.0
ee8f94a77069        dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9   "chaincode -peer.add…"   2 hours ago         Up 2 hours                                                             dev-peer0.org1.example.com-mycc-1.0
dc79bc8bc96b        dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b   "chaincode -peer.add…"   2 hours ago         Up 2 hours                                                             dev-peer0.org2.example.com-mycc-1.0
5a80c75e0cee        hyperledger/fabric-tools:latest                                                                        "/bin/bash"              2 hours ago         Up 2 hours                                                             cli
d5c383b59c90        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com
a87dbb92d8cc        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
e75c46b2e025        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
60052619f218        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 hours ago         Up 2 hours          0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
2cc483de6ea0        hyperledger/fabric-orderer:latest                                                                      "orderer"                2 hours ago         Up 2 hours          0.0.0.0:7050->7050/tcp                             orderer.example.com
➜  hyperledger-fabric ./byfn.sh down
zsh: no such file or directory: ./byfn.sh
➜  hyperledger-fabric cd fabric-samples 
➜  fabric-samples git:(bb39b6e) ./byfn.sh down   
zsh: no such file or directory: ./byfn.sh
➜  fabric-samples git:(bb39b6e) ls
CODE_OF_CONDUCT.md       LICENSE                  balance-transfer         chaincode                config                   high-throughput
CONTRIBUTING.md          MAINTAINERS.md           basic-network            chaincode-docker-devmode fabcar                   interest_rate_swaps
Jenkinsfile              README.md                bin                      commercial-paper         first-network            scripts
➜  fabric-samples git:(bb39b6e) cd first-network 
➜  first-network git:(bb39b6e) ./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 peer0.org1.example.com ... done
Stopping peer1.org2.example.com ... done
Stopping peer1.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Stopping orderer.example.com    ... done
Removing cli                    ... done
Removing peer0.org1.example.com ... done
Removing peer1.org2.example.com ... done
Removing peer1.org1.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.
8180ba4f3431
ee8f94a77069
dc79bc8bc96b
Untagged: dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab:latest
Deleted: sha256:b46d9aa35aae3c8846f4a3ed3dfa8b8f79efa96ce6d7b572fbcc531395e5c579
Deleted: sha256:0af8af71efd8be3ea4179294b374fcbe2a1667a219d36a2d2353c3a509732f57
Deleted: sha256:6bbf23ce227334ce245cce2736c33c120c2e92b1bdfaa5e591ae6edf4d7847a9
Deleted: sha256:196304953434fe4df7ab83a236730c77122c927970dbb8d81187813f978d6b54
Untagged: dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9:latest
Deleted: sha256:1351571922fcbe14822732eee202bc9619ee69a28058e84f23ba5651f1f4b9e8
Deleted: sha256:9a8ca76bc6af5dfb1bc3c4b827dbd4172e862c25faef37b5afc2b2d2308a3bb5
Deleted: sha256:891c3f411deb93e613f8eb025627b044b6f75dfa22670ac3dc1bc975d4fbfb1d
Deleted: sha256:690ad68f069ea7167336167b5c8618066b09062a9d680e87fd0fc2534af73cd4
Untagged: dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latest
Deleted: sha256:406ab497636a28e9613dcd44781901b92ed1bbbd6a6de6dfbe8a2f8fca0683ba
Deleted: sha256:71dc7e28d4eee36d2eea71f0ce90a7e0a61e85b336e7444071c4348a6387e8c8
Deleted: sha256:f56b5651b96596816dcd40df89cdd25a257e1aefc1f642626c3a70c27a837428
Deleted: sha256:a973a2c3e8baf14fc61687148cf422651f378e15e4012cddcd8da4f961b25e1c
➜  first-network git:(bb39b6e) pwd
/Users/Barry/hyperledger-fabric/fabric-samples/first-network

3 ubuntu20 部署hyperledger Fabric

3.1 前置条件docker,golang,node.js

安装过程忽略

版本信息如下

barry@u20:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:17:43 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8891c58
  Built:            Mon Dec 28 16:15:19 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
barry@u20:~$ 
barry@u20:~$ node -v
v8.11.4
barry@u20:~$ go version
go version go1.15.6 linux/amd64
barry@u20:~$ 

3.1.1 ubuntu Docker 配置镜像加速器

1. 安装/升级Docker客户端

推荐安装1.10.0以上版本的Docker客户端,参考文档 docker-ce

2. 配置镜像加速器

针对Docker客户端版本大于 1.10.0 的用户

您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://gv1tx6mh.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

3.2 部署hyperledger

3.2.1 bash init.sh 1.2.0 1.2.0 0.4.10

barry@u20:~$ cd hyperledger-fabric/
bash init.sh 1.2.0 1.2.0 0.4.10
下载完的镜像如下:
===> List out hyperledger docker images
hyperledger/fabric-ca        1.2       66cc132bd09c   2 years ago   252MB
hyperledger/fabric-ca        1.2.0     66cc132bd09c   2 years ago   252MB
hyperledger/fabric-ca        latest    66cc132bd09c   2 years ago   252MB
hyperledger/fabric-tools     1.2       379602873003   2 years ago   1.51GB
hyperledger/fabric-tools     1.2.0     379602873003   2 years ago   1.51GB
hyperledger/fabric-tools     latest    379602873003   2 years ago   1.51GB
hyperledger/fabric-ccenv     1.2       6acf31e2d9a4   2 years ago   1.43GB
hyperledger/fabric-ccenv     1.2.0     6acf31e2d9a4   2 years ago   1.43GB
hyperledger/fabric-ccenv     latest    6acf31e2d9a4   2 years ago   1.43GB
hyperledger/fabric-orderer   1.2       4baf7789a8ec   2 years ago   152MB
hyperledger/fabric-orderer   1.2.0     4baf7789a8ec   2 years ago   152MB
hyperledger/fabric-orderer   latest    4baf7789a8ec   2 years ago   152MB
hyperledger/fabric-peer      1.2       82c262e65984   2 years ago   159MB
hyperledger/fabric-peer      1.2.0     82c262e65984   2 years ago   159MB
hyperledger/fabric-peer      latest    82c262e65984   2 years ago   159MB

3.2.2 添加全局命令

barry@u20:~/hyperledger-fabric$ cd fabric-samples/
barry@u20:~/hyperledger-fabric/fabric-samples$ tar -zxvf hyperledger-fabric-linux-amd64-1.2.0.tar.gz 
bin/
bin/configtxgen
bin/cryptogen
bin/idemixgen
bin/discover
bin/configtxlator
bin/peer
bin/orderer
bin/get-docker-images.sh
config/
config/configtx.yaml
config/core.yaml
config/orderer.yaml
barry@u20:~/hyperledger-fabric/fabric-samples$ tar -zxvf hyperledger-fabric-ca-linux-amd64-1.2.0.tar.gz 
bin/
bin/fabric-ca-client

barry@u20:~/hyperledger-fabric/fabric-samples$ ll
total 45004
drwxrwxr-x 14 barry docker     4096 1月  15 14:40 ./
drwxrwxr-x  3 barry docker     4096 1月  15 15:04 ../
drwxrwxr-x  5 barry docker     4096 1月  15 13:39 balance-transfer/
drwxrwxr-x  4 barry docker     4096 1月  15 13:39 basic-network/
drwxrwxr-x  2 barry docker     4096 7月   4  2018 bin/
drwxrwxr-x  8 barry docker     4096 1月  15 13:39 chaincode/
drwxrwxr-x  3 barry docker     4096 1月  15 13:39 chaincode-docker-devmode/
-rw-rw-r--  1 barry docker      597 1月  15 13:39 CODE_OF_CONDUCT.md
drwxrwxr-x  2 barry docker     4096 7月   4  2018 config/
-rw-rw-r--  1 barry docker      961 1月  15 13:39 CONTRIBUTING.md
drwxrwxr-x  2 barry docker     4096 1月  15 13:39 fabcar/
drwxrwxr-x  3 barry docker     4096 1月  15 13:39 fabric-ca/
drwxrwxr-x  6 barry docker     4096 1月  15 15:43 first-network/
drwxrwxr-x  8 barry docker     4096 1月  15 14:36 .git/
-rw-rw-r--  1 barry docker      130 1月  15 13:39 .gitignore
-rw-rw-r--  1 barry docker      109 1月  15 13:39 .gitreview
drwxrwxr-x  4 barry docker     4096 1月  15 13:39 high-throughput/
-rw-rw-r--  1 barry barry   5059290 12月 17  2018 hyperledger-fabric-ca-linux-amd64-1.2.0.tar.gz
-rw-rw-r--  1 barry barry  40919608 12月 17  2018 hyperledger-fabric-linux-amd64-1.2.0.tar.gz
-rw-rw-r--  1 barry docker     3095 1月  15 13:39 Jenkinsfile
-rw-rw-r--  1 barry docker    11358 1月  15 13:39 LICENSE
-rw-rw-r--  1 barry docker      470 1月  15 13:39 MAINTAINERS.md
-rw-rw-r--  1 barry docker     1229 1月  15 13:39 README.md
drwxrwxr-x  3 barry docker     4096 1月  15 13:39 scripts/

barry@u20:~/hyperledger-fabric/fabric-samples$ cd bin/
barry@u20:~/hyperledger-fabric/fabric-samples/bin$ ls
configtxgen  configtxlator  cryptogen  discover  fabric-ca-client  get-docker-images.sh  idemixgen  orderer  peer
barry@u20:~/hyperledger-fabric/fabric-samples/bin$ 
barry@u20:~/hyperledger-fabric/fabric-samples/bin$ 
barry@u20:~/hyperledger-fabric/fabric-samples/bin$ ll
total 131264
drwxrwxr-x  2 barry docker     4096 Jul  4  2018 ./
drwxrwxr-x 14 barry docker     4096 Jan 15 14:40 ../
-rwxrwxr-x  1 barry docker 16784432 Jul  4  2018 configtxgen*
-rwxrwxr-x  1 barry docker 17925784 Jul  4  2018 configtxlator*
-rwxrwxr-x  1 barry docker  8660280 Jul  4  2018 cryptogen*
-rwxrwxr-x  1 barry docker 17611704 Jul  4  2018 discover*
-rwxrwxr-x  1 barry docker 14298688 Jul  4  2018 fabric-ca-client*
-rwxrwxr-x  1 barry docker      817 Jul  4  2018 get-docker-images.sh*
-rwxrwxr-x  1 barry docker  7152824 Jul  4  2018 idemixgen*
-rwxrwxr-x  1 barry docker 22075240 Jul  4  2018 orderer*
-rwxrwxr-x  1 barry docker 29880000 Jul  4  2018 peer*
barry@u20:~/hyperledger-fabric/fabric-samples/bin$ ls
configtxgen  configtxlator  cryptogen  discover  fabric-ca-client  get-docker-images.sh  idemixgen  orderer  peer
barry@u20:~/hyperledger-fabric/fabric-samples/bin$ 
barry@u20:~/hyperledger-fabric/fabric-samples/bin$ 
barry@u20:~/hyperledger-fabric/fabric-samples/bin$  sudo cp * /usr/local/bin

3.2.3 启动测试

./byfn.sh generate  生成秘钥和身份信息

cd ..
barry@u20:~/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/barry/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/barry/hyperledger-fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2021-01-15 14:41:57.705 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'.
2021-01-15 14:41:57.705 CST [common/tools/configtxgen] main -> INFO 002 Loading configuration
2021-01-15 14:41:57.712 CST [common/tools/configtxgen/encoder] NewChannelGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the channel group in configtx.yaml
2021-01-15 14:41:57.712 CST [common/tools/configtxgen/encoder] NewOrdererGroup -> WARN 004 Default policy emission is deprecated, please include policy specificiations for the orderer group in configtx.yaml
2021-01-15 14:41:57.712 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
2021-01-15 14:41:57.712 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2021-01-15 14:41:57.712 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
2021-01-15 14:41:57.713 CST [msp] getMspConfig -> INFO 008 Loading NodeOUs
2021-01-15 14:41:57.713 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
2021-01-15 14:41:57.713 CST [common/tools/configtxgen] doOutputBlock -> INFO 00a Generating genesis block
2021-01-15 14:41:57.713 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
2021-01-15 14:41:57.768 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:41:57.776 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2021-01-15 14:41:57.776 CST [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the application group in configtx.yaml
2021-01-15 14:41:57.776 CST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2021-01-15 14:41:57.776 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
2021-01-15 14:41:57.777 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2021-01-15 14:41:57.777 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
2021-01-15 14:41:57.778 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
2021-01-15 14:41:57.825 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:41:57.832 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2021-01-15 14:41:57.832 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
2021-01-15 14:41:57.881 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:41:57.888 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2021-01-15 14:41:57.888 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
+ res=0
+ set +x

barry@u20:~/hyperledger-fabric/fabric-samples/first-network$ ls ./channel-artifacts/
.gitkeep           Org1MSPanchors.tx  Org2MSPanchors.tx  channel.tx         genesis.block 

3.2.4 启动测试网络失败及解决

失败信息如下

barry@u20:~/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] 
proceeding ...
LOCAL_VERSION=1.2.0
DOCKER_IMAGE_VERSION=1.2.0
/home/barry/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/barry/hyperledger-fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2021-01-15 14:44:08.645 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'.
2021-01-15 14:44:08.645 CST [common/tools/configtxgen] main -> INFO 002 Loading configuration
2021-01-15 14:44:08.651 CST [common/tools/configtxgen/encoder] NewChannelGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the channel group in configtx.yaml
2021-01-15 14:44:08.651 CST [common/tools/configtxgen/encoder] NewOrdererGroup -> WARN 004 Default policy emission is deprecated, please include policy specificiations for the orderer group in configtx.yaml
2021-01-15 14:44:08.651 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
2021-01-15 14:44:08.652 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2021-01-15 14:44:08.652 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
2021-01-15 14:44:08.652 CST [msp] getMspConfig -> INFO 008 Loading NodeOUs
2021-01-15 14:44:08.653 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
2021-01-15 14:44:08.653 CST [common/tools/configtxgen] doOutputBlock -> INFO 00a Generating genesis block
2021-01-15 14:44:08.653 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
2021-01-15 14:44:08.696 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:44:08.703 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2021-01-15 14:44:08.703 CST [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the application group in configtx.yaml
2021-01-15 14:44:08.704 CST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2021-01-15 14:44:08.704 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
2021-01-15 14:44:08.705 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2021-01-15 14:44:08.705 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
2021-01-15 14:44:08.706 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
2021-01-15 14:44:08.750 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:44:08.756 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2021-01-15 14:44:08.757 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
2021-01-15 14:44:08.801 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:44:08.808 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2021-01-15 14:44:08.808 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 peer0.org1.example.com ... done
Creating peer1.org1.example.com ... done
Creating orderer.example.com    ... done
Creating peer1.org2.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
2021-01-15 06:44:13.917 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:44:13.945 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
2021-01-15 06:44:13.951 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2021-01-15 06:44:14.155 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=1
+ set +x
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
peer0.org1 failed to join the channel, Retry after 3 seconds
+ peer channel join -b mychannel.block
+ res=1
+ set +x
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
peer0.org1 failed to join the channel, Retry after 3 seconds
+ peer channel join -b mychannel.block
+ res=1
+ set +x
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
peer0.org1 failed to join the channel, Retry after 3 seconds
+ peer channel join -b mychannel.block
+ res=1
+ set +x
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
peer0.org1 failed to join the channel, Retry after 3 seconds
+ peer channel join -b mychannel.block
+ res=1
+ set +x
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded
!!!!!!!!!!!!!!! After 5 attempts, peer0.org1 has failed to join channel 'mychannel'  !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========

ERROR !!!! Test failed

启动测试网络 ./byfn.sh up 错误解决

参考 https://www.cnblogs.com/chaichai/p/11755994.html

在 docker-compose-cli.yaml 中 cli 容器下,添加环境变量 GODEBUG=netdns=go,在 base/peer-base.yaml 中 peer-base 容器下,添加环境变量 GODEBUG=netdns=go

参考文献: https://yq.aliyun.com/articles/238940

  environment:

      - GODEBUG=netdns=go

两个文件都添加一下环境变量

barry@u20:~/hyperledger-fabric/fabric-samples/first-network$ vi docker-compose-cli.yaml 
barry@u20:~/hyperledger-fabric/fabric-samples/first-network$ vi base/peer-base.yaml

3.2.5 重新启动服务,测试成功

打印如下

barry@u20:~/hyperledger-fabric/fabric-samples/first-network$ ./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 orderer.example.com ... done
Removing cli                    ... done
Removing orderer.example.com    ... done
Removing peer1.org2.example.com ... done
Removing peer0.org1.example.com ... done
Removing peer1.org1.example.com ... done
Removing peer0.org2.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.
---- No containers available for deletion ----
---- No images available for deletion ----
barry@u20:~/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] 
proceeding ...
LOCAL_VERSION=1.2.0
DOCKER_IMAGE_VERSION=1.2.0
/home/barry/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/barry/hyperledger-fabric/fabric-samples/first-network/../bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
+ configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2021-01-15 14:58:53.477 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'.
2021-01-15 14:58:53.477 CST [common/tools/configtxgen] main -> INFO 002 Loading configuration
2021-01-15 14:58:53.484 CST [common/tools/configtxgen/encoder] NewChannelGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the channel group in configtx.yaml
2021-01-15 14:58:53.484 CST [common/tools/configtxgen/encoder] NewOrdererGroup -> WARN 004 Default policy emission is deprecated, please include policy specificiations for the orderer group in configtx.yaml
2021-01-15 14:58:53.484 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
2021-01-15 14:58:53.485 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2021-01-15 14:58:53.485 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
2021-01-15 14:58:53.485 CST [msp] getMspConfig -> INFO 008 Loading NodeOUs
2021-01-15 14:58:53.485 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
2021-01-15 14:58:53.485 CST [common/tools/configtxgen] doOutputBlock -> INFO 00a Generating genesis block
2021-01-15 14:58:53.486 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
2021-01-15 14:58:53.525 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:58:53.532 CST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2021-01-15 14:58:53.532 CST [common/tools/configtxgen/encoder] NewApplicationGroup -> WARN 003 Default policy emission is deprecated, please include policy specificiations for the application group in configtx.yaml
2021-01-15 14:58:53.532 CST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2021-01-15 14:58:53.533 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
2021-01-15 14:58:53.533 CST [msp] getMspConfig -> INFO 006 Loading NodeOUs
2021-01-15 14:58:53.533 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
2021-01-15 14:58:53.534 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
2021-01-15 14:58:53.578 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:58:53.585 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2021-01-15 14:58:53.585 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
2021-01-15 14:58:53.629 CST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2021-01-15 14:58:53.636 CST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2021-01-15 14:58:53.636 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 peer1.org1.example.com ... done
Creating orderer.example.com    ... done
Creating peer1.org2.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
2021-01-15 06:58:58.365 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:58:58.414 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
2021-01-15 06:58:58.421 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2021-01-15 06:58:58.625 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
2021-01-15 06:58:58.730 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:58:58.771 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
2021-01-15 06:59:01.860 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:59:01.897 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
2021-01-15 06:59:04.994 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:59:05.031 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
2021-01-15 06:59:08.127 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:59:08.169 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
2021-01-15 06:59:11.267 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:59:11.282 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
2021-01-15 06:59:14.375 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2021-01-15 06:59:14.392 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
2021-01-15 06:59:17.480 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-15 06:59:17.480 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-15 06:59:19.507 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
2021-01-15 06:59:19.601 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-15 06:59:19.601 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-15 06:59:19.838 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
2021-01-15 06:59:19.932 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-15 06:59:19.932 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
2021-01-15 07:00:24.662 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
2021-01-15 07:00:24.752 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2021-01-15 07:00:24.752 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2021-01-15 07:00:24.970 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 =========== 


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

猜你喜欢

转载自blog.csdn.net/a6taotao/article/details/112726905