根据书本以及百度查阅文献进行本文的记录。书本为《超级账本HyperLedger Fabric区块链开发实战》 林维锋编著
1、创建helloworld项目
2、编译好智能合约 chaincode
3、配置crypto-config.yaml和 configtx.yaml
crypto-config.yaml:用于生成证书配置文件
configtx.yaml: 用于生成区块和通道配置文件
4、生成公私钥和证书(这里是用到crypto-config.yaml)
output:
5、生成创世区块(这里是用到configtx.yaml中的Profiles标签中的 OneOrgsOrdererGenesis 这个设置)
此处碰到bug: 没有-channelID
output:
2020-12-28 01:57:27.159 PST [figtxgen] main -> INFO 001 Loading configuration
2020-12-28 01:57:27.164 PST [figtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2020-12-28 01:57:27.164 PST [figtxgen.localconfig] Load -> INFO 003 Loaded configuration: configtx.yaml
2020-12-28 01:57:27.165 PST [figtxgen] doOutputBlock -> INFO 004 Generating genesis block
2020-12-28 01:57:27.165 PST [figtxgen] doOutputBlock -> INFO 005 Creating system channel genesis block
2020-12-28 01:57:27.165 PST [figtxgen] doOutputBlock -> INFO 006 Writing genesis block
6、生成通道配置区块
output:
2020-12-28 02:02:06.871 PST [figtxgen] main -> INFO 001 Loading configuration
2020-12-28 02:02:06.876 PST [figtxgen.localconfig] Load -> INFO 002 Loaded configuration: configtx.yaml
2020-12-28 02:02:06.876 PST [figtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-12-28 02:02:06.878 PST [figtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx
7、准备Docker配置文件
配置docker-orderer.yaml和docker-peer.yaml
(1)docker-orderer.yaml: 启动Orderer服务配置文件
version: ‘2’
services:
(2)docker-peer.yaml: 启动Peer服务配置文件
8、准备部署智能合约
智能合约这里最好是有个单独的文件夹,这样分开比较好。一般路径为
项目下的/chaincode/go/helloworld
9、启动Fabric网络
(1) 启动Orderer
output:
ample …
ample … done
(2) 启动Peer
output:
ample …
ample … done
Creating cli …
Creating cli … done
(3)启动Cli容器
(4) 创建通道
#ORDERER_CA=/opt/gopath/src/github/hyperledger/fabric/peer/crypto/ordererOrganizations/example/ample/msp/ample-cert.pem
或者直接合并:
peer channel create -ample:7050 -c mychannel -f ./ --tls --cafile /opt/gopath/src/github/hyperledger/fabric/peer/crypto/ordererOrganizations/example/ample/msp/ample-cert.pem
或者尝试直接在系统中执行
peer channel create -ample:7050 -c mychannel -f ./ --tls --cafile ${PWD}/crypto-config/ordererOrganizations/example/ample/msp/ample-cert.pem
此处bug:
2020-12-28 10:32:56.482 UTC [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2020-12-28 10:32:56.485 UTC [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
Error: failed to create deliver client for orderer: orderer client failed to connect ample:7050: failed to create new connection: context deadline exceeded
未完:
解决尝试1:
Error: failed to create deliver client :orderer client failed to connect to orderer
解决尝试2:
使用了文档中的过程
用了core.yaml进行docker的通道创建
.2/deploypeer/peerchecklist.html?highlight=core.yaml#checklist-for-a-production-peer
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# export CORE_PEER_TLS_ENABLED=true
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# export CORE_PEER_LOCALMSPID=“Org1MSP”
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# export CORE_PEER_TLS_ROOTCERT_FILE=KaTeX parse error: Expected 'EOF', got '#' at position 155: …bric/helloworld#̲ export CORE_PE…{PWD}/crypto-config/ample/users/Adminample/msp
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# export CORE_PEER_ADDRESS=localhost:7051
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# peer channel create -o localhost:7050 --ample -c mychannel -f ./ --outputBlock ./channel-artifacts/mychannel.block --tls --cafile KaTeX parse error: Expected 'EOF', got '#' at position 404: …bric/helloworld#̲ export FABRIC_…PWD/c
chaincode/ channel-artifacts/ config/ configtx.yaml crypto-config/ crypto-config.yaml
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# export FABRIC_CFG_PATH=KaTeX parse error: Expected 'EOF', got '#' at position 187: …bric/helloworld#̲ export FABRIC_…PWD/c
chaincode/ channel-artifacts/ config/ configtx.yaml crypto-config/ crypto-config.yaml
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# export FABRIC_CFG_PATH=$PWD/config/
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# echo $FABRIC_CFG_PATH
/home/dujunjie/GolandProjects/fabric/helloworld/config/
root@ubuntu:/home/dujunjie/GolandProjects/fabric/helloworld# peer channel create -o localhost:7050 --ample -c mychannel -f ./ --outputBlock ./channel-artifacts/mychannel.block --tls --cafile ${PWD}/crypto-config/ordererOrganizations/example/ample/msp/ample-cert.pem
最后报错
2020-12-28 03:31:53.728 PST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: got unexpected status: FORBIDDEN – config update for existing channel did not pass initial checks: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the ‘Writers’ sub-policies to be satisfied: permission denied
.html
Hyperledger Fabric创建通道抛错Error: got unexpected status: FORBIDDEN – Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied解决方案
安装Hyperledger Fabric,服务整个都跑起来了,但是抛了一个错,Error: got unexpected status: FORBIDDEN – Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied
这个时候找了很多解决的办法,解决思路是,仔细看一下orderer的日志,看清楚它到底是具体的哪一个部分有问题,
看到大多数的问题在于:
1)UTC [cauthdsl] deduplicate -> ERRO 014 Principal deserialization failure (the supplied identity is not valid: x509: certificate signed by unknown authority (possibly because of “x509: ECDSA verification failure” while trying to verify candidate authority certificate “ample”)) for identity
错误原因:由于启动过网络并且更新了证书,在没有删除干净的环境中启动复用的之前的volume,所以导致证书认证失败。
解决方案:执行如下命令删除卷
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
2)这个是我自己的问题,deduplicate -> ERRO 2dd Principal deserialization failure (MSP OrdererMSP is unknown) for identity
其实这个不在创世机构里面的组织, 发起创建channel交易
去查看,docker-compose配置文件中的- ORDERER_GENERAL_LOCALMSPID=OrdererMSP,这个值需要和configtx.yaml配置文件中的组织名称保持一致,否则就会报上面的错误,
解决方案:修改保持两边一致即可
自己的思路:
1、从文档的脚本中找到docker-compose.yaml是如何用命令运行的
2、找到docker-compose.yaml的路径
前两个这个看这个文章
Fabric_超详细的fabric网络搭建03-docker-compose文件的编写
3、解决上面的es to be satisfied: permission denied错误,解决尝试2
最后的解决:
应该是
docker-peer文件中
extra_hosts:- ample:192.168.162.130"
这个内容,主机名+IP,应该是自己的本地IP。因为DOCKER中的IP地址都是0.0.0.0。连接成功。
然后出现了BUG
Error: got unexpected status: FORBIDDEN – config update for existing channel did not pass initial checks: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the ‘Writers’ sub-policies to be satisfied: permission denied
根据百度查阅资料,修改了configtx.yaml之后
又出现了以下错误
Error: got unexpected status: BAD_REQUEST – error validating channel creation transaction for new channel ‘mychannel’, could not successfully apply update to template configuration: error authorizing update: error validating DeltaSet: policy for [Group] /Channel/Application not satisfied: implicit policy evaluation failed - 0 sub-policies were satisfied, but this policy requires 1 of the ‘Admins’ sub-policies to be satisfied
据此难以解决此问题,便感觉是版本差别较大,于是转换思路。直接根据fabric官方的教程,fabric-samples的运行进行分析,并据此写一个hello world。
本文发布于:2024-02-02 04:02:21,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170681792041228.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |