主頁 > 區塊鏈 > hyperledger環境搭建(mac11.1、ubunt20)

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

2021-01-18 12:46:48 區塊鏈

目錄

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拉取鏡像巨慢

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

DockerForMac-18.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-peerpeer模塊鏡像檔案
hyperledger/fabric-ordererorderer節點庫鏡像檔案
hyperledger/fabric-ccenvGo語言chaincode運行環境庫鏡像檔案
hyperledger/fabric-tools相關工具鏡像檔案包含了cryptogen, configtxgen等
hyperledger/fabric-caCA模塊鏡像檔案
hyperledger/fabric-couchdbcouchdb資料庫鏡像檔案
hyperledger/fabric-kafkakafka庫鏡像檔案
hyperledger/fabric-zookeeperzookeeper

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 =========== 


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

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/250268.html

標籤:區塊鏈

上一篇:Python3.7在Ubuntu(Linux)下的安裝步驟:源代碼構建安裝Python3.7

下一篇:2020年技術總結——區塊鏈

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • JAVA使用 web3j 進行token轉賬

    最近新學習了下區塊鏈這方面的知識,所學不多,給大家分享下。 # 1. 關于web3j web3j是一個高度模塊化,反應性,型別安全的Java和Android庫,用于與智能合約配合并與以太坊網路上的客戶端(節點)集成。 # 2. 準備作業 jdk版本1.8 引入maven <dependency> < ......

    uj5u.com 2020-09-10 03:03:06 more
  • 以太坊智能合約開發框架Truffle

    前言 部署智能合約有多種方式,命令列的瀏覽器的渠道都有,但往往跟我們程式員的風格不太相符,因為我們習慣了在IDE里寫了代碼然后打包運行看效果。 雖然現在IDE中已經存在了Solidity插件,可以撰寫智能合約,但是部署智能合約卻要另走他路,沒辦法進行一個快捷的部署與測驗。 如果團隊管理的區塊節點多、 ......

    uj5u.com 2020-09-10 03:03:12 more
  • 谷歌二次驗證碼成為區塊鏈專用安全碼,你怎么看?

    前言 谷歌身份驗證器,前些年大家都比較陌生,但隨著國內互聯網安全的加強,它越來越多地出現在大家的視野中。 比較廣泛接觸的人群是國際3A游戲愛好者,游戲盜號現象嚴重+國外賬號安全應用廣泛,這類游戲一般都會要求用戶系結名為“兩步驗證”、“雙重驗證”等,平臺一般都推薦用谷歌身份驗證器。 后來區塊鏈業務風靡 ......

    uj5u.com 2020-09-10 03:03:17 more
  • 密碼學DAY1

    目錄 ##1.1 密碼學基本概念 密碼在我們的生活中有著重要的作用,那么密碼究竟來自何方,為何會產生呢? 密碼學是網路安全、資訊安全、區塊鏈等產品的基礎,常見的非對稱加密、對稱加密、散列函式等,都屬于密碼學范疇。 密碼學有數千年的歷史,從最開始的替換法到如今的非對稱加密演算法,經歷了古典密碼學,近代密 ......

    uj5u.com 2020-09-10 03:03:50 more
  • 密碼學DAY1_02

    目錄 ##1.1 ASCII編碼 ASCII(American Standard Code for Information Interchange,美國資訊交換標準代碼)是基于拉丁字母的一套電腦編碼系統,主要用于顯示現代英語和其他西歐語言。它是現今最通用的單位元組編碼系統,并等同于國際標準ISO/IE ......

    uj5u.com 2020-09-10 03:04:50 more
  • 密碼學DAY2

    ##1.1 加密模式 加密模式:https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html ECB ECB : Electronic codebook, 電子密碼本. 需要加密的訊息按照塊密碼的塊大小被分為數個塊,并對每個塊進 ......

    uj5u.com 2020-09-10 03:05:42 more
  • NTP時鐘服務器的特點(京準電子)

    NTP時鐘服務器的特點(京準電子) NTP時鐘服務器的特點(京準電子) 京準電子官V——ahjzsz 首先對時間同步進行了背景介紹,然后討論了不同的時間同步網路技術,最后指出了建立全球或區域時間同步網存在的問題。 一、概 述 在通信領域,“同步”概念是指頻率的同步,即網路各個節點的時鐘頻率和相位同步 ......

    uj5u.com 2020-09-10 03:05:47 more
  • 標準化考場時鐘同步系統推進智能化校園建設

    標準化考場時鐘同步系統推進智能化校園建設 標準化考場時鐘同步系統推進智能化校園建設 安徽京準電子科技官微——ahjzsz 一、背景概述隨著教育事業的快速發展,學校建設如雨后春筍,隨之而來的學校教育、管理、安全方面的問題成了學校管理人員面臨的最大的挑戰,這些問題同時也是學生家長所擔心的。為了讓學生有更 ......

    uj5u.com 2020-09-10 03:05:51 more
  • 位元幣入門

    引言 位元幣基本結構 位元幣基礎知識 1)哈希演算法 2)非對稱加密技術 3)數字簽名 4)MerkleTree 5)哪有位元幣,有的是UTXO 6)位元幣挖礦與共識 7)區塊驗證(共識) 總結 引言 上一篇我們已經知道了什么是區塊鏈,此篇說一下區塊鏈的第一個應用——位元幣。其實先有位元幣,后有的區塊 ......

    uj5u.com 2020-09-10 03:06:15 more
  • 北斗對時服務器(北斗對時設備)電力系統應用

    北斗對時服務器(北斗對時設備)電力系統應用 北斗對時服務器(北斗對時設備)電力系統應用 京準電子科技官微(ahjzsz) 中國北斗衛星導航系統(英文名稱:BeiDou Navigation Satellite System,簡稱BDS),因為是目前世界范圍內唯一可以大面積提供免費定位服務的系統,所以 ......

    uj5u.com 2020-09-10 03:06:20 more
最新发布
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:46:47 more
  • Hyperledger Fabric 使用 CouchDB 和復雜智能合約開發

    在上個實驗中,我們已經實作了簡單智能合約實作及客戶端開發,但該實驗中智能合約只有基礎的增刪改查功能,且其中的資料管理功能與傳統 MySQL 比相差甚遠。本文將在前面實驗的基礎上,將 Hyperledger Fabric 的默認資料庫支持 LevelDB 改為 CouchDB 模式,以實作更復雜的資料... ......

    uj5u.com 2023-04-16 07:28:31 more
  • .NET Core 波場鏈離線簽名、廣播交易(發送 TRX和USDT)筆記

    Get Started NuGet You can run the following command to install the Tron.Wallet.Net in your project. PM> Install-Package Tron.Wallet.Net 配置 public reco ......

    uj5u.com 2023-04-14 08:08:00 more
  • DKP 黑客分析——不正確的代幣對比率計算

    概述: 2023 年 2 月 8 日,針對 DKP 協議的閃電貸攻擊導致該協議的用戶損失了 8 萬美元,因為 execute() 函式取決于 USDT-DKP 對中兩種代幣的余額比率。 智能合約黑客概述: 攻擊者的交易:0x0c850f,0x2d31 攻擊者地址:0xF38 利用合同:0xf34ad ......

    uj5u.com 2023-04-07 07:46:09 more
  • Defi開發簡介

    Defi開發簡介 介紹 Defi是去中心化金融的縮寫, 是一項旨在利用區塊鏈技術和智能合約創建更加開放,可訪問和透明的金融體系的運動. 這與傳統金融形成鮮明對比,傳統金融通常由少數大型銀行和金融機構控制 在Defi的世界里,用戶可以直接從他們的電腦或移動設備上訪問廣泛的金融服務,而不需要像銀行或者信 ......

    uj5u.com 2023-04-05 08:01:34 more
  • solidity簡單的ERC20代幣實作

    // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "hardhat/console.sol"; //ERC20 同質化代幣,每個代幣的本質或性質都是相同 //ETH 是原生代幣,它不是ERC20代幣, ......

    uj5u.com 2023-03-21 07:56:29 more
  • solidity 參考型別修飾符memory、calldata與storage 常量修飾符C

    在solidity語言中 參考型別修飾符(參考型別為存盤空間不固定的數值型別) memory、calldata與storage,它們只能修飾參考型別變數,比如字串、陣列、位元組等... memory 適用于方法傳參、返參或在方法體內使用,使用完就會清除掉,釋放記憶體 calldata 僅適用于方法傳參 ......

    uj5u.com 2023-03-08 07:57:54 more
  • solidity注解標簽

    在solidity語言中 注釋符為// 注解符為/* 內容*/ 或者 是 ///內容 注解中含有這幾個標簽給予我們使用 @title 一個應該描述合約/介面的標題 contract, library, interface @author 作者的名字 contract, library, interf ......

    uj5u.com 2023-03-08 07:57:49 more
  • 評價指標:相似度、GAS消耗

    【代碼注釋自動生成方法綜述】 這些評測指標主要來自機器翻譯和文本總結等研究領域,可以評估候選文本(即基于代碼注釋自動方法而生成)和參考文本(即基于手工方式而生成)的相似度. BLEU指標^[^?88^^?^]^:其全稱是bilingual evaluation understudy.該指標是最早用于 ......

    uj5u.com 2023-02-23 07:27:39 more
  • 基于NOSTR協議的“公有制”版本的Twitter,去中心化社交軟體Damus

    最近,一個幽靈,Web3的幽靈,在網路游蕩,它叫Damus,這玩意詮釋了什么叫做病毒式營銷,滑稽的是,一個Web3產品卻在Web2的產品鏈上瘋狂傳銷,各方大佬紛紛為其背書,到底發生了什么?Damus的葫蘆里,賣的是什么藥? 注冊和簡單實用 很少有什么產品在用戶注冊環節會有什么噱頭,但Damus確實出 ......

    uj5u.com 2023-02-05 06:48:39 more