(二)Hyperledger Fabric 1.1安装部署-Fabric Samples

Hyperledger Fabric Samples是官方推荐的First Network,对于熟悉fabric和测试基础环境很有好处。

Fabric Samples源码下载:

使用git下载源码,进入到go安装目录(可以使用命令echo $GOPATH查看go安装目录)。

git clone -b master https://github.com/hyperledger/fabric-samples.git

下载完成后进入到fabric-samples目录

cd fabric-samples

使用git tag命令查看版本列表,根据个人需要将源码切换到对应的版本,本次使用的是1.1版。

git checkout -b v1.1.0


下载二进制文件:

二进制文件官方给出两种方式

curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0(这个方式需要FQ)

或者直接访问下面的网址,访问二进制文件

https://github.com/hyperledger/fabric/blob/master/scripts/bootstrap.sh

也可以新建bootstrap.sh文件,拷贝下面的脚本并执行。

#!/bin/bash

#

# Copyright IBM Corp. All Rights Reserved.

#

# SPDX-License-Identifier: Apache-2.0

#


# if version not passed in, default to latest released version

export VERSION=${1:-1.1.0}

# if ca version not passed in, default to latest released version

export CA_VERSION=${2:-$VERSION}

# current version of thirdparty images (couchdb, kafka and zookeeper) released

export THIRDPARTY_IMAGE_VERSION=0.4.6

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 ccenv javaenv 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

}


dockerThirdPartyImagesPull() {

local THIRDPARTY_TAG=$1

for IMAGES in couchdb kafka zookeeper; do

echo "==> THIRDPARTY DOCKER IMAGE: $IMAGES"

echo

docker pull hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG

docker tag hyperledger/fabric-$IMAGES:$THIRDPARTY_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-$CA_VERSION"}

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

: ${THIRDPARTY_TAG:="$MARCH-$THIRDPARTY_IMAGE_VERSION"}


echo "===> Downloading platform specific fabric 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 "===> Downloading platform specific fabric-ca-client binary"

curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${VERSION}/hyperledger-fabric-ca-${ARCH}-${VERSION}.tar.gz | tar xz

if [ $? != 0 ]; then

echo

echo "------> $VERSION fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----"

echo

fi

which docker >& /dev/null

NODOCKER=$?

if [ "${NODOCKER}" == 0 ]; then


echo "===> Pulling fabric Images"

dockerFabricPull ${FABRIC_TAG}


echo "===> Pulling fabric ca Image"

dockerCaPull ${CA_TAG}


echo "===> Pulling thirdparty docker images"

dockerThirdPartyImagesPull ${THIRDPARTY_TAG}

echo


echo "===> List out hyperledger docker images"

docker images | grep hyperledger*

else

echo "========================================================="

echo "Docker not installed, bypassing download of Fabric images"

echo "========================================================="

fi

这个脚本将下载网络所需的特定二进制文件和镜像。执行成功后会生成bin和config。


bin文件:

(二)Hyperledger Fabric 1.1安装部署-Fabric Samples


config文件:

(二)Hyperledger Fabric 1.1安装部署-Fabric Samples


拉取的镜像:
可以通过docker images命令查看

(二)Hyperledger Fabric 1.1安装部署-Fabric Samples
上述工作完成以后就可以进行Fabric Samples测试了。

上一篇:《交互式程序设计 第2版》一3.3 Processing应用程序基础


下一篇:Ext 2.0 教程 目录