测试Fabric1.4性能时运行以下命令时报错
npx caliper launch master --caliper-workspace . --caliper-benchconfig benchmarks/scenario/simple/config.yaml --caliper-networkconfig networks/fabric/fabric-v1.4.1/2org1peergoleveldb/fabric-go.yaml
首先是提示拉取镜像失败:Get https://registry-1.docker.io/v2/hyperledger/fabric-ca/manifests/1.4.1: net/http: TLS handshake timeout
然后报错如下:problem reading the PEM file :: Error: ENOENT: no such file or directory, open '/home/yujialing/go/src/github.com/hyperledger/caliper-benchmarks/networks/fabric/config_solo/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/key.pem’
1.首先解决拉取docker镜像失败的问题
将docker镜像换成国内源
vim /etc/docker/daemon.json
{
"registry-mirrors":["https://registry.docker-cn.com"]
}
重启docker
systemctl restart docker
查看docker信息
docker info
再次运行以下命令,拉取docker镜像的问题解决了,但证书问题仍未解决
npx caliper launch master --caliper-workspace . --caliper-benchconfig benchmarks/scenario/simple/config.yaml --caliper-networkconfig networks/fabric/fabric-v1.4.1/2org1peergoleveldb/fabric-go.yaml
去到config_solo目录去查看
cd networks/fabric/config_solo/crypto-config/peerOrganizations/org1.example.com/users
文件夹为空
docker镜像拉取失败问题解决,但是证书找不到问题还没解决,原因是缺少了Fabric1.4.1的二进制脚本文件。
2.解决找不到证书的问题
可以到此处0积分下载Fabric1.4.1的二进制脚本文件,并放置在config_solo目录下。
另外搭建了Hyperledger Fabric的同学也可以去fabric/script目录下用bootstrap.sh
下载Fabric1.4.1的二进制脚本文件
cd /home/yujialing/go/src/github.com/hyperledger/fabric/scripts
打开bootstrap.sh
,编辑版本参数,分别改为1.4.1
、1.4.1
、0.4.15
保存后退出。注意,之前搭建Hyperledger Fabric的时候,当前目录下可能有fabric-sample
这个文件夹,如果以后还要用到就将其备份起来,以后不用的同学将其删除也可以
执行以下命令下载fabric-sample、二进制脚本文件和docker镜像
./bootstrap.sh
下载完成后会在当前文件夹下生成fabic-sample文件,里面有一个bin文件夹用于放置二进制脚本文件,复制到caliper-benchmarks/networks/fabric/config_solo下
cp -r fabric-samples/bin /home/yujialing/go/src/github.com/hyperledger/caliper-benchmarks/networks/fabric/config_solo/bin
进入bin目录查看二进制脚本文件是否已经复制过来,下图显示已经成功复制过来
cd /home/yujialing/go/src/github.com/hyperledger/caliper-benchmarks/networks/fabric/config_solo/bin
返回上一级
cd ..
目前有4个文件,执行generate.sh
./generate.sh
成功生成了证书密钥文件夹、通道交易和创世区块
接下来回到caliper-benchmarks
目录,再次执行测试性能测试指令,证书问题解决了,但还存在一个新的问题
cd ../../..
npx caliper launch master --caliper-workspace . --caliper-benchconfig benchmarks/scenario/simple/config.yaml --caliper-networkconfig networks/fabric/fabric-v1.4.1/2org1peergoleveldb/fabric-go.yaml
原先node版本为10.20.0
,npm为最新的6.14.8
换了node和npm版本(node8.9.0
、npm5.5.1
),这个问题就解决了,所以产生这个问题的原因是node版本不匹配,Hyperledger Caliper对node版本要求也太高了吧!
查看node和npm版本指令
node -v
npm -v
解决这个问题的同时又产生了新的问题,报错如下:
error [caliper] [caliper-engine] Error while performing "install" step: Error: Invalid endorsement for marbles@v0 in mychannel from peer0.org1.example.com: error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "/chaincode/input/src/fabric/samples/marbles/go/marbles.go:110:2: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
/usr/local/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
/chaincode/input/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)
/go/src/github.com/hyperledger/fabric/core/chaincode/shim
/chaincode/input/src/fabric/samples/marbles/go/marbles.go:111:2: cannot find package "github.com/hyperledger/fabric/protos/peer" in any of:
/usr/local/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT)
/chaincode/input/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH)
/go/src/github.com/hyperledger/fabric/protos/peer
我猜是因为我本地Fabric的版本是2.0,没有shim和peer这两个依赖包
切换到Fabric文件夹中
cd /home/yujialing/go/src/github.com/hyperledger/fabric
git branch
版本显示是release-2.0
将其切换到v1.4.1
git checkout v1.4.1
回到caliper-benchmarks
目录
cd /home/yujialing/go/src/github.com/hyperledger/caliper-benchmarks
npx caliper launch master --caliper-workspace . --caliper-benchconfig benchmarks/scenario/simple/config.yaml --caliper-networkconfig networks/fabric/fabric-v1.4.1/2org1peergoleveldb/fabric-go.yaml
我把这shim和peer这两个包复制到/usr/local/go
目录下,尝试切换到相对应的目录是可以的,但为什么显示找不到包呢?
[yujialing@localhost caliper-benchmarks]$ cd /usr/local/go/src/github.com/hyperledger/fabric/core/chaincode/shim
[yujialing@localhost shim]$ ls
chaincode.go inprocstream.go mockstub.go shim_test.go
ext inprocstream_test.go mockstub_test.go
handler.go interfaces.go response.go
[yujialing@localhost shim]$ cd /usr/local/go/src/github.com/hyperledger/fabric/protos/peer
[yujialing@localhost peer]$ ls
admin.pb.go configuration.pb.go proposal_response.pb.go
admin.proto configuration.proto proposal_response.proto
chaincode_event.pb.go events.pb.go query.pb.go
chaincode_event.proto events.proto query.proto
chaincode.go lifecycle resources.pb.go
chaincode.pb.go peer.pb.go resources.proto
chaincode.proto peer.proto signed_cc_dep_spec.pb.go
chaincode_shim.pb.go proposal.go signed_cc_dep_spec.proto
chaincode_shim.proto proposal.pb.go transaction.go
chaincodeunmarshall.go proposal.proto transaction.pb.go
configuration.go proposal_response.go transaction.proto
仍然报相同的错误,正在解决中,请持续关注
欢迎小伙伴的讨论,若有问题请在评论区评论,谢谢你。