Hyperledger Fabric 1.0 Environment Construction Practice - Continuously updated...

After multiple machines are deployed, the intranet IPs are 10.18.22.221, 10.18.22.222, 10.18.22.223, 10.18.22.224, 10.18.22.225.

Among them, 10.18.22.221 is the orderer node, and the other 4 are peer nodes.

The domain names are orderer.com, peer0.org1.com, peer1.org1.com, peer0.org2.com, peer1.org2.com.

Among them, chaincode is installed on peer0.org1.com, peer0.org2.com, peer1.org2.com by default, and chaincode is not installed on peer1.org1.

After successfully starting the cluster,

1. The process of installing the smart contract chainCode on 10.18.22.223 (peer1.org1.example.com) is as follows:

1. Enter the container of 10.18.22.223 (peer1.org1.example.com) through the following command

docker exec -it cli bash

After entering the container, the default path is as follows:

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

2. Execute the smart contract ChainCode installation command

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

After the command is executed, the log process is as follows:

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" > 

It means that the Chaincode has been installed successfully. This command installs the source code of chaincode into the file system of the peer.

3. Call the command to query the Chaincode

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

After calling this command, the smart contract container will be started. After waiting for a while, the query result will be obtained.

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. Create a new command window and query through docker-ps to find the newly installed chaincode container.

[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

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324962103&siteId=291194637