Hyperledger Fabric 1.4.4中添加PBFT并使用caliper压测

预备条件:ubuntu 20.04 、docker、docker-compose、git、wget

视频链接:Hyperledger Fabric 添加PBFT共识算法 含caliper压测_哔哩哔哩_bilibili

1.安装必备工具下载pbft源码

sudo apt install gcc make python2.7 g++

git clone https://github.com/yezhem/fabric-sample

git clone https://gitee.com/real__cool/fabric_install

2.下载安装go

wget https://golang.google.cn/dl/go1.18.4.linux-amd64.tar.gz

sudo tar -C /usr/local -xzf go1.18.4.linux-amd64.tar.gz

设置go环境变量

mkdir go

export GOPATH=$HOME/go

export GOROOT=/usr/local/go

export PATH=$GOROOT/bin:$PATH

3.下载fabric 1.4.4 源代码

mkdir -p $GOPATH/src/github.com/hyperledger/

cd $GOPATH/src/github.com/hyperledger/

git clone https://github.com/hyperledger/fabric

git checkout v1.4.4


 

4.修改fabric源代码,支持pbft

common/tools/configtxgen/localconfig/config.go

388 case "pbft":

common/tools/configtxgen/encoder/encoder.go

39  ConsensusTypePbft = "pbft"

216 case ConsensusTypePbft:

orderer/common/server/main.go

50 "github.com/hyperledger/fabric/orderer/consensus/pbft"

650 consenters["pbft"] = pbft.New()

下载编译源码相关工具

mkdir -p $GOPATH/src/golang.org/x

cd $GOPATH/src/golang.org/x

git clone https://github.com/golang/tools.git

拷贝pbft源码到fabric源码

cd orderer/consensus/

cp -r ~/fabric-sample/pbft .

编译orderer镜像

make orderer-docker

关闭GO111MODULE

export GO111MODULE=off

make configtxgen

5.下载nvm与node

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

nvm install 8.15

nvm alias default 8.15

npm config set registry https://registry.npm.taobao.org

6.下载fabric-samples、二进制文件、docker镜像

chmod +x bootstrap3.sh

./bootstrap3.sh 1.4.4 1.4.4

7.删除fabric-sample/pbft-network中的IMAGETAG

59 docker-compose-cli.yaml

4、17 peer-base.yaml


 

8.安装caliper依赖

添加python环境变量到.bashrc

export PYTHON=/usr/bin/python2.7

安装caliper-cli

npm install -g --only=prod @hyperledger/[email protected]

绑定sut,这里出错了就重试几次

caliper bind --caliper-bind-sut fabric:1.4.4 --caliper-bind-args=-g

下载caliper-core

cd /home/test/fabric-sample/chaincode/demo/callback

npm install @hyperledger/[email protected]


 

9.启动项目与caliper测试

制作好的二进制文件替换原来的,才可以识别pbft

 cp ~/go/src/github.com/hyperledger/fabric/.build/bin/configtxgen .

给新制作好的镜像打上标签latest,这里06bc1fdea693是刚做好的镜像

docker tag 06bc1fdea693 hyperledger/fabric-orderer:latest

sudo ./scripts/utils.sh down

./scripts/gen.sh

./scripts/utils.sh up

到这里就启动好pbft网络了

Hyperledger Fabric 1.4.4中添加PBFT并使用caliper压测_第1张图片

caliper测试

sudo ./scripts/utils.sh down && npx caliper launch master --caliper-workspace ./ --caliper-benchconfig benchmarks/config.yaml --caliper-networkconfig benchmarks/network.yaml

Hyperledger Fabric 1.4.4中添加PBFT并使用caliper压测_第2张图片

输出的report.html 就是本次测试的报告,可以在浏览器中查看

Hyperledger Fabric 1.4.4中添加PBFT并使用caliper压测_第3张图片

编译好的docker镜像:

直接拉取后打上标签latest即可

docker pull realhaha/fabric-orderer:pbft

编译好的configtxgen:

链接:https://pan.baidu.com/s/13XS1Q_9Oa1QKqYmOQ1iKmA 
提取码:4i79

至此结束

你可能感兴趣的:(fabric,docker,运维,区块链,linux)