我无法在 Hyperledge Fabric 中实例化链代码。
执行时:
peer chaincode instantiate -o orderer -n test_cc -C test-channel -v 0.1 -c '{"Args":["initLedger"]}'
我收到错误:
peer0 | 2018-04-17 13:02:11.097 UTC [dockercontroller] Start -> ERRO 046 start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
在互联网上搜索时,错误消息与[ OCI Runtimer Error when installing Hyperledger Chaincode via Java-SDK 上的原始帖子相同。和[OCI runtime error when sending Hyperledger Fabric's chaincode instantiation request to peers ,但这些帖子的评论并没有让我找到解决方案。
我正在使用以下软件版本: super 账本1.1.0 Docker 版本 18.03.0-ce(在 Linux 上),Hyperledger Docker 镜像:x86_64-1.1.0
以下步骤成功:
- 构建链码。代码编译没有错误。除了两个必需的“github.com/hyperledger/fabric/core/chaincode/shim”之外,我没有包含任何依赖项 “github.com/hyperledger/fabric/protos/peer”
- 打包链代码。
- 签署链代码。
- 安装链代码(它最终位于对等方的/var/hyperledger/products/chaincodes/test_cc.0.1 中。
(根据 Hyperledger 文档的步骤:[ http://hyperledger-fabric-docs.readthedocs.io/en/latest/chaincode4noah.html] )
在 CLI Docker 容器中,文件位于目录 /opt/gopath/src/chaincode/go/test_cc/
中,其中存在 4 个文件:test_cc、test_cc.go 、test_cc_pack.out、test_cc_signed_pack.out
(二进制文件、源文件、打包文件和签名包文件)。
排序者和同伴的完整输出是:
orderer | 2018-04-17 13:29:43.617 UTC [orderer/common/server] Broadcast -> DEBU 167 Starting new Broadcast handler
orderer | 2018-04-17 13:29:43.617 UTC [orderer/common/broadcast] Handle -> DEBU 168 Starting new broadcast loop for 172.18.0.6:41228
couchdb | [notice] 2018-04-17T13:29:43.624931Z nonode@nohost <0.16042.3> b5d38cd27d couchdb:5984 172.18.0.5 undefined GET /test-channel_lscc/test_cc?attachments=true 404 ok 2
peer | 2018-04-17 13:29:44.416 UTC [dockercontroller] Start -> ERRO 04a start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer | 2018-04-17 13:29:44.647 UTC [chaincode] Launch -> ERRO 04b launchAndWaitForRegister failed: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer |
peer | error starting container
peer | 2018-04-17 13:29:44.647 UTC [endorser] simulateProposal -> ERRO 04c [test-channel][39e4414a] failed to invoke chaincode name:"lscc" , error: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer |
peer | error starting container
orderer | 2018-04-17 13:29:44.648 UTC [orderer/common/broadcast] Handle -> DEBU 169 Received EOF from 172.18.0.6:41228, hangup
orderer | 2018-04-17 13:29:44.648 UTC [orderer/common/server] func1 -> DEBU 16a Closing Broadcast stream
看起来好像存在一些路径问题,但是链代码容器的创建过程以及影响此过程的变量。
我已经解决这个问题几天了(!),尝试了所有路径组合,例如将文件放入 /opt/gopath/bin
等,但无济于事。
有人可以解决这个问题吗?或者知道正确的路径是什么以及它们在哪里,或者应该在哪里定义它们?
谢谢
最佳答案
问题是在 Go 源文件中我使用了“package test_package”,它在构建时不会创建可执行文件,而是创建可链接的对象文件。
在我的 Go 文件中包含“package main”,然后重建和重新打包,使“peer chaincode install”和“peer chaincode instantiate”命令按预期工作。
关于go - Hyperledger-fabric 无法实例化链代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49880334/