Fabric学习笔记(一) - Fabric v1.0.5安装笔记

永不停歇的脚步 2019-06-26

操作系统

CENTOS 7

安装软件

1.基础软件安装

yum install -y docker docker-compose libtool golang m4

2.建立GO语言环境

vi ~/.bashrc

增加以下行

export GOPATH=/opt/gopath/

保存文件

source ~/.bashrc
mkdir –p /opt/gopath/
mkdir -p $GOPATH/src/github.com/hyperledger

3.fabric源码

下载fabric源代码

cd GOPATH/src/github.com/hyperledger
git clone -b release https://github.com/hyperledger/fabric.git

4.docker image 安装

镜像加速器

新增以下内容:
vi /etc/docker/daemon.json
{
 "registry-mirrors": ["https://d8b3zdiw.mirror.aliyuncs.com"]
}

保存并执行

sudo systemctl daemon-reload
sudo systemctl restart docker

docker image 下载

docker pull hyperledger/fabric-baseimage:x86_64-0.3.2
docker pull hyperledger/fabric-baseos:x86_64-0.3.2
docker pull hyperledger/fabric-tools:x86_64-1.0.5
docker pull hyperledger/fabric-kafka:x86_64-1.0.5
docker pull hyperledger/fabric-zookeeper:x86_64-1.0.5
docker pull hyperledger/fabric-orderer:x86_64-1.0.5
docker pull hyperledger/fabric-ccenv:x86_64-1.0.5

重命名镜像

docker tag hyperledger/fabric-baseimage:x86_64-0.3.2 hyperledger/fabric-baseimage
docker tag hyperledger/fabric-baseos:x86_64-0.3.2       hyperledger/fabric-baseos
docker tag hyperledger/fabric-tools:x86_64-1.0.5        hyperledger/fabric-tools
docker tag hyperledger/fabric-kafka:x86_64-1.0.5        hyperledger/fabric-kafka
docker tag hyperledger/fabric-zookeeper:x86_64-1.0.5    hyperledger/fabric-zookeeper
docker tag hyperledger/fabric-orderer:x86_64-1.0.5      hyperledger/fabric-orderer
docker tag hyperledger/fabric-ccenv:x86_64-1.0.5        hyperledger/fabric-ccenv

5.源码编译镜像

本章内容如果已经下载了镜像,则可以不用编译,仅作参考.

修改/opt/gopath/src/github.com/hyperledger/fabric/gotools/Makefile

[root@block-104 gotools]# git diff Makefile
diff --git a/gotools/Makefile b/gotools/Makefile
index 95b181e..e97467f 100644
--- a/gotools/Makefile
+++ b/gotools/Makefile
@@ -18,7 +18,7 @@ OBJDIR ?= build
 TMP_GOPATH=$(OBJDIR)/gopath
 GOBIN=$(abspath $(TMP_GOPATH)/bin)

-GOTOOLS = golint govendor goimports protoc-gen-go ginkgo gocov gocov-xml misspell
+GOTOOLS = protoc-gen-go#golint govendor goimports protoc-gen-go ginkgo gocov gocov-xml misspell
 GOTOOLS_BIN = $(patsubst %,$(GOBIN)/%, $(GOTOOLS))

 # go tool->path mapping

修改/opt/gopath/src/github.com/hyperledger/fabric/Makefile

[root@block-hubin-104 fabric]# git diff Makefile
diff --git a/Makefile b/Makefile
index 84dc529..5e74de7 100755
--- a/Makefile
+++ b/Makefile
@@ -82,7 +82,7 @@ PROJECT_FILES = $(shell git ls-files  | grep -v ^test | grep -v ^unit-test | \
        grep -v ^.git | grep -v ^examples | grep -v ^devenv | grep -v .png$ | \
        grep -v ^LICENSE )
 RELEASE_TEMPLATES = $(shell git ls-files | grep "release/templates")
-IMAGES = peer orderer ccenv javaenv buildenv testenv zookeeper kafka couchdb tools
+IMAGES = peer orderer ccenv tools
 RELEASE_PLATFORMS = windows-amd64 darwin-amd64 linux-amd64 linux-ppc64le linux-s390x
 RELEASE_PKGS = configtxgen cryptogen configtxlator peer orderer

@@ -96,7 +96,7 @@ pkgmap.cryptogen      := $(PKGNAME)/common/tools/cryptogen

 include docker-env.mk

-all: native docker checks
+all: native #docker checks

 checks: license spelling linter unit-test behave

@@ -221,7 +221,7 @@ build/docker/gotools: gotools/Makefile

 # Both peer and peer-docker depend on ccenv and javaenv (all docker env images it supports).
 build/bin/peer: build/image/ccenv/$(DUMMY) build/image/javaenv/$(DUMMY)
-build/image/peer/$(DUMMY): build/image/ccenv/$(DUMMY) build/image/javaenv/$(DUMMY)
+build/image/peer/$(DUMMY): build/image/ccenv/$(DUMMY) #build/image/javaenv/$(DUMMY)

 build/bin/%: $(PROJECT_FILES)
        @mkdir -p $(@D)

编译:

make docker

即可编译镜像
注意:编译过程可能有大量的下载属于GFW防火墙拦截范围,可能会有下载失败,如有碰到此类问题,请使用VPN代理翻墙等方式来解决

Fabric启动

cd /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli

执行

./network_setup.sh

即可生成一套简单的fabric网络
其中包含2个组织,具体详情请见End-to-End Flow

相关推荐

hyxinyu / 0评论 2020-04-27