本文共 3314 字,大约阅读时间需要 11 分钟。
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 versionexport VERSION=${1:-1.1.0}# if ca version not passed in, default to latest released versionexport CA_VERSION=${2:-$VERSION}# current version of thirdparty images (couchdb, kafka and zookeeper) releasedexport THIRDPARTY_IMAGE_VERSION=0.4.6export 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,i386MARCH=`uname -m`dockerFabricPull() {local FABRIC_TAG=$1for IMAGES in peer orderer ccenv javaenv tools; doecho "==> FABRIC IMAGE: $IMAGES"echodocker pull hyperledger/fabric-$IMAGES:$FABRIC_TAGdocker tag hyperledger/fabric-$IMAGES:$FABRIC_TAG hyperledger/fabric-$IMAGESdone}dockerThirdPartyImagesPull() {local THIRDPARTY_TAG=$1for IMAGES in couchdb kafka zookeeper; doecho "==> THIRDPARTY DOCKER IMAGE: $IMAGES"echodocker pull hyperledger/fabric-$IMAGES:$THIRDPARTY_TAGdocker tag hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG hyperledger/fabric-$IMAGESdone}dockerCaPull() {local CA_TAG=$1echo "==> FABRIC CA IMAGE"echodocker pull hyperledger/fabric-ca:$CA_TAGdocker 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 xzecho "===> 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 xzif [ $? != 0 ]; thenechoecho "------> $VERSION fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----"echofiwhich docker >& /dev/nullNODOCKER=$?if [ "${NODOCKER}" == 0 ]; thenecho "===> Pulling fabric Images"dockerFabricPull ${FABRIC_TAG}echo "===> Pulling fabric ca Image"dockerCaPull ${CA_TAG}echo "===> Pulling thirdparty docker images"dockerThirdPartyImagesPull ${THIRDPARTY_TAG}echoecho "===> List out hyperledger docker images"docker images | grep hyperledger*elseecho "========================================================="echo "Docker not installed, bypassing download of Fabric images"echo "========================================================="fi
这个脚本将下载网络所需的特定二进制文件和镜像。执行成功后会生成bin和config。
bin文件:config文件:
拉取的镜像:
可以通过docker images命令查看