根据博客安装安装git,cURL,Docker,docker-compose,Golang,我用的golang 版本是1.19版本的。
建一个名为blockchain的文件夹,把代码拉倒里面起。
cd blockchain
git clone https://github.com/hyperledger/fabric.git
cd ./fabric
git branch -a
git checkout v1.4.3
git clone https://github.com/hyperledger/fabric-samples.git
cd ./fabric-samples
git branch -a
git checkout v1.4.3
去下面两个网站找到对应的依赖
https://github.com/hyperledger/fabric-ca/releases/tag/v1.4.3
https://github.com/hyperledger/fabric/releases/tag/v1.4.3
下载这两个文件之后,放到服务器上面解压。
hyperledger-fabric-ca-linux-amd64-1.4.3.tar.gz 解压之后会得到一个bin。
hyperledger-fabric-linux-amd64-1.4.3.tar.gz解压之后会得到一个bin和一个config文件。
将两个bin合并,即把第一个bin里面的文件复制到第二个bin里面。
把合并后的bin和config移动fabric-samples文件夹下,赋予bin下面所以文件赋予执行权限
sudo chmod -R 777 ./bin
在fabric/scripts/bootstrap.sh文件中,最后一部分有如下命令,将其中红框内删除,即只保留$Docker步骤。之后执行下列语句:
./bootstrap.sh 1.4.3 1.4.3 0.4.15
cd ./fabric-samples/first-network/
./byfn.sh up
报错:got unexpected status: FORBIDDEN – implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the ‘Writers’ sub-policies to be satisfied: permission denied
解决办法:参照了https://www.cnblogs.com/coderzjz/p/13812451.html
docker-compose -f docker-compose-cli.yaml down --volumes --remove-orphans
docker rm -f $(docker ps -a | grep "hyperledger/*" | awk "{print \$1}")
docker volume prune
再次执行./byfn.sh up
报错: got unexpected status: BAD_REQUEST – error applying config update to existing channel ‘mychannel’: error authorizing update: error validating ReadSet: proposed update requires that key [Group] /Channel/Application be at version 0, but it is currently at version 1
解决办法:./byfn.sh -m restart -c mychannel
这个就是重启,建议在启动失败之后,先执行./byfn.sh down 再执行./byfn.sh up比较好
再次执行./byfn.sh up
报错:Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: connection error: desc = “transport: error while dialing: dial tcp: lookup peer0.org1.example.com: no such host”
解决办法:先sudo vim /etc/resolv.conf
注释掉options
然后执行如下命令
sudo apt install resolvconf
sudo service resolvconf restart
./byfn.sh down
./byfn.sh up