超级账本Fabric1.0环境搭建实践-持续更新中……

  • 作者:新网
  • 来源:新网
  • 2018-03-27 01:20:13

多机部署后内网IP分别为10.18.22.221,10.18.22.222,10.18.22.223,10.18.22.224,10.18.22.225. 其中10.18.22.221为orderer节点,其余4个为peer节点。 域名分别为orderer.com,peer0.org1.com,peer1.org1.com,peer0.org2...

多机部署后内网IP分别为10.18.22.221,10.18.22.222,10.18.22.223,10.18.22.224,10.18.22.225.

其中10.18.22.221为orderer节点,其余4个为peer节点。

t01350d34d55895ef87.jpg

域名分别为orderer.com,peer0.org1.com,peer1.org1.com,peer0.org2.com,peer1.org2.com.

其中默认在peer0.org1.com,peer0.org2.com,peer1.org2.com上安装了chaincode,在peer1.org1上未安装chaincode。

成功启动集群后,

一、在10.18.22.223(peer1.org1.example.com)上安装智能合约chainCode过程如下:

1、通过下面命令进入10.18.22.223(peer1.org1.example.com)的容器

docker exec -it cli bash

进入容器后,默认路径如下:

root@6e75c97a960a:/opt/gopath/src/github.com/hyperledger/fabric/peer#

2、执行智能合约ChainCode安装命令

peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

命令执行后,日志过程如下:

2018-03-26 02:44:25.468 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP 2018-03-26 02:44:25.469 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity 2018-03-26 02:44:25.469 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc 2018-03-26 02:44:25.469 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc 2018-03-26 02:44:28.521 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 2018-03-26 02:44:30.351 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt 2018-03-26 02:44:30.352 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim 2018-03-26 02:44:30.352 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer 2018-03-26 02:44:30.352 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv 2018-03-26 02:44:30.352 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done 2018-03-26 02:44:30.356 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A8A070A5C08031A0C088EBDE1D50510...5F74FD270000FFFFCEF44F9B002C0000 2018-03-26 02:44:30.356 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 9D17182BF883747B383970BEFD9C4DEBB0BB07ADCADD5F0C3C4DF5D9D57F12A0 2018-03-26 02:44:30.379 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" >

说明该Chaincode已经安装成功。这个命令将chaincode的源码安装到该peer节点的文件系统中。

3、调用命令查询Chaincode

peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'

调用该命令后,将会启动智能合约容器。等待一段时间,将得到查询结果。

root@6e75c97a960a:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' 2018-03-26 02:58:50.594 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP 2018-03-26 02:58:50.594 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity 2018-03-26 02:58:50.594 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc 2018-03-26 02:58:50.595 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc 2018-03-26 02:58:50.595 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C08EAC3E1D50510...6D7963631A0A0A0571756572790A0161 2018-03-26 02:58:50.595 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: B4B927D16A7B0B16747B264E0336F79769F5F841F67B1C70C2B75431ACD1E168 Query Result: 90 2018-03-26 02:58:50.618 UTC [main] main -> INFO 007 Exiting.....

4、新建一个命令窗口,通过docker-ps 查询,已经能够查到,新安装的链码容器。

[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d20a155e430e dev-peer1.org1.example.com-mycc-1.0 "chaincode -peer.add…" 18 seconds ago Up 16 seconds dev-peer1.org1.example.com-mycc-1.0 6e75c97a960a hyperledger/fabric-tools "/bin/bash" 28 minutes ago Up 28 minutes cli 0d70e326c8c5 hyperledger/fabric-peer "peer node start" 28 minutes ago Up 28 minutes 0.0.0.0:7051-7053->7051-7053/tcp peer1.org1.example.com

 

免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:operations@xinnet.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

免费咨询获取折扣