• Ubuntu下配置Hyperledger Fabric环境


    在win10系统的台式机上安装配置Hyperledger Fabric环境

    • 安装Ubuntu 16.04 双系统
      镜像下载地址:https://www.ubuntu.com/download/desktop
      安装教程:http://www.cnblogs.com/Duane/p/5424218.html
      注意:这里设置了/boot分区并作为启动引导器以保留win10系统的引导,注意分配大一点的空间(200M不够用),否则会导致apt-get无法使用等等一系列问题。

    • cURL

      sudo apt-get install curl
    • Git

      sudo apt-get install git
    • Node.js

      curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
      sudo apt-get install -y nodejs
    • Docker
      这里是根据官方文档https://docs.docker.com/install/linux/docker-ce/ubuntu/推荐的通过仓库下载的方法,注意用的源是Ubuntu16.04自带的source.list,如果更改了源很可能会安装失败。
      首先更新apt包索引:

      sudo apt-get update

      安装使用仓库所需要的相关包:

      sudo apt-get install 
          apt-transport-https 
          ca-certificates 
          curl 
          software-properties-common

      安装GPG key:

      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
      

      验证key的fingerprint是否为9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88:

          apt-key fingerprint 0EBFCD88

      安装仓库

      sudo add-apt-repository 
         "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
         $(lsb_release -cs) 
         stable"

      再次更新apt-get仓库信息并下载Docker CE

      sudo apt-get update
      sudo apt-get install docker-ce

      下载成功,为了方便,可以赋给当前用户(username)以docker的权限。(这一步需要切换到root用户再切换回来才能生效,或者注销)

      sudo usermod -aG docker username
    • Docker Compose
      安装前需要安装Python-pip。执行命令从github下载,并增加执行权限:

      curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
      chmod +x /usr/local/bin/docker-compose

      如果速度缓慢则从DaoClound下载

      curl -L https://get.daocloud.io/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
      sudo mv ~/docker-compose /usr/local/bin/docker-compose 
      chmod +x /usr/local/bin/docker-compose
    • Go
      apt-get下载版本太旧,所以使用wget从官网下载最新版本,保存路径为/usr/local

      sudo wget https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz
      sudo tar -C /usr/local -xzf go1.9.linux-amd64.tar.gz

      安装后需要配置环境变量:

      vim ~/.profile

      添加以下内容,其中GOROOT是安装路径,GOPATH是工作路径:

      export GOROOT=/usr/local/go 
      export PATH=$PATH:$GOROOT/bin 
      export GOPATH=$HOME/go 
      export PATH=$PATH:$GOPATH/bin

      将go的目录GOPATH放在用户目录~下,所以需要创建go目录:

      cd ~
      mkdir go
    • fabric源码
      首先需要创建对应的目录,然后在其中克隆下fabric的源码。这里注意,fabric源码中的一些工具需要通过Go语言编译,所以源码要克隆到GOPATH路径下,否则运行例子的时候会出现错误。

      mkdir -p ~/go/src/github.com/hyperledger
      cd ~/go/src/github.com/hyperledger 
      git clone https://github.com/hyperledger/fabric.git

      可以将代码切换到1.0.0版本

      cd fabric
      git checkout v1.0.0
    • fabric镜像下载
      执行项目中的脚本即可完成docker镜像的批量下载,参数可设置需要下载的镜像版本

      cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/
      source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0

      如果速度缓慢,可使用DaoCloud加速器:

      curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://6e4616d7.m.daocloud.io
    • 测试Fabric网络
      进入到e2e_cli目录后运行启动网络的脚本:

      ./network_setup.sh up

      如果出现错误显示缺少ltdl.h,则需要执行:

      sudo apt install libtool libltdl-dev

      该脚本执行后完成了以下任务:

      • 编译工具cryptogen并运行,基于crypto-config.yaml配置文件生成网络成员的密钥和证书;

      • 通过configtxgen工具,基于configtx.yaml配置文件生成创世区块和channel配置交易;

      • 基于docker-compose-cli.yaml配置文件启动容器,包括4Peer+1Orderer+1CLI;

      • CLI容器启动时会自动运行其中脚本scripts/script.sh,完成创建通道,将节点加入通道,安装Chaincode,实例化和执行相关Chaincode的任务。

      正常运行后关闭网络:

          ./network_setup.sh down

      注意:如果出现报错(比如在创建channel的过程中),需要在fabric目录下执行make clean,此时会删除清除编译信息并删除所有镜像,则需要从下载镜像步骤开始一步步执行,最终成功。

  • 相关阅读:
    PythonStudy——greenlet 协程
    PythonStudy——事件 Event
    PythonStudy——单线程并发的实现
    2015年的总结
    kylin一种OLAP的实现
    分布式消息队列的使用kakfa
    第一次听到了docker
    Hive分布式的数据仓库
    dubbo服务框架学习
    Storm实时计算框架的编程模式
  • 原文地址:https://www.cnblogs.com/zhayujie/p/12941561.html
Copyright © 2020-2023  润新知