Hyperledger Fabric教程(1)--Hyperledger Fabric 老版本 1.1.0 快速部署安装
2021/6/17 12:27:49
本文主要是介绍Hyperledger Fabric教程(1)--Hyperledger Fabric 老版本 1.1.0 快速部署安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一. 运行环境:首先要保证系统安装了Go、Docker、Docker-Compose.
1. 操作系统
Ubuntu 16.04
内存:32G
磁盘:700G
- 安装git
sudo apt install git
- 安装curl
sudo apt install curl
- 安装wget
- 安装vim
sudo apt install vim
2. 安装docker
使用官方安装脚本自动安装:使用官方安装脚本自动安装:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
安装完成后需要修改当前用户(我使用的用户叫shijianfeng)权限:
sudo usermod -aG docker shijianfeng
注销并重新登录,然后配置 Docker 加速器,这里使用的是DaoClound的镜像,执行命令:
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
该脚本可以将 --registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。
You need to restart docker to take effect
sudo systemctl restart docker.service
https://blog.csdn.net/qq_38280232/article/details/82972446
3. 安装go
下载并解压
# 建议下载1.13.8以上的版本,否则编译fabric的时候会报错 wget https://dl.google.com/go/go1.13.8.linux-amd64.tar.gz tar -xvf go1.13.8.linux-amd64.tar.gz sudo mv ./go /usr/local
创建GO工作目录
sudo mkdir -p /home/go/src
设置环境变量
sudo vim /etc/profile # 在最下面添加下面三行代码 export GOROOT=/usr/local/go export GOPATH=/home/go export PATH=$PATH:$GOROOT/bin source /etc/profile
https://blog.csdn.net/u013288190/article/details/112337070
4. 安装docker-composer
Docker-compose是支持通过模板脚本批量创建Docker容器的一个组件。
在安装Docker-Compose之前,需要安装Python-pip,运行脚本:
sudo apt-get install python-pip
升级pip
pip install --upgrade pip
安装docker-compose
pip install docker-compose
查看docker-compose版本
docker-compose -version
https://blog.csdn.net/u013288190/article/details/112297248
可以参考文章Ubuntu16.04 搭建Fabric 1.0.0(https://blog.csdn.net/qq_38280232/article/details/82972446)。
Building Your First Network官方文档(https://hyperledger-fabric.readthedocs.io/en/release-1.1/build_network.html)。
二、安装
1.下载官方 sample
git clone -b master https://github.com/hyperledger/fabric-samples.git
cd fabric-samples && git checkout v1.1.0
git branch
2. 下载fabric提供的工具
curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0
如果因为网络不能下载,我已经下载好了
vim downloadbyfn.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 export VERSION=1.4.4 # if ca version not passed in, default to latest released version export CA_VERSION=1.4.4 # current version of thirdparty images (couchdb, kafka and zookeeper) released export THIRDPARTY_IMAGE_VERSION=0.4.18 export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')") export MARCH=$(uname -m) printHelp() { echo "Usage: bootstrap.sh [version [ca_version [thirdparty_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 1.4.4 -s" echo "would download docker images and binaries for version 1.4.4" } dockerFabricPull() { local FABRIC_TAG=$1 for IMAGES in peer orderer ccenv javaenv tools; do echo "==> FABRIC IMAGE: $IMAGES" echo docker pull hyperledger/fabric-$IMAGES:$FABRIC_TAG docker tag hyperledger/fabric-$IMAGES:$FABRIC_TAG hyperledger/fabric-$IMAGES done } dockerThirdPartyImagesPull() { local THIRDPARTY_TAG=$1 for IMAGES in couchdb kafka zookeeper; do echo "==> THIRDPARTY DOCKER IMAGE: $IMAGES" echo docker pull hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG docker tag hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG hyperledger/fabric-$IMAGES done } dockerCaPull() { local CA_TAG=$1 echo "==> FABRIC CA IMAGE" echo docker pull hyperledger/fabric-ca:$CA_TAG docker tag hyperledger/fabric-ca:$CA_TAG hyperledger/fabric-ca } samplesInstall() { # 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 "===> Checking out v${VERSION} of hyperledger/fabric-samples" git checkout v${VERSION} elif [ -d fabric-samples ]; then # if fabric-samples repo already cloned and in current directory, # cd fabric-samples and checkout corresponding version echo "===> Checking out v${VERSION} of hyperledger/fabric-samples" cd fabric-samples && git checkout v${VERSION} else echo "===> Cloning hyperledger/fabric-samples repo and checkout v${VERSION}" git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples && git checkout v${VERSION} fi } # Incrementally downloads the .tar.gz file locally first, only decompressing it # after the download is complete. This is slower than binaryDownload() but # allows the download to be resumed. binaryIncrementalDownload() { local BINARY_FILE=$1 local URL=$2 curl -f -s -C -L --retry 5 --retry-delay 3 - ${URL} -o ${BINARY_FILE} || rc=$? # Due to limitations in the current Nexus repo: # curl returns 33 when there's a resume attempt with no more bytes to download # curl returns 2 after finishing a resumed download # with -f curl returns 22 on a 404 if [ "$rc" = 22 ]; then # looks like the requested file doesn't actually exist so stop here return 22 fi if [ -z "$rc" ] || [ $rc -eq 33 ] || [ $rc -eq 2 ]; then # The checksum validates that RC 33 or 2 are not real failures echo "==> File downloaded. Verifying the md5sum..." tar xzf ./${BINARY_FILE} --overwrite else echo "Failure downloading binaries (curl RC=$rc). Please try again and the download will resume from where it stopped." exit 1 fi } # This will attempt to download the .tar.gz all at once, but will trigger the # binaryIncrementalDownload() function upon a failure, allowing for resume # if there are network failures. binaryDownload() { local BINARY_FILE=$1 local URL=$2 echo "===> Downloading: " ${URL} # Check if a previous failure occurred and the file was partially downloaded if [ -e ${BINARY_FILE} ]; then echo "==> Partial binary file found. Resuming download..." binaryIncrementalDownload ${BINARY_FILE} ${URL} else curl -L --retry 5 --retry-delay 3 ${URL} | tar xz || rc=$? if [ ! -z "$rc" ]; then echo "==> There was an error downloading the binary file. Switching to incremental download." echo "==> Downloading file..." binaryIncrementalDownload ${BINARY_FILE} ${URL} else echo "==> Done." fi fi } binariesInstall() { echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries" binaryDownload ${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 fi echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary" binaryDownload ${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 fi } dockerInstall() { which docker >& /dev/null NODOCKER=$? if [ "${NODOCKER}" == 0 ]; then echo "===> Pulling fabric Images" dockerFabricPull ${FABRIC_TAG} echo "===> Pulling fabric ca Image" dockerCaPull ${CA_TAG} echo "===> Pulling thirdparty docker images" dockerThirdPartyImagesPull ${THIRDPARTY_TAG} echo 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 [ ! -z "$1" -a ${1:0:1} != "-" ]; then VERSION=$1;shift if [ ! -z "$1" -a ${1:0:1} != "-" ]; then CA_VERSION=$1;shift if [ ! -z "$1" -a ${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 "Installing hyperledger/fabric-samples repo" echo samplesInstall fi if [ "$BINARIES" == "true" ]; then echo echo "Installing Hyperledger Fabric binaries" echo binariesInstall fi if [ "$DOCKER" == "true" ]; then echo echo "Installing Hyperledger Fabric docker images" echo dockerInstall fi
bash ./downloadbyfn.sh 1.1.0 -s
下载了各种命令
ls -lrt bin/
下载的各种镜像
docker images | grep hyper
ccenv是链码运行环境
baseos是区块链的底层操作系统
3. 运行sample
然后进入first-network
文件夹下
cd first-network
关闭之前可能存在的网络
./byfn.sh -m down
执行generate命令:
这个命令为我们的各种网络实体生成所有证书和密钥、用于引导排序服务的创世块,以及配置Channel所需的一系列配置交易。
./byfn.sh -m generate
shijianfeng@k8s-master:~/fabric-samples/first-network$ ./byfn.sh -m generate Generating certs and genesis block for with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds Continue? [Y/n] proceeding ... /home/shijianfeng/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/shijianfeng/fabric-samples/first-network/../bin/configtxgen ########################################################## ######### Generating Orderer Genesis block ############## ########################################################## + configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block 2021-01-06 05:59:03.704 PST [common/tools/configtxgen] main -> INFO 001 Loading configuration 2021-01-06 05:59:03.710 PST [msp] getMspConfig -> INFO 002 Loading NodeOUs 2021-01-06 05:59:03.711 PST [msp] getMspConfig -> INFO 003 Loading NodeOUs 2021-01-06 05:59:03.711 PST [common/tools/configtxgen] doOutputBlock -> INFO 004 Generating genesis block 2021-01-06 05:59:03.711 PST [common/tools/configtxgen] doOutputBlock -> INFO 005 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-06 05:59:03.750 PST [common/tools/configtxgen] main -> INFO 001 Loading configuration 2021-01-06 05:59:03.756 PST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx 2021-01-06 05:59:03.756 PST [msp] getMspConfig -> INFO 003 Loading NodeOUs 2021-01-06 05:59:03.756 PST [msp] getMspConfig -> INFO 004 Loading NodeOUs 2021-01-06 05:59:03.775 PST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 005 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-06 05:59:03.814 PST [common/tools/configtxgen] main -> INFO 001 Loading configuration 2021-01-06 05:59:03.820 PST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update 2021-01-06 05:59:03.820 PST [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-06 05:59:03.860 PST [common/tools/configtxgen] main -> INFO 001 Loading configuration 2021-01-06 05:59:03.867 PST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update 2021-01-06 05:59:03.867 PST [common/tools/configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update + res=0 + set +x
执行如下命令启动网络:
./byfn.sh -m up
shijianfeng@k8s-master:~/fabric-samples/first-network$ ./byfn.sh -m up Starting with channel 'mychannel' and CLI timeout of '10' seconds and CLI delay of '3' seconds Continue? [Y/n] proceeding ... 2021-01-06 13:59:34.367 UTC [main] main -> INFO 001 Exiting..... LOCAL_VERSION=1.1.0 DOCKER_IMAGE_VERSION=1.1.0 /home/shijianfeng/.local/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release. from cryptography.hazmat.backends import default_backend Creating network "net_byfn" with the default driver Creating volume "net_peer0.org2.example.com" with default driver Creating volume "net_peer1.org2.example.com" with default driver Creating volume "net_peer1.org1.example.com" with default driver Creating volume "net_peer0.org1.example.com" with default driver Creating volume "net_orderer.example.com" with default driver Creating orderer.example.com ... done Creating peer0.org1.example.com ... done Creating peer0.org2.example.com ... done Creating peer1.org1.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... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org1MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + 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-06 13:59:41.982 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2021-01-06 13:59:42.004 UTC [channelCmd] InitCmdFactory -> INFO 002 Endorser and orderer connections initialized 2021-01-06 13:59:42.220 UTC [main] main -> INFO 003 Exiting..... ===================== Channel "mychannel" is created successfully ===================== Having all peers join the channel... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org1MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + peer channel join -b mychannel.block + res=0 + set +x 2021-01-06 13:59:42.308 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2021-01-06 13:59:42.397 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 2021-01-06 13:59:42.397 UTC [main] main -> INFO 003 Exiting..... ===================== peer0.org1 joined on the channel "mychannel" ===================== CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org1MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer1.org1.example.com:7051 + peer channel join -b mychannel.block + res=0 + set +x 2021-01-06 13:59:45.444 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2021-01-06 13:59:45.534 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 2021-01-06 13:59:45.534 UTC [main] main -> INFO 003 Exiting..... ===================== peer1.org1 joined on the channel "mychannel" ===================== CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org2MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org2.example.com:7051 + peer channel join -b mychannel.block + res=0 + set +x 2021-01-06 13:59:48.591 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2021-01-06 13:59:48.676 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 2021-01-06 13:59:48.676 UTC [main] main -> INFO 003 Exiting..... ===================== peer0.org2 joined on the channel "mychannel" ===================== CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org2MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer1.org2.example.com:7051 + peer channel join -b mychannel.block + res=0 + set +x 2021-01-06 13:59:51.748 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2021-01-06 13:59:51.835 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel 2021-01-06 13:59:51.835 UTC [main] main -> INFO 003 Exiting..... ===================== peer1.org2 joined on the channel "mychannel" ===================== Updating anchor peers for org1... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org1MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + 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-06 13:59:54.903 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2021-01-06 13:59:54.918 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update 2021-01-06 13:59:54.919 UTC [main] main -> INFO 003 Exiting..... ===================== Anchor peers for org "Org1MSP" on "mychannel" is updated successfully ===================== Updating anchor peers for org2... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org2MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org2.example.com:7051 + 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-06 13:59:57.969 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized 2021-01-06 13:59:57.977 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update 2021-01-06 13:59:57.978 UTC [main] main -> INFO 003 Exiting..... ===================== Anchor peers for org "Org2MSP" on "mychannel" is updated successfully ===================== Installing chaincode on peer0.org1... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org1MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/ + res=0 + set +x 2021-01-06 14:00:01.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2021-01-06 14:00:01.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 2021-01-06 14:00:01.228 UTC [main] main -> INFO 003 Exiting..... ===================== Chaincode is installed on peer0.org1 ===================== Install chaincode on peer0.org2... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org2MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org2.example.com:7051 + peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/ + res=0 + set +x 2021-01-06 14:00:01.294 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2021-01-06 14:00:01.294 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 2021-01-06 14:00:01.453 UTC [main] main -> INFO 003 Exiting..... ===================== Chaincode is installed on peer0.org2 ===================== Instantiating chaincode on peer0.org2... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org2MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org2.example.com:7051 + 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 'OR ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')' + res=0 + set +x 2021-01-06 14:00:01.521 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2021-01-06 14:00:01.521 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 2021-01-06 14:00:42.285 UTC [main] main -> INFO 003 Exiting..... ===================== Chaincode Instantiation on peer0.org2 on channel 'mychannel' is successful ===================== Querying chaincode on peer0.org1... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org1MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org1.example.com:7051 ===================== Querying on peer0.org1 on channel 'mychannel'... ===================== Attempting to Query peer0.org1 ...3 secs + peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' + res=0 + set +x 2021-01-06 14:00:45.336 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2021-01-06 14:00:45.336 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc Query Result: 100 2021-01-06 14:00:57.563 UTC [main] main -> INFO 003 Exiting..... ===================== Query on peer0.org1 on channel 'mychannel' is successful ===================== Sending invoke transaction on peer0.org1... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org1MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + 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 -c '{"Args":["invoke","a","b","10"]}' + res=0 + set +x 2021-01-06 14:00:57.628 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2021-01-06 14:00:57.628 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 2021-01-06 14:00:57.634 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 003 Chaincode invoke successful. result: status:200 2021-01-06 14:00:57.634 UTC [main] main -> INFO 004 Exiting..... ===================== Invoke transaction on peer0.org1 on channel 'mychannel' is successful ===================== Installing chaincode on peer1.org2... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org2MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer1.org2.example.com:7051 + peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/ + res=0 + set +x 2021-01-06 14:00:57.697 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2021-01-06 14:00:57.697 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc 2021-01-06 14:00:57.865 UTC [main] main -> INFO 003 Exiting..... ===================== Chaincode is installed on peer1.org2 ===================== Querying chaincode on peer1.org2... CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key CORE_PEER_LOCALMSPID=Org2MSP CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt CORE_PEER_TLS_ENABLED=true CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ID=cli CORE_LOGGING_LEVEL=INFO CORE_PEER_ADDRESS=peer1.org2.example.com:7051 ===================== 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 2021-01-06 14:01:00.933 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc 2021-01-06 14:01:00.933 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc Query Result: 90 2021-01-06 14:01:11.315 UTC [main] main -> INFO 003 Exiting..... ===================== Query on peer1.org2 on channel 'mychannel' is successful ===================== ========= All GOOD, BYFN execution completed =========== _____ _ _ ____ | ____| | \ | | | _ \ | _| | \| | | | | | | |___ | |\ | | |_| | |_____| |_| \_| |____/ shijianfeng@k8s-master:~/fabric-samples/first-network$
查看所有运行的docker
docker ps
shijianfeng@k8s-master:~/fabric-samples/first-network$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 133dab556852 dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab "chaincode -peer.a..." 11 hours ago Up 11 hours dev-peer1.org2.example.com-mycc-1.0 32312906669c dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9 "chaincode -peer.a..." 11 hours ago Up 11 hours dev-peer0.org1.example.com-mycc-1.0 73a04d9d1022 dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b "chaincode -peer.a..." 11 hours ago Up 11 hours dev-peer0.org2.example.com-mycc-1.0 8b7553ce5caf hyperledger/fabric-tools:latest "/bin/bash" 11 hours ago Up 11 hours cli c31f57abdc27 hyperledger/fabric-peer:latest "peer node start" 11 hours ago Up 11 hours 0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com bf2b6c01d856 hyperledger/fabric-peer:latest "peer node start" 11 hours ago Up 11 hours 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com 159e662172d4 hyperledger/fabric-peer:latest "peer node start" 11 hours ago Up 11 hours 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com 150554d5a348 hyperledger/fabric-peer:latest "peer node start" 11 hours ago Up 11 hours 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com 6b1ee06e363c hyperledger/fabric-orderer:latest "orderer" 11 hours ago Up 11 hours 0.0.0.0:7050->7050/tcp orderer.example.com shijianfeng@k8s-master:~/fabric-samples/first-network$
- 这三个是执行链码,动态创建的容器
dev-peer1.org2.example.com-mycc-1.0
dev-peer0.org1.example.com-mycc-1.0
dev-peer0.org2.example.com-mycc-1.0
- 这个容器运行区块链的控制台
cli
- 这四个是运行peer节点的容器
peer1.org2.example.com
peer0.org2.example.com
peer0.org1.example.com
peer1.org1.example.com
- 这个是orderer节点运行的容器
orderer.example.com
https://blog.csdn.net/yjjing123/article/details/103720166
https://www.www.zyiz.net/content-3-61401.html
https://www.it610.com/article/1281912501604204544.htm
Hyperledger Fabric 容器部署以及chaincode测试(BYFN)
https://zhuanlan.zhihu.com/p/32741931
这篇关于Hyperledger Fabric教程(1)--Hyperledger Fabric 老版本 1.1.0 快速部署安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23增量更新怎么做?-icode9专业技术文章分享
- 2024-11-23压缩包加密方案有哪些?-icode9专业技术文章分享
- 2024-11-23用shell怎么写一个开机时自动同步远程仓库的代码?-icode9专业技术文章分享
- 2024-11-23webman可以同步自己的仓库吗?-icode9专业技术文章分享
- 2024-11-23在 Webman 中怎么判断是否有某命令进程正在运行?-icode9专业技术文章分享
- 2024-11-23如何重置new Swiper?-icode9专业技术文章分享
- 2024-11-23oss直传有什么好处?-icode9专业技术文章分享
- 2024-11-23如何将oss直传封装成一个组件在其他页面调用时都可以使用?-icode9专业技术文章分享
- 2024-11-23怎么使用laravel 11在代码里获取路由列表?-icode9专业技术文章分享
- 2024-11-22怎么实现ansible playbook 备份代码中命名包含时间戳功能?-icode9专业技术文章分享