Hyperledger Fabric部署的坑(更新中)

weixin_34214500發表於2018-11-06

1.映象需與fabric版本一致

fabric執行所需要的映象一共是12種

可以通過輸入docker images檢視你已下載的映象。

如果發現有少的映象則用下述語句下載,每條語句對應下載每一個映象,請根據所缺失的映象選擇語句並執行:

docker pull hyperledger/fabric-tools:x86_64-1.0.0
docker pull hyperledger/fabric-couchdb:x86_64-1.0.0
docker pull hyperledger/fabric-kafka:x86_64-1.0.0
docker pull hyperledger/fabric-orderer:x86_64-1.0.0
docker pull hyperledger/fabric-peer:x86_64-1.0.0
docker pull hyperledger/fabric-ca:x86_64-1.0.0
docker pull hyperledger/fabric-ccenv:x86_64-1.0.0
docker pull hyperledger/fabric-baseimage:x86_64-0.4.7
docker pull hyperledger/fabric-baseos:x86_64-0.4.7
docker pull hyperledger/fabric-zookeeper:x86_64-1.0.0
docker pull hyperledger/fabric-javaenv:x86_64-1.0.0
docker pull hyperledger/fabric-membersrvc:latest

請注意每個映象的版本號!大多數往往缺少baseimage,baseos,membersrvc這三種。

2 錯誤彙總

1.ERRO 001 Cannot run peer because error when setting up MSP from directory........msp.......
2.ERRO 001 Cannot run peer because error when setting up MSP from directory /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp......

解決辦法:

這兩個問題都是因為fabric版本和docker映象版本不一致
檢視fabric branch:git branch -a

結果帶*就是你的branch,如果不是v1.0.0,就
git checkout v1.0.0

當然,也可以下載對應的映象(如果版本為v 1.1):

cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/
source download-dockerimages.sh -c x86_64-1.1.0 -f x86_64-1.1.0

再檢視下fabric目錄下: make cryptogen。如果返回

CGO_CFLAGS=" " GOBIN=/opt/gopath/src/github.com/hyperledger/fabric/build/bin go install -tags "" -ldflags "-X github.com/hyperledger/fabric/common/tools/cryptogen/metadata.Version=1.0.1" github.com/hyperledger/fabric/common/tools/cryptogen
github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11
vendor/github.com/miekg/pkcs11/pkcs11.go:29:18: fatal error: ltdl.h: No such file or directory
compilation terminated.
Makefile:227: recipe for target 'build/bin/cryptogen' failed
make: *** [build/bin/cryptogen] Error 2

表明缺少ltdl.h檔案。執行以下命令:

apt-get install libtool libltdl-dev
make cryptogen

3 如果出現:

Error: Error endorsing chaincode: rpc error: code = Unknown desc = Error starting container: API error (404): {"message":"network e2ecli_default not found"}

解決辦法:

cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/base
gedit peer-base.yaml
開啟檔案後將e2ecli_default修改為e2e_cli_default

4 go語言的環境問題

注意:cd ~cd /home是不一樣的!!!

7 docker刪除相同的映象出錯解決:

3644599-cf633f5cd9490508.jpg
[圖片上傳中...(微信截圖_20181101174638.png-77585f-1541473389553-0)]

8 出現DEBU 001 Returning existing local MSP

3644599-3ec5dc5e3e1a0c5d.png
微信截圖_20181101174638.png

有一種解決方法是:

執行一下命令  vim /etc/hosts
增加以下內容
172.16.10.188 orderer.example.com

但是,我覺的這種方法沒有什麼效果,因為我執行了這句話後,也沒解決問題

後來,看到一篇帖子,終於解決了:

是因為環境遺留的問題

解決方式,重新關閉網路

./network_setup.sh down mychannel

root@cc-fibric:/home/cc/go/src/github.com/hyperledger/fabric/examples/e2e_cli# ./network_setup.sh down mychannel
WARNING: The CHANNEL_NAME variable is not set. Defaulting to a blank string.
WARNING: The TIMEOUT variable is not set. Defaulting to a blank string.
Stopping cli                    ... done
Stopping kafka3                 ... done
Stopping kafka0                 ... done
Stopping kafka1                 ... done
Stopping kafka2                 ... done
Stopping peer1.org2.example.com ... done
Stopping zookeeper0             ... done
Stopping zookeeper2             ... done
Stopping zookeeper1             ... done
Stopping peer0.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Stopping peer1.org1.example.com ... done
Removing cli                    ... done
Removing orderer.example.com    ... done
Removing kafka3                 ... done
Removing kafka0                 ... done
Removing kafka1                 ... done
Removing kafka2                 ... done
Removing peer1.org2.example.com ... done
Removing zookeeper0             ... done
Removing zookeeper2             ... done
Removing zookeeper1             ... done
Removing peer0.org1.example.com ... done
Removing peer0.org2.example.com ... done
Removing peer1.org1.example.com ... done
Removing network e2e_cli_default
---- No containers available for deletion ----
---- No images available for deletion ----

當然,也有可能是e2e_cli檔案沒有許可權讀寫

後記:

我一開始是版本錯了,是v1.1 的版,下的docker映象卻是v1.0.0;

接下來,估計是由於前面執行過一次./network_setup.sh up ,所以有環境殘餘。
在執行完./network_setup.sh down mychannel後,
再啟動

./network_setup.sh up

root@cc-fibric:/home/cc/go/src/github.com/hyperledger/fabric/examples/e2e_cli# ./network_setup.sh up
setting to default channel 'mychannel'
mychannel

Using cryptogen -> /home/cc/go/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
org2.example.com

Using configtxgen -> /home/cc/go/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################

相關文章