1、安装docker

1.1卸载旧的版本

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
1.2下载需要的安装包

yum install -y yum-utils

1.3设置镜像的仓库

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo  #国外的地址
# 设置阿里云的Docker镜像仓库
yum-config-manager \
  --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  #国内的地址

1.4更新yum软件包索包

  yum makecache fast

1.5安装docker相关的配置

docker-ce 是社区版,docker-ee 企业版

yum install docker-ce docker-ce-cli containerd.io

1.6启动Docker

systemctl start docker

# 查看当前版本号,是否启动成功

docker version

# 设置开机自启动

systemctl enable docker

2.配置阿里云镜像

3.安装docker-compse

3.1安装:

sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compos

3.2授权:

# 将可执行权限应用于该二进制文件
sudo chmod +x /usr/local/bin/docker-compose

3.3测试:

#测试
docker-compose --version

4.安装go语言环境

4.1下载并安装Go语言环境

# cd /opt
# mkdir golang
# cd golang
# yum install wget
# wget https://studygolang.com/dl/golang/go1.14.3.linux-amd64.tar.gz
# tar -zxvf go1.14.3.linux-amd64.tar.gz

4.2配置Go语言环境变量

vi /etc/profile
#添加如下内容到/etc/profile后面
export GOPATH=/opt/gopath
export GOROOT=/opt/golang/go
export PATH=$GOROOT/bin:$PATH
#生效配置文件
source /etc/profile

5.安装git

yum -y install git

附带的插件方便查看

#方便查看层级关系
yum -y install tree
#高亮编辑
yum -y install vim-enhanced

6.Fabric安装

6.1创建生产目录

mkdir -p $GOPATH/src/github.com/hyperledger/
cd $GOPATH/src/github.com/hyperledger/

6.2通过git克隆源码:

git clone https://github.com/hyperledger/fabric.git  #优先
#若github下载太慢,可以将https改成git
git clone git://github.com/hyperledger/fabric.git  #(备选1)
#也可以用国内镜像
git clone https://github.com.cnpmjs.org/hyperledger/fabric.git #(备选2)
cd fabric

6.3切换分支

git checkout -b release-1.4 origin/release-1.4
#检查一下分支
git branch

6.4修改编译环境脚本bootstrap.sh

cd /opt/gopath/src/github.com/hyperledger/fabric/scripts
vim 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
VERSION=1.4.12
# if ca version not passed in, default to latest released version
CA_VERSION=1.4.9
ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m |sed 's/x86_64/amd64/g')" |sed 's/darwin-arm64/darwin-amd64/g')
MARCH=$(uname -m)

printHelp() {
    echo "Usage: bootstrap.sh [version [ca_version]] [options]"
    echo
    echo "options:"
    echo "-h : this help"
    echo "-d : bypass docker image download"
    echo "-s : bypass fabric-samples repo clone"
    echo "-b : bypass download of platform-specific binaries"
    echo
    echo "e.g. bootstrap.sh 2.4.3 1.5.3 -s"
    echo "will download docker images and binaries for Fabric v2.4.3 and Fabric CA v1.5.3"
}

# dockerPull() pulls docker images from fabric and chaincode repositories
# note, if a docker image doesn't exist for a requested release, it will simply
# be skipped, since this script doesn't terminate upon errors.

dockerPull() {
    #three_digit_image_tag is passed in, e.g. "1.4.7"
    three_digit_image_tag=$1
    shift
    #two_digit_image_tag is derived, e.g. "1.4", especially useful as a local tag for two digit references to most recent baseos, ccenv, javaenv, nodeenv patch releases
    two_digit_image_tag=$(echo "$three_digit_image_tag" | cut -d'.' -f1,2)
    while [[ $# -gt 0 ]]
    do
        image_name="$1"
        echo "====> hyperledger/fabric-$image_name:$three_digit_image_tag"
        docker pull "hyperledger/fabric-$image_name:$three_digit_image_tag"
        docker tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name"
        docker tag "hyperledger/fabric-$image_name:$three_digit_image_tag" "hyperledger/fabric-$image_name:$two_digit_image_tag"
        shift
    done
}

cloneSamplesRepo() {
    # clone (if needed) hyperledger/fabric-samples and checkout corresponding
    # version to the binaries and docker images to be downloaded
    if [ -d test-network ]; then
        # if we are in the fabric-samples repo, checkout corresponding version
        echo "==> Already in fabric-samples repo"
    elif [ -d fabric-samples ]; then
        # if fabric-samples repo already cloned and in current directory,
        # cd fabric-samples
        echo "===> Changing directory to fabric-samples"
        cd fabric-samples
    else
        echo "===> Cloning hyperledger/fabric-samples repo"
        git clone -b main https://github.com/hyperledger/fabric-samples.git && cd fabric-samples
    fi

if GIT_DIR=.git git rev-parse v${VERSION} >/dev/null 2>&1; then
        echo "===> Checking out v${VERSION} of hyperledger/fabric-samples"
        git checkout -q v${VERSION}
    else
        echo "fabric-samples v${VERSION} does not exist, defaulting to main. fabric-samples main branch is intended to work with recent versions of fabric."
        git checkout -q main
    fi
}

# This will download the .tar.gz
download() {
    local BINARY_FILE=$1
    local URL=$2
    echo "===> Downloading: " "${URL}"
    curl -L --retry 5 --retry-delay 3 "${URL}" | tar xz || rc=$?
    if [ -n "$rc" ]; then
        echo "==> There was an error downloading the binary file."
        return 22
    else
        echo "==> Done."
    fi
}

pullBinaries() {
    echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries"
    download "${BINARY_FILE}" "https://github.com/hyperledger/fabric/releases/download/v${VERSION}/${BINARY_FILE}"
    if [ $? -eq 22 ]; then
        echo
        echo "------> ${FABRIC_TAG} platform specific fabric binary is not available to download <----"
        echo
        exit
    fi

echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary"
    download "${CA_BINARY_FILE}" "https://github.com/hyperledger/fabric-ca/releases/download/v${CA_VERSION}/${CA_BINARY_FILE}"
    if [ $? -eq 22 ]; then
        echo
        echo "------> ${CA_TAG} fabric-ca-client binary is not available to download  (Available from 1.1.0-rc1) <----"
        echo
        exit
    fi
}

pullDockerImages() {
    command -v docker >& /dev/null
    NODOCKER=$?
    if [ "${NODOCKER}" == 0 ]; then
        FABRIC_IMAGES=(peer orderer ccenv tools)
        case "$VERSION" in
        2.*)
            FABRIC_IMAGES+=(baseos)
            shift
            ;;
        esac
        echo "FABRIC_IMAGES:" "${FABRIC_IMAGES[@]}"
        echo "===> Pulling fabric Images"
        dockerPull "${FABRIC_TAG}" "${FABRIC_IMAGES[@]}"
        echo "===> Pulling fabric ca Image"
        CA_IMAGE=(ca)
        dockerPull "${CA_TAG}" "${CA_IMAGE[@]}"
        echo "===> List out hyperledger docker images"
        docker images | grep hyperledger
    else
        echo "========================================================="
        echo "Docker not installed, bypassing download of Fabric images"
        echo "========================================================="
    fi
}

DOCKER=true
SAMPLES=true
BINARIES=true

# Parse commandline args pull out
# version and/or ca-version strings first
if [ -n "$1" ] && [ "${1:0:1}" != "-" ]; then
    VERSION=$1;shift
    if [ -n "$1" ]  && [ "${1:0:1}" != "-" ]; then
        CA_VERSION=$1;shift
        if [ -n  "$1" ] && [ "${1:0:1}" != "-" ]; then
            THIRDPARTY_IMAGE_VERSION=$1;shift
        fi
    fi
fi

# prior to 1.2.0 architecture was determined by uname -m
if [[ $VERSION =~ ^1\.[0-1]\.* ]]; then
    export FABRIC_TAG=${MARCH}-${VERSION}
    export CA_TAG=${MARCH}-${CA_VERSION}
    export THIRDPARTY_TAG=${MARCH}-${THIRDPARTY_IMAGE_VERSION}
else
    # starting with 1.2.0, multi-arch images will be default
    : "${CA_TAG:="$CA_VERSION"}"
    : "${FABRIC_TAG:="$VERSION"}"
    : "${THIRDPARTY_TAG:="$THIRDPARTY_IMAGE_VERSION"}"
fi

BINARY_FILE=hyperledger-fabric-${ARCH}-${VERSION}.tar.gz
CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH}-${CA_VERSION}.tar.gz

# then parse opts
while getopts "h?dsb" opt; do
    case "$opt" in
        h|\?)
            printHelp
            exit 0
            ;;
        d)  DOCKER=false
            ;;
        s)  SAMPLES=false
            ;;
        b)  BINARIES=false
            ;;
    esac
done

if [ "$SAMPLES" == "true" ]; then
    echo
    echo "Clone hyperledger/fabric-samples repo"
    echo
    cloneSamplesRepo
fi
if [ "$BINARIES" == "true" ]; then
    echo
    echo "Pull Hyperledger Fabric binaries"
    echo
    pullBinaries
fi
if [ "$DOCKER" == "true" ]; then
    echo
    echo "Pull Hyperledger Fabric docker images"
    echo
    pullDockerImages
fi

6.5启动相关的二进制

./boostrp.sh

下载相关的fabric的组件包括 tools,peer,orderer,baseos,ca,ccenv

6.6构建第一个区块链网络

#cd /opt/gopath/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network
#./byfn.sh -m generate 生产相关的证书

./byfn,sh -m up 启动测试网络。

出现这个页面表示启动成功了。

如何搭建Hyperledger fabric网络相关推荐

  1. 搭建Hyperledger Fabric网络

    注意:进行本文操作的前提是已完成Hyperledger Fabric的开发环境搭建,具体搭建步骤可参考[Hyperledger Fabric开发环境搭建(https://blog.csdn.net/y ...

  2. hyperledger fabric 网络操作基本操作和概念

    hyperledger fabric 网络操作基本操作和概念 hyperledger fabric 网络操作基本操作和概念 1. cryptogen 操作 1.1 cryptogen 生成证书文件 1 ...

  3. (Fabric 超级账本学习【5】)Fabric2.4网络环境下——搭建Hyperledger Fabric区块链浏览器

    博主最近在搭建Hyperledger Fabric区块链浏览器过程中也学习了很多博主的搭建流程,踩了很多雷,踩 了很多坑,现将成功搭建好的Hyperledger Fabric区块链浏览器详细流程分享如 ...

  4. Hyperledger Fabric网络环境手动配置及其链码自动化部署

    目录 5.1 网络环境的搭建 5.1.1 生成组织结构与身份证书 5.1.2 生成创世区块和通道 5.1.3 启动Fabric网络 5.1.4  创建Fabric-SDK-GO对象并建立通道 5.1. ...

  5. 在一台Ubuntu计算机上构建Hyperledger Fabric网络

    在一台Ubuntu计算机上构建Hyperledger Fabric网络 Hyperledger fabric是一个开源的区块链应用程序平台,为开发基于区块链的应用程序提供了一个起点.当我们提到Hype ...

  6. Linux搭建Hyperledger Fabric区块链框架 - Hyperledger Fabric模型概念

    企业选型的区块链底层技术 Hyperledger Fabric 概念 2015年,Linux基金会启动了Hyperledger项目,目标是发展跨行业的区块链技术. Hyperledger Fabric ...

  7. zookeeper 虚拟机搭建好后 外部链接不上_Ubuntu Server搭建Hyperledger Fabric 2.1学习环境...

    最近在学习Hyperledger Fabric,它是由 Linux 基金会发起创建的开源区块链分布式账本. Hyperledger Fabric是一个开源区块链实现,开发环境建立在 VirtualBo ...

  8. ubuntu18.04 快速搭建 Hyperledger Fabric超级账本框架

    这两天一直再配Hyperledger Fabric1.4的环境,找了很多资料,期间因为墙的原因找了很多博客的解决办法终于搭建成果,特此记录下来避免以后搭建出错. 文章目录 环境 步骤 1. ubunt ...

  9. 基于Debian搭建Hyperledger Fabric 2.4开发环境及运行简单案例

    前言 在基于truffle框架实现以太坊公开拍卖智能合约中我们已经实现了以太坊智能合约的编写及部署,但其工作方式注定其只能应用于有限的业务场景中.相比之下,基于超级账本的Fabric具有高可扩展性和高 ...

  10. Hyperledger Fabric 网络环境的一点理解

    Hyperledger Fabric 开发链码,一般都是测试网络开发,然后部署到生产网络. 下面介绍测试网络.生产网络的一点理解. 1 测试网络 使用cryptogen等工具建立测试网络,开发环境使用 ...

最新文章

  1. Apache Sentry架构介绍
  2. 如何启用 SAP Spartacus Guest checkout
  3. jquery weui 中alert弹出框在ios中跳动问题
  4. 计算机辅助设计基础学什么,东大计算机辅助设计基础X20秋学期《计算机辅助设计基础》在线平时作业3资料...
  5. cnn 验证集 参与训练吗_一个简单的零基础的机器学习教程之二,字母数字验证码识别...
  6. java作业 大蛇丸的召唤术 万蛇罗之阵 类与对象的演练
  7. python怎样创建桌面快捷方式_python创建桌面快捷方式的代码
  8. Linux下logrotate命令使用.配置和理解
  9. 教你打开线程、进程和协程的大门!
  10. 少儿编程家长疑问解答
  11. 哈夫曼树及哈夫曼编码例题
  12. CF802C Heidi and Library (hard) (网络流+最大流)
  13. 梁宁 产品30讲理解
  14. 笔记本安装系统不认硬盘?
  15. Windows 10用户档案无法加载的解决方法
  16. lenovo启动热键_联想启动热键
  17. 「星火计划沙龙视频」腾讯Caelus在离线混合部署方案揭秘
  18. 正则表达式 匹配中文,英文字母和数字及_长度详解
  19. DIV+CSS 鼠标样式,鼠标手型样式
  20. 使用电脑时经常遇到问题?来试试这四款小众的实用软件吧

热门文章

  1. 漫画算法:什么是跳跃表?
  2. 个人博客系统项目总结
  3. 【lstm预测】基于lstm实现时间序列数据预测matlab源码
  4. T1076 正常血压(信息学一本通C++)
  5. codelite交叉编译动态库学习记录
  6. 装系统时的UEFI模式
  7. 2020-12-28 微信支付二面
  8. pandas学习-变形-task15
  9. 淘宝买家秀后台操作与各场景展示逻辑
  10. 精进1-如何反思 by采铜