Mac OS搭建Hyperledger Fabric官方Demo一

weixin_34075551發表於2017-09-15

Demo地址

在嘗試Demo的時候遇到了不少坑,這裡記錄一下:

問題一

在執行./startFabric.sh時報錯ERROR: manifest for hyperledger/fabric-couchdb:latest not found

# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1

docker-compose -f docker-compose.yml down
Removing network net_basic

docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb
Creating network "net_basic" with the default driver
Pulling couchdb (hyperledger/fabric-couchdb:latest)...
ERROR: manifest for hyperledger/fabric-couchdb:latest not found

解決辦法

查了一下,貌似是沒有配置Hyperledger Fabric Samples的工具庫

問題二

按照Hyperledger Fabric Samples的教程,在執行curl -sSL https://goo.gl/Gci9ZX | bash時,卡死了,和可能是網路問題;

解決辦法:

在瀏覽器裡開啟https://goo.gl/Gci9ZX,其程式碼如下

#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

export VERSION=1.0.2
export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
#Set MARCH variable i.e ppc64le,s390x,x86_64,i386
MARCH=`uname -m`

dockerFabricPull() {
  local FABRIC_TAG=$1
  for IMAGES in peer orderer couchdb ccenv javaenv kafka zookeeper tools; do
      echo "==> FABRIC IMAGE: $IMAGES"
      echo
      docker pull hyperledger/fabric-$IMAGES:$FABRIC_TAG
      docker tag hyperledger/fabric-$IMAGES:$FABRIC_TAG hyperledger/fabric-$IMAGES
  done
}

dockerCaPull() {
      local CA_TAG=$1
      echo "==> FABRIC CA IMAGE"
      echo
      docker pull hyperledger/fabric-ca:$CA_TAG
      docker tag hyperledger/fabric-ca:$CA_TAG hyperledger/fabric-ca
}

: ${CA_TAG:="$MARCH-$VERSION"}
: ${FABRIC_TAG:="$MARCH-$VERSION"}

echo "===> Downloading platform binaries"
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz

echo "===> Pulling fabric Images"
dockerFabricPull ${FABRIC_TAG}

echo "===> Pulling fabric ca Image"
dockerCaPull ${CA_TAG}
echo
echo "===> List out hyperledger docker images"
docker images | grep hyperledger*

將程式碼複製到fabric-samples/init.sh,然後執行
./init.sh
開始自動下載需要的docker image,網速不給力,這裡需要較長時間,可以給Docker配置代理,配置代理教程

iMacdeiMac-2:fabric-samples imactwo$ ./init.sh 
===> Downloading platform binaries
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.5M  100 22.5M    0     0   257k      0  0:01:29  0:01:29 --:--:--  248k
===> Pulling fabric Images
==> FABRIC IMAGE: peer

x86_64-1.0.2: Pulling from hyperledger/fabric-peer
d5c6f90da05d: Already exists 
1300883d87d5: Already exists 
c220aa3cfc1b: Already exists 
2e9398f099dc: Already exists 
dc27a084064f: Already exists 
87675a6d4030: Already exists 
93e601aafda8: Already exists 
51fc526ed766: Already exists 
e0386e9ee7cf: Pull complete 
a75d8afcee28: Pull complete 
Digest: sha256:ce6e3c3d0f71641020184e4fe0615c2e65b5181664bad3d05942091917b73e28
Status: Downloaded newer image for hyperledger/fabric-peer:x86_64-1.0.2
==> FABRIC IMAGE: orderer

x86_64-1.0.2: Pulling from hyperledger/fabric-orderer
Digest: sha256:6427715d8c56b8778de30c7895287d0dd7bb9adb2f895337aac2dd3d0dcabca7
Status: Downloaded newer image for hyperledger/fabric-orderer:x86_64-1.0.2
==> FABRIC IMAGE: couchdb

x86_64-1.0.2: Pulling from hyperledger/fabric-couchdb
d5c6f90da05d: Already exists 
1300883d87d5: Already exists 
c220aa3cfc1b: Already exists 
2e9398f099dc: Already exists 
dc27a084064f: Already exists 
87675a6d4030: Already exists 
93e601aafda8: Already exists 
6be6b5cbce6b: Already exists 
c90d7a44426d: Pull complete 
9767b1c8440b: Pull complete 
b9b680c73863: Pull complete 
910808d7b46d: Pull complete 
b2b400af2b65: Pull complete 
656c0e3d1026: Pull complete 
fd537a07cc88: Pull complete 
fb80790f85e2: Pull complete 
6b4be879a573: Pull complete 
24e26e38b19c: Pull complete 
ba4d4ddd242e: Pull complete 
Digest: sha256:5364d4f3e0844455195cc82626675cf01a873ba3b762d156efffb239740c2415
Status: Downloaded newer image for hyperledger/fabric-couchdb:x86_64-1.0.2
==> FABRIC IMAGE: ccenv

x86_64-1.0.2: Pulling from hyperledger/fabric-ccenv
d5c6f90da05d: Already exists 
1300883d87d5: Already exists 
c220aa3cfc1b: Already exists 
2e9398f099dc: Already exists 
dc27a084064f: Already exists 
87675a6d4030: Already exists 
93e601aafda8: Already exists 
6be6b5cbce6b: Already exists 
c90d7a44426d: Already exists 
9767b1c8440b: Already exists 
b9b680c73863: Already exists 
166a55562f41: Pull complete 
3d603cc86908: Pull complete 
5e68f74a4f28: Pull complete 
Digest: sha256:3ad83a302e633dea8fa3d9d95b3e68919b7754d81bd521d1c3744bd251d5a526
Status: Downloaded newer image for hyperledger/fabric-ccenv:x86_64-1.0.2
==> FABRIC IMAGE: javaenv

x86_64-1.0.2: Pulling from hyperledger/fabric-javaenv
d5c6f90da05d: Already exists 
1300883d87d5: Already exists 
c220aa3cfc1b: Already exists 
2e9398f099dc: Already exists 
dc27a084064f: Already exists 
87675a6d4030: Already exists 
93e601aafda8: Already exists 
6be6b5cbce6b: Already exists 
c90d7a44426d: Already exists 
9767b1c8440b: Already exists 
b9b680c73863: Already exists 
f27ca7df950b: Pull complete 
6bdffd82de79: Pull complete 
b049ece410a1: Pull complete 
d6a291b77d29: Pull complete 
7cb4541e382f: Pull complete 
b31b833bb285: Pull complete 
643fd0d667f7: Pull complete 
935ca4c299df: Pull complete 
Digest: sha256:3cfb1ccb0b17e58a2a903a68959aa25e53dd3eaeefccd969944efd4b766541aa
Status: Downloaded newer image for hyperledger/fabric-javaenv:x86_64-1.0.2
==> FABRIC IMAGE: kafka

x86_64-1.0.2: Pulling from hyperledger/fabric-kafka
d5c6f90da05d: Already exists 
1300883d87d5: Already exists 
c220aa3cfc1b: Already exists 
2e9398f099dc: Already exists 
dc27a084064f: Already exists 
87675a6d4030: Already exists 
93e601aafda8: Already exists 
6be6b5cbce6b: Already exists 
c90d7a44426d: Already exists 
9767b1c8440b: Already exists 
b9b680c73863: Already exists 
acb25f369ac3: Pull complete 
16930d8f4113: Pull complete 
4641f537b20c: Pull complete 
Digest: sha256:ebbfd837ed010eac27007b7203074d3621969431e07fd6a874dc4c057bfbf0a2
Status: Downloaded newer image for hyperledger/fabric-kafka:x86_64-1.0.2
==> FABRIC IMAGE: zookeeper

x86_64-1.0.2: Pulling from hyperledger/fabric-zookeeper
d5c6f90da05d: Already exists 
1300883d87d5: Already exists 
c220aa3cfc1b: Already exists 
2e9398f099dc: Already exists 
dc27a084064f: Already exists 
87675a6d4030: Already exists 
93e601aafda8: Already exists 
6be6b5cbce6b: Already exists 
c90d7a44426d: Already exists 
9767b1c8440b: Already exists 
b9b680c73863: Already exists 
44885f365644: Pull complete 
46ece701894d: Pull complete 
2d416318c4a3: Pull complete 
f65b80d465e8: Pull complete 
Digest: sha256:ef981366251ad87d20f2d6de85f1c3524dd31d3551e6f53274925066c5b1d849
Status: Downloaded newer image for hyperledger/fabric-zookeeper:x86_64-1.0.2
==> FABRIC IMAGE: tools

x86_64-1.0.2: Pulling from hyperledger/fabric-tools
d5c6f90da05d: Already exists 
1300883d87d5: Already exists 
c220aa3cfc1b: Already exists 
2e9398f099dc: Already exists 
dc27a084064f: Already exists 
87675a6d4030: Already exists 
93e601aafda8: Already exists 
6be6b5cbce6b: Already exists 
c90d7a44426d: Already exists 
9767b1c8440b: Already exists 
b9b680c73863: Already exists 
0cb2dbc2f8a2: Pull complete 
05edc6c8e54b: Pull complete 
1a8edd3b0b2a: Pull complete 
579fce528924: Pull complete 
0c728eabbff4: Pull complete 
Digest: sha256:9323ebacecc60f20562a49de201bd0a8b7852d3d9349a8916a66df1203fd38b0
Status: Downloaded newer image for hyperledger/fabric-tools:x86_64-1.0.2
===> Pulling fabric ca Image
==> FABRIC CA IMAGE

x86_64-1.0.2: Pulling from hyperledger/fabric-ca
aafe6b5e13de: Pull complete 
0a2b43a72660: Pull complete 
18bdd1e546d2: Pull complete 
8198342c3e05: Pull complete 
f56970a44fd4: Pull complete 
e32b597e7839: Pull complete 
a6e362fc71c4: Pull complete 
b42cff702f8a: Pull complete 
fd742d0d9134: Pull complete 
1af663083463: Pull complete 
aeef9e452233: Pull complete 
Digest: sha256:25ab46a951c17b3034b3555b339ba4a985148668959f96152a1e91bbd1c7dd57
Status: Downloaded newer image for hyperledger/fabric-ca:x86_64-1.0.2

===> List out hyperledger docker images
hyperledger/fabric-ca                               latest              7e53be14f804        10 days ago         238 MB
hyperledger/fabric-ca                               x86_64-1.0.2        7e53be14f804        10 days ago         238 MB
hyperledger/fabric-tools                            latest              ba9750b2565d        10 days ago         1.33 GB
hyperledger/fabric-tools                            x86_64-1.0.2        ba9750b2565d        10 days ago         1.33 GB
hyperledger/fabric-couchdb                          latest              3f922f54bd68        10 days ago         1.47 GB
hyperledger/fabric-couchdb                          x86_64-1.0.2        3f922f54bd68        10 days ago         1.47 GB
hyperledger/fabric-kafka                            latest              0b4b1d249e65        10 days ago         1.29 GB
hyperledger/fabric-kafka                            x86_64-1.0.2        0b4b1d249e65        10 days ago         1.29 GB
hyperledger/fabric-zookeeper                        latest              1efb063147d3        10 days ago         1.3 GB
hyperledger/fabric-zookeeper                        x86_64-1.0.2        1efb063147d3        10 days ago         1.3 GB
hyperledger/fabric-orderer                          latest              6efd17e86e65        10 days ago         151 MB
hyperledger/fabric-orderer                          x86_64-1.0.2        6efd17e86e65        10 days ago         151 MB
registry.docker-cn.com/hyperledger/fabric-orderer   x86_64-1.0.2        6efd17e86e65        10 days ago         151 MB
hyperledger/fabric-peer                             latest              0e2ed51971c9        10 days ago         154 MB
hyperledger/fabric-peer                             x86_64-1.0.2        0e2ed51971c9        10 days ago         154 MB
hyperledger/fabric-javaenv                          latest              0be45dbd7ff4        10 days ago         1.41 GB
hyperledger/fabric-javaenv                          x86_64-1.0.2        0be45dbd7ff4        10 days ago         1.41 GB
hyperledger/fabric-ccenv                            latest              d0f166e1a89e        10 days ago         1.28 GB
hyperledger/fabric-ccenv                            x86_64-1.0.2        d0f166e1a89e        10 days ago         1.28 GB

問題三

在npm install 時,因為使用了node版本管理器n,報錯如下:

npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/fs'


   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 5.0.0 → 5.4.1    │
   │     Run npm i -g npm to update      │
   │                                     │
   ╰─────────────────────────────────────╯


npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/imactwo/.npm/_logs/2017-09-12T05_37_44_321Z-debug.log

解決辦法

此時node版本為8.0.0,先用n將node版本改為6.2.2,再使用npm i -g npm安裝最新版的npm

問題四

https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html上有如下提示:

5379947-4793ff66fe3b8a39.png
螢幕快照 2017-09-12 下午2.40.00.png

使用n安裝node 6.9.5,因為網路問題,下載特別慢,查到這個部落格,配置加速來提高下載速度

PROJECT_NAME="node" PROJECT_URL="https://npm.taobao.org/mirrors/node/" n project 6.9.5

相關文章