在fabric环境搭建过程中,我试了很多次都没有完成。原因是创建client失败。虽然网上有关于这个问题的教程,比如更改host,都没有解决如下问题:
Creating kafka2 ...
Creating kafka1 ...
Creating kafka2
Creating kafka3
Creating kafka0
Creating kafka3 ... done
Creating orderer.example.com ...
Creating orderer.example.com ... done
Creating cli ...
Creating cli ... done
____ _____ _ ____ _____ _____ ____ _____
/ ___| |_ _| / \ | _ \ |_ _| | ____| |___ \ | ____|
\___ \ | | / _ \ | |_) | | | _____ | _| __) | | _|
___) | | | / ___ \ | _ < | | |_____| | |___ / __/ | |___
|____/ |_| /_/ \_\ |_| \_\ |_| |_____| |_____| |_____|
Channel name : mychannel
Check orderering service availability...
Attempting to fetch system channel 'testchainid' ...4 secs
Attempting to fetch system channel 'testchainid' ...33 secs
Attempting to fetch system channel 'testchainid' ...59 secs
2018-03-28 02:14:34.999 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-03-28 02:14:35.098 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-03-28 02:14:55.260 UTC [grpc] Printf -> DEBU 003 grpc: addrConn.resetTransport failed to create client transport: connection error: desc = "transport: Error while dialing dial tcp: i/o timeout"; Reconnecting to {orderer.example.com:7050 <nil>}
Error: Error connecting due to rpc error: code = Unavailable desc = grpc: the connection is unavailable
Usage:
peer channel fetch <newest|oldest|config|(number)> [outputfile] [flags]
Flags:
-c, --channelID string In case of a newChain command, the channel ID to create.
Global Flags:
--cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
--logging-level string Default logging level and overrides, see core.yaml for full syntax
-o, --orderer string Ordering service endpoint
--test.coverprofile string Done (default "coverage.cov")
--tls Use TLS when communicating with the orderer endpoint
-v, --version Display current version of fabric peer server
!!!!!!!!!!!!!!! Ordering Service is not available, Please try again ... !!!!!!!!!!!!!!!!
其实这个问题出现的原因很简单,docker的版本不符合,虽然网上很多的教程都提到要使用软连接git branch更改分支,但是并没什么用处,除非是运气特别好(我第一次成功了)。后来再次尝试仍然失败。因此需要重新修订这个,直接下载1.0版本,下载语句如下:
git clone -b release-1.0 https://github.com/hyperledger/fabric
之后成功:
Installing chaincode on org2/peer3...
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
2018-11-03 07:15:12.844 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-03 07:15:12.844 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-03 07:15:12.844 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-03 07:15:12.844 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-03 07:15:12.894 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-11-03 07:15:13.024 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2018-11-03 07:15:13.024 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-11-03 07:15:13.024 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-11-03 07:15:13.024 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2018-11-03 07:15:13.024 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2018-11-03 07:15:13.026 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A89070A5B08031A0B088196F5DE0510...5F74FD270000FFFFCEF44F9B002C0000
2018-11-03 07:15:13.026 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 62066F9E10DF1CAB8647452DFE1117402D2D33536654A99954EC30B2511111D5
2018-11-03 07:15:13.032 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:<status:200 payload:"OK" >
2018-11-03 07:15:13.032 UTC [main] main -> INFO 00e Exiting.....
===================== Chaincode is installed on remote peer PEER3 =====================
Querying chaincode on org2/peer3...
===================== Querying on PEER3 on channel 'mychannel'... =====================
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID=Org2MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
Attempting to Query PEER3 ...3 secs
2018-11-03 07:15:16.078 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-11-03 07:15:16.078 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-11-03 07:15:16.078 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-11-03 07:15:16.078 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-11-03 07:15:16.078 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A94070A6608031A0B088496F5DE0510...6D7963631A0A0A0571756572790A0161
2018-11-03 07:15:16.078 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 5E2C38C7A31DB53D27D2687EB90F95C3AD92B301914C757D1381EBEA37051613
Query Result: 90
2018-11-03 07:15:34.793 UTC [main] main -> INFO 007 Exiting.....
===================== Query on PEER3 on channel 'mychannel' is successful =====================
===================== All GOOD, End-2-End execution completed =====================
_____ _ _ ____ _____ ____ _____
| ____| | \ | | | _ \ | ____| |___ \ | ____|
| _| | \| | | | | | _____ | _| __) | | _|
| |___ | |\ | | |_| | |_____| | |___ / __/ | |___
|_____| |_| \_| |____/ |_____| |_____| |_____|