Hyperledger Fabric(v1.1.0)编译时遇到的问题

0. 编译过程的坑

编译时,按照如下顺序编译

  1. make release,编译源码生成二进制文件
  2. make docker,生成一系列的docker镜像

第一步没什么问题,第二部时会遇到一些问题,比如:

  • go get不能获取golang.org包的问题
  • docker中ubuntu官方镜像源不能访问或者太慢问题

1. go get不能获取golang.org包

在编译过程中,生成docker镜像时需要go相关的工具,github上的可以正常,但是golang.org的包由于墙的原因不能获取。尝试过设置全局代理、设置git代理,不过试了半天都没成功。

我的解决方法是:

  1. 首先在github上获取包的源码
  2. 然后只编译gotools,make gotools
  3. 将生成的可执行文件复制到fabric/build/docker/gotools/bin目录下

在fabric/gotools/Makefile文件中,可以看到编译时需要的golang依赖包。

go.fqp.govendor  := github.com/kardianos/govendor
go.fqp.golint := golang.org/x/lint/golint
go.fqp.goimports := golang.org/x/tools/cmd/goimports
go.fqp.ginkgo := github.com/onsi/ginkgo/ginkgo
go.fqp.gocov := github.com/axw/gocov/...
go.fqp.misspell := github.com/client9/misspell/cmd/misspell
go.fqp.gocov-xml:= github.com/AlekSi/gocov-xml
go.fqp.manifest-tool := github.com/estesp/manifest-tool

1.1 github上获取包的源码

在目录fabric/build/gopath/src下分别建立两个目录github.comgolang.org

进入golang.org目录获取包源码

mkdir x && cd x
git clone https://github.com/golang/tools.git
git clone https://github.com/golang/lint.git

进入github.com目录获取包源码

git clone https://github.com/kardianos/govendor.git
git clone https://github.com/onsi/ginkgo.git
git clone https://github.com/axw/gocov.git
git clone https://github.com/client9/misspell.git
git clone https://github.com/AlekSi/gocov-xml.git
git clone https://github.com/estesp/manifest-tool.git

1.2 编译gotools并复制可执行文件

make gotools编译go的工具。然后将将生成的可执行文件复制到fabric/build/docker/gotools/bin目录下。

2. docker官方镜像源修改

解决完上一个问题后,会卡在生成testenv的docker地方,原因是原有docker中的ubuntu镜像源是Ubuntu官方的,速度很慢或者根本不能访问,直接替换为阿里云的镜像源就好了。

首先定位生成docker的目录位置,是在fabric/build/testenv/目录下。该目录下的Dockerfile文件描述了该docker要做的东西。我们需要在这个文件中修改镜像源。

在文件中加入这三行:

# add by gexin, change the sources.list
COPY payload/sources.list /etc/apt/
RUN sudo apt-get update

修改后的文件内容如下:

# Copyright Greg Haskins All Rights Reserved
#
# SPDX-License-Identifier: Apache-2.0
#
FROM hyperledger/fabric-buildenv:x86_64-1.1.1-snapshot-feed00ad6 # fabric configuration locations
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric # add by gexin, change the sources.list
COPY payload/sources.list /etc/apt/
RUN sudo apt-get update # create needed directories
RUN mkdir -p \
$FABRIC_CFG_PATH \
/var/hyperledger/production # fabric configuration files
ADD payload/sampleconfig.tar.bz2 $FABRIC_CFG_PATH # fabric binaries
COPY payload/orderer /usr/local/bin
COPY payload/peer /usr/local/bin # softhsm2
COPY payload/install-softhsm2.sh /tmp
RUN bash /tmp/install-softhsm2.sh && rm -f install-softhsm2.sh # typically, this is mapped to a developer's dev environment
WORKDIR /opt/gopath/src/github.com/hyperledger/fabric
LABEL org.hyperledger.fabric.version=1.1.1-snapshot-feed00ad6 \
org.hyperledger.fabric.base.version=0.4.6

加入的三行就是我们用 自己的sources.list文件替换原有的文件。需要注意的是,这时我们还没有需要替换的文件呢。

在payload目录下,新建一个sources.list文件,在文件内容为阿里云的镜像源,如下所示:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse

总结

先是golang包的问题折腾了一下午,解决之后又遇到了镜像源的问题。

对golang以及docker的理解还不深入,需要继续在解决问题的过程中提高多这两个部分的认知。

Hyperledger Fabric(v1.1.0)编译时遇到的问题的更多相关文章

  1. Hyperledger Fabric(v1.2.0)代码分析1——channel创建

    Hyperledger Fabric(v1.2.0)代码分析1--channel创建 0. e2e_cli Hyperledger Fabric提供了一个e2e的例子,该例中创建了一个基础的区块链网络 ...

  2. 使用docker加载已有镜像安装Hyperledger Fabric v1.1.0

    背景 每次在新的服务器上安装Hyperledger Fabric网络时,通过fabric官方提供的脚本安装时,需要从网络上down下近10G的fabric相关镜像,这个过程是漫长及痛苦的,有时因网络问 ...

  3. Hyperledger Fabric v1.1.0安装记录(国内源版)

    1. 安装虚拟机     虚拟机软件采用:VirtualBox     操作系统选择:Ubuntu 14.04     内存:4G     CPU:2核     硬盘:20G     2.(可选)更改 ...

  4. 阿里云容器服务区块链解决方案全新升级 支持Hyperledger Fabric v1.1

    摘要: 全球开源区块链领域影响最为广泛的Hyperledger Fabric日前宣布了1.1版本的正式发布,带来了一系列丰富的新功能以及在安全性.性能与扩展性等方面的显著提升.阿里云容器服务区块链解决 ...

  5. 三、主流区块链技术特点及Hyperledger Fabric V1.0版本特点

    一.Hyperledger fabric V1.0 架构 1.逻辑架构: 2.区块链网络 3.运行时架构 二.架构总结 1.架构要点 分拆Peer的功能,将Blockchain的数据维护和共识服务进行 ...

  6. 安装hyperledger fabric V1.0.1

      安装文档位置: https://github.com/hyperledger/fabric   fabric代码托管地址 https://hyperledger-fabric.readthedoc ...

  7. 安装hyperledger fabric V1.0.0-beta

      安装文档位置: https://github.com/hyperledger/fabric   fabric代码托管地址 https://hyperledger-fabric.readthedoc ...

  8. Ubuntu下搭建Hyperledger Fabric v1.0环境

      多次尝试才正常启动了Fabric,如遇到各种莫名错误,请参考如下一步步严格安装,特别用户权限需要注意. 一.安装Ubuntu16 虚拟机或双系统,虚拟机有VirtualBox或者VMware,Ub ...

  9. 003-主流区块链技术特点及Hyperledger Fabric V1.0版本特点

    一.Hyperledger fabric V1.0 架构 1.逻辑架构: 2.区块链网络 3.运行时架构 二.架构总结 1.架构要点 分拆Peer的功能,将Blockchain的数据维护和共识服务进行 ...

随机推荐

  1. Python学习之路 (四)爬虫(三)HTTP和HTTPS

    HTTP和HTTPS HTTP协议(HyperText Transfer Protocol,超文本传输协议):是一种发布和接收 HTML页面的方法. HTTPS(Hypertext Transfer ...

  2. jenkins 调用 k8s api

    delete_old_images() { #删除以前的镜像,节省本地空间 if docker images | grep $javaname ; then docker rmi -f `docker ...

  3. JAVA构造MAP并初始化MAP

    第一种方法:static块初始化 public class Demo{ private static final Map<String, String> myMap; static { m ...

  4. JavaScript小例子

    1. alert.html <html> <head> <title></title> <script type="text/javas ...

  5. HDU 2602 Bone Collector(经典01背包问题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/O ...

  6. 01.创建winserver2012r2+hyper-v+centos7

    1.背景 DELL poweredge T320,装的winserver2012 r2,利用自带的hyper-v安装centos7,后期主要用于spark开发. 1.1 安装winserver2012 ...

  7. Golang设计模式—简单工厂模式(Simple Factory Pattern)

    Golang设计模式--简单工厂模式 背景 假设我们在做一款小型翻译软件,软件可以将德语.英语.日语都翻译成目标中文,并显示在前端. 思路 我们会有三个具体的语言翻译结构体,或许以后还有更多,但现在分 ...

  8. 重学Verilog(3)——参数化模块

    1.parameter方法 首先有这样一个模块 module half_adder(co,sum,a,b); output co,sum; input a,b; ; ; and #and_delay ...

  9. c++ STL总结

    https://blog.csdn.net/piaoxuezhong/article/details/54348787 http://net.pku.edu.cn/~yhf/UsingSTL.htm ...

  10. easybcd删除win10启动项如何恢复?

    制作windows启动盘: u盘启动 开始安装,选择左下角的"修复计算机": 运行命令 bcdboot c:\windows /l zh-cn 从系统盘C:\Windows目录中复 ...