如何解决对等生命周期链代码approveformyorg错误:发送事务失败:状态异常:NOT_FOUND-频道不存在
我在进行链式代码批准时遇到以下问题:错误:无法发送交易:出现意外状态:NOT_FOUND-通道不存在。我已成功执行链式代码打包和链式代码安装操作,但是执行链式代码批准时我无法继续。你有没有遇到这样的问题?谢谢
以下是当前节点的信息:
bash-5.0#对等频道列表
2020-09-21 10:18:18.939 UTC [channelCmd] InitCmdFactory-> INFO 001已初始化Endorser和Orderer连接
渠道同行已加入:
示例频道
已安装bash-5.0#对等生命周期链代码查询
已在对等节点上安装链码:
程序包ID:mycc_1:2499940fe909cc71a661bf79a3d78523a43c4d2879f4456e6cbe4a2a5a5e5246,标签:mycc_1
======================== 2020-09-22 =================== =
这是我的configtx.yaml
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP
MSPDir: ./crypto-config/ordererOrganizations/example.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
- &Org1
Name: Org1MSP
ID: Org1MSP
MSPDir: ./crypto-config/peerOrganizations/org1.example.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('Org1MSP.admin','Org1MSP.peer','Org1MSP.client')"
Writers:
Type: Signature
Rule: "OR('Org1MSP.admin','Org1MSP.client')"
Admins:
Type: Signature
Rule: "OR('Org1MSP.admin')"
AnchorPeers:
- Host: peer0.org1.example.com
Port: 7051
- &Org2
Name: Org2MSP
ID: Org2MSP
MSPDir: ./crypto-config/peerOrganizations/org2.example.com/msp
Policies:
Readers:
Type: Signature
Rule: "OR('Org2MSP.admin','Org2MSP.peer','Org2MSP.client')"
Writers:
Type: Signature
Rule: "OR('Org2MSP.admin','Org2MSP.client')"
Admins:
Type: Signature
Rule: "OR('Org2MSP.admin')"
AnchorPeers:
- Host: peer0.org2.example.com
Port: 7051
Capabilities:
Channel: &ChannelCapabilities
V2_0: true
Orderer: &OrdererCapabilities
V2_0: true
Application: &ApplicationCapabilities
V2_0: true
Application: &ApplicationDefaults
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ApplicationCapabilities
Orderer: &OrdererDefaults
OrdererType: etcdraft
Addresses: # orderer
- orderer.example.com:7050
- orderer2.example.com:7050
- orderer3.example.com:7050
- orderer4.example.com:7050
- orderer5.example.com:7050
BatchTimeout: 2s
BatchSize:
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
Channel: &ChannelDefaults
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ChannelCapabilities
Profiles:
TwoOrgsChannel:
Consortium: SampleConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
Capabilities:
<<: *ApplicationCapabilities
SampleMultiNodeEtcdRaft:
<<: *ChannelDefaults
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
OrdererType: etcdraft
EtcdRaft:
Consenters:
- Host: orderer.example.com
Port: 7050
ClientTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
ServerTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
- Host: orderer2.example.com
Port: 7050
ClientTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
ServerTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt
- Host: orderer3.example.com
Port: 7050
ClientTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
ServerTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt
- Host: orderer4.example.com
Port: 7050
ClientTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt
ServerTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt
- Host: orderer5.example.com
Port: 7050
ClientTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer5.example.com/tls/server.crt
ServerTLSCert: ./crypto-config/ordererOrganizations/example.com/orderers/orderer5.example.com/tls/server.crt
Addresses:
- orderer.example.com:7050
- orderer2.example.com:7050
- orderer3.example.com:7050
- orderer4.example.com:7050
- orderer5.example.com:7050
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- <<: *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
这是我的主机列表:
|order.example.com|182.23.20.1|order|
|peer0.org1.example.com|182.23.20.2|org1|
|peer1.org1.example.com|182.23.20.3|org1|
|peer0.org2.example.com|182.23.20.4|org2|
|peer1.org2.example.com|182.23.20.5|org2|
这就是我的做法
第一步:生成证书文件
cryptogen generate --config=./crypto-config.yaml
第二步:创建系统渠道
configtxgen -profile SampleMultiNodeEtcdRaft -outputBlock ../channel-artifacts/orderer.genesis.block -channelID system-channel
第三步:创建应用程序渠道
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ../channel-artifacts/example-channel.tx -channelID example-channel
第四步:锚节点更新
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ../channel-artifacts/Org1MSPanchors.tx -channelID example-channel -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ../channel-artifacts/Org2MSPanchors.tx -channelID example-channel -asOrg Org2MSP
第五步:在peer0.org1节点上的节点上创建频道
peer channel create -o orderer.example.com:7050 -c example-channel \
-f ./channel-artifacts/example-channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
第六步:加入频道和锚节点更新
peer channel join -b example-channel.block
#Anchor node update
peer channel update -o orderer.example.com:7050 -c example-channel -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
其他对等节点也是如此 第七步:链码管理器,使用fabcar
# 1:gradlew installDist
cd ~/go/src/github.com/hyperledger/example/chaincode/fabcar/java
./gradlew installDist
#2:chaincode package
peer lifecycle chaincode package mycc.tar.gz \
--path /opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/fabcar/java/build/install/fabcar \
--lang java --label mycc_1
#3:chaincode install
peer lifecycle chaincode install mycc.tar.gz
对于其他所有节点都是如此 我尝试使用“对等生命周期链码查询安装”命令在每个对等体上执行,并得到以下结果:
Installed chaincodes on peer:
Package ID: mycc_1:2499940fe909cc71a661bf79a3d78523a43c4d2879f4456e6cbe4a2a5a5e5246,Label: mycc_1
#4:chaincode批准formyorg
export CC_PACKAGE_ID=mycc_1:2499940fe909cc71a661bf79a3d78523a43c4d2879f4456e6cbe4a2a5a5e5246
# cafile path
export CF=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
# cc_name
export CC_NAME=example-channel
peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 \
--channelID $CC_NAME --name mycc --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls \
--cafile $CF --signature-policy "OR('Org1MSP.peer','Org2MSP.peer')"
我执行命令时出现错误:
Error: failed to send transaction: got unexpected status: NOT_FOUND -- channel does not exist
最后,在上述补充程序下方的任何上述过程中都没有错误消息!
你有一个好的解决方案,想想!!!
解决方法
请确保按照所有步骤正确创建频道。
这些步骤是:
- 使用configtxgen创建渠道交易工件
- 使用“对等通道创建”命令在网络上创建通道
- 使用“对等频道加入”加入该频道上的对等人
现在,当您进行批准时,请确保在批准时间中使用“ --channelID”标志。
,这似乎是您的订购者服务引起的错误。尽管您在配置文件configtx.yaml
上定义了5个订购者节点,但是在日志中仅显示一个:|order.example.com|182.23.20.1|order|
。因此,您似乎并没有开始所有这5个订购者。您是否检查过order.example.com
日志?
但是,您可以尝试以下一项或两项更改?
- 我认为您应该尝试从配置文件中删除其余订购者的配置,即您只应定义
orderer.example.com
。然后,您应该再次执行所有步骤。请记住删除先前创建的Docker容器和卷。 - 第二项测试可能是复制
orderer.example.com
的配置。您将尝试复制orderer.example.com
的定义。因为似乎您没有在定义和启动应该运行的其余订购者。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。