美文网首页Fabric
Hyperledger Fabric(一) 1.1.0环境搭建

Hyperledger Fabric(一) 1.1.0环境搭建

作者: yuyangray | 来源:发表于2018-03-20 15:32 被阅读198次

说明

没办法,现在网上的中文教程基本都是基于1.0.0版本,我看了下官方文档,差距蛮大,所以还是按着官方文档来吧!翻译和理解有误的话请评论,谢谢!

本文是基于Mac OS的环境搭建

官方关于准备阶段的安装介绍:
http://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html

安装 cURL

mac 环境中默认安装了curl:

yuyangdeMacBook-Pro:~ yuyang$ curl --version
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0

安装Docker

什么是Docker?
Docker的通俗解释

下载地址:https://store.docker.com/editions/community/docker-ce-desktop-mac

安装完成后查看版本信息,确认是否安装成功:

yuyangdeMacBook-Pro:~ yuyang$ docker version
Client:
 Version:   17.12.0-ce
 API version:   1.35
 Go version:    go1.9.2
 Git commit:    c97c6d6
 Built: Wed Dec 27 20:03:51 2017
 OS/Arch:   darwin/amd64

Server:
 Engine:
  Version:  17.12.0-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.2
  Git commit:   c97c6d6
  Built:    Wed Dec 27 20:12:29 2017
  OS/Arch:  linux/amd64
  Experimental: true
yuyangdeMacBook-Pro:~ yuyang$ docker-compose version
docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

安装Homebrew

使用Homebrew来安装Go,这里先安装Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装完成后查看版本信息,确认是否安装成功:

yuyangdeMacBook-Pro:~ yuyang$ brew -v
Homebrew 1.5.4
Homebrew/homebrew-core (git revision 68c5; last commit 2018-02-19)

安装Go语言

brew install go

安装完成后查看版本信息,确认是否安装成功:

yuyangdeMacBook-Pro:~ yuyang$ go version
go version go1.10 darwin/amd64

设置环境变量

首先检查之前是否设置过环境变量:

echo $GOPATH

如果显示:

/Users/xxx/go

说明之前设置过。

如果没有任何显示,则需要设置:

打开.bash_profile

yuyangdeMacBook-Pro:~ yuyang$ open .bash_profile

添加以下内容:

export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN

编译.bash_profile

yuyangdeMacBook-Pro:~ yuyang$ source .bash_profile

Node.js Runtime and NPM

NodeJs官网:https://nodejs.org/zh-cn/

Node.js version 9.x is not supported at this time.
Node.js- version 8.9.x or greater

官方说明现在不支持Node.js 9.x版本,建议使用8.9.x版本。

有关node安装以及版本管理的文章看这里

下载Hyperledger Fabric 源代码

进入之前为Go的环境变量设置的文件夹:

yuyangdeMacBook-Pro:~ yuyang$ cd /Users/yuyang/go 

使用git下载

git clone https://github.com/hyperledger/fabric.git

下载Hyperledger Fabric Samples 示例代码

新建目录

yuyangdeMacBook-Pro:~ yuyang$ mkdir fabric-sample
yuyangdeMacBook-Pro:~ yuyang$ cd fabric-sample

使用git下载

git clone -b master https://github.com/hyperledger/fabric-samples.git

进入目录

cd fabric-samples

为了确保刚才下载的samples与即将下载的Fabric binaries兼容,最好确认下samples当前的版本号。

查看当前的版本号序列

yuyangdeMacBook-Pro:fabric-samples yuyang$ git tag

版本号序列,现在最新的是v1.1.0-rc1

v1.0.2
v1.0.6
v1.1.0
v1.1.0-alpha
v1.1.0-preview
v1.1.0-rc1

git checkout {TAG}

yuyangdeMacBook-Pro:fabric-samples yuyang$ git checkout v1.1.0-rc1

下载安装二进制工具及镜像文件

yuyangdeMacBook-Pro:fabric-samples yuyang$ curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-rc1

这里可以通过替换Docker的镜像源地址来加速。

下载成功

yuyangdeMacBook-Pro:fabric-samples yuyang$ curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-rc1
===> Downloading platform specific fabric binaries
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 28.3M  100 28.3M    0     0  33272      0  0:14:51  0:14:51 --:--:-- 27614
===> Downloading platform specific fabric-ca-client binary
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 4473k  100 4473k    0     0   6800      0  0:11:13  0:11:13 --:--:-- 16667
===> Pulling fabric Images
==> FABRIC IMAGE: peer

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-peer
1be7f2b886e8: Pull complete 
6fbc4a21b806: Pull complete 
c71a6f8e1378: Pull complete 
4be3072e5a37: Pull complete 
06c6d2f59700: Pull complete 
4d536120d8a5: Pull complete 
0baaf9ec263e: Pull complete 
e74a3a99fe86: Pull complete 
c1815d6e0dbd: Pull complete 
df397132c393: Pull complete 
Digest: sha256:2cd593c5821b7b30997eebd87284d766501c1c98ba0838c6478fe45bb4ae9552
Status: Downloaded newer image for hyperledger/fabric-peer:x86_64-1.1.0-rc1
==> FABRIC IMAGE: orderer

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-orderer
1be7f2b886e8: Already exists 
6fbc4a21b806: Already exists 
c71a6f8e1378: Already exists 
4be3072e5a37: Already exists 
06c6d2f59700: Already exists 
4d536120d8a5: Already exists 
0baaf9ec263e: Already exists 
e74a3a99fe86: Already exists 
e87f5fb58ad0: Pull complete 
a31db65119a3: Pull complete 
Digest: sha256:fd5549b24c1ebd1b69ac9863aafe36220d9c554066ba48f49dc4bbb6cb8d7bdb
Status: Downloaded newer image for hyperledger/fabric-orderer:x86_64-1.1.0-rc1
==> FABRIC IMAGE: ccenv

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-ccenv
1be7f2b886e8: Already exists 
6fbc4a21b806: Already exists 
c71a6f8e1378: Already exists 
4be3072e5a37: Already exists 
06c6d2f59700: Already exists 
4d536120d8a5: Already exists 
0baaf9ec263e: Already exists 
3ea9b6cc6f21: Pull complete 
6173b9a5fe5e: Pull complete 
e73719e0bcbe: Pull complete 
b55408c6ced5: Pull complete 
4320b56d1fd5: Pull complete 
161da62af955: Pull complete 
154d29a2fc56: Pull complete 
Digest: sha256:62a9a37d3bb00fc945b9284eaf018d8a2f99eb6c80c400ac012a7d0f8b6cda92
Status: Downloaded newer image for hyperledger/fabric-ccenv:x86_64-1.1.0-rc1
==> FABRIC IMAGE: javaenv

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-javaenv
1be7f2b886e8: Already exists 
6fbc4a21b806: Already exists 
c71a6f8e1378: Already exists 
4be3072e5a37: Already exists 
06c6d2f59700: Already exists 
4d536120d8a5: Already exists 
0baaf9ec263e: Already exists 
3ea9b6cc6f21: Already exists 
6173b9a5fe5e: Already exists 
e73719e0bcbe: Already exists 
b55408c6ced5: Already exists 
0cb76bf18c52: Pull complete 
00e8d170d4d3: Pull complete 
a057c79fb691: Pull complete 
4f9f0d7df745: Pull complete 
6f2defea9bc0: Pull complete 
273773539a3e: Pull complete 
04569d868e5a: Pull complete 
8cd1a2bc9ab0: Pull complete 
Digest: sha256:ec7ba4d49f0f24c2e78d715b4ce6e0ece83f1bb9f655e1fba5689c5b6a85505d
Status: Downloaded newer image for hyperledger/fabric-javaenv:x86_64-1.1.0-rc1
==> FABRIC IMAGE: tools

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-tools
1be7f2b886e8: Already exists 
6fbc4a21b806: Already exists 
c71a6f8e1378: Already exists 
4be3072e5a37: Already exists 
06c6d2f59700: Already exists 
4d536120d8a5: Already exists 
0baaf9ec263e: Already exists 
3ea9b6cc6f21: Already exists 
6173b9a5fe5e: Already exists 
e73719e0bcbe: Already exists 
b55408c6ced5: Already exists 
dc72ffb63c77: Pull complete 
68c166b53a44: Pull complete 
6d1d8e9c19c1: Pull complete 
6e94cdba0791: Pull complete 
cf5d44fff6fe: Pull complete 
Digest: sha256:e80b049473792fe82c18418f2b06541b84ed7b0ccf90d24f61872773ecff4a72
Status: Downloaded newer image for hyperledger/fabric-tools:x86_64-1.1.0-rc1
===> Pulling fabric ca Image
==> FABRIC CA IMAGE

x86_64-1.1.0-rc1: Pulling from hyperledger/fabric-ca
1be7f2b886e8: Already exists 
6fbc4a21b806: Already exists 
c71a6f8e1378: Already exists 
4be3072e5a37: Already exists 
06c6d2f59700: Already exists 
4d536120d8a5: Already exists 
0baaf9ec263e: Already exists 
8379e4c08f5d: Pull complete 
db4cd8454ab5: Pull complete 
c08c6d07dd0e: Pull complete 
23385c4db996: Pull complete 
946161ef2f63: Pull complete 
Digest: sha256:fb458b405ea1aaf7570a10cc1f914de2ca5ddb683f13138e380c00d180683afc
Status: Downloaded newer image for hyperledger/fabric-ca:x86_64-1.1.0-rc1
===> Pulling thirdparty docker images
==> THIRDPARTY DOCKER IMAGE: couchdb

x86_64-0.4.6: Pulling from hyperledger/fabric-couchdb
8f7c85c2269a: Pull complete 
9e72e494a6dd: Pull complete 
3009ec50c887: Pull complete 
9d5ffccbec91: Pull complete 
e872a2642ce1: Pull complete 
9b84958a26b3: Pull complete 
68d4ced7ec19: Pull complete 
ff1d2b44d88d: Pull complete 
99e6a41c35bd: Pull complete 
87b2e4a0b9d2: Pull complete 
55f108d3ee4a: Pull complete 
9e76f6c2c001: Pull complete 
368be4b23f81: Pull complete 
581042703e1f: Pull complete 
18c50435ee69: Pull complete 
70dbffc27ecb: Pull complete 
31c35dd1bd00: Pull complete 
7571e6af230f: Pull complete 
9ef1e88f8344: Pull complete 
Digest: sha256:4278269b115cfd0f24251b5381407be9ccdf396c1470c69e1ee2ff16917ac882
Status: Downloaded newer image for hyperledger/fabric-couchdb:x86_64-0.4.6
==> THIRDPARTY DOCKER IMAGE: kafka

x86_64-0.4.6: Pulling from hyperledger/fabric-kafka
8f7c85c2269a: Already exists 
9e72e494a6dd: Already exists 
3009ec50c887: Already exists 
9d5ffccbec91: Already exists 
e872a2642ce1: Already exists 
9b84958a26b3: Already exists 
68d4ced7ec19: Already exists 
ff1d2b44d88d: Already exists 
99e6a41c35bd: Already exists 
87b2e4a0b9d2: Already exists 
55f108d3ee4a: Already exists 
76d29739374b: Pull complete 
8e29d2dddc78: Pull complete 
6bb3eb1b6cb1: Pull complete 
Digest: sha256:738bb79f02aa505a9ab0553a865122605ffba91d1b5de6eb0429f7287e83ac7c
Status: Downloaded newer image for hyperledger/fabric-kafka:x86_64-0.4.6
==> THIRDPARTY DOCKER IMAGE: zookeeper

x86_64-0.4.6: Pulling from hyperledger/fabric-zookeeper
8f7c85c2269a: Already exists 
9e72e494a6dd: Already exists 
3009ec50c887: Already exists 
9d5ffccbec91: Already exists 
e872a2642ce1: Already exists 
9b84958a26b3: Already exists 
68d4ced7ec19: Already exists 
ff1d2b44d88d: Already exists 
99e6a41c35bd: Already exists 
87b2e4a0b9d2: Already exists 
55f108d3ee4a: Already exists 
f876628e022b: Pull complete 
5e8448f14014: Pull complete 
c1ddd9fcc9fe: Pull complete 
cae637096fa7: Pull complete 
Digest: sha256:7fda667f6c39d6cb87125c132962fc3e434a8e6b2b16ee798d6fa94f970531a2
Status: Downloaded newer image for hyperledger/fabric-zookeeper:x86_64-0.4.6

===> List out hyperledger docker images
hyperledger/fabric-ca          latest              8a6c8c2e2ebf        2 weeks ago         283MB
hyperledger/fabric-ca          x86_64-1.1.0-rc1    8a6c8c2e2ebf        2 weeks ago         283MB
hyperledger/fabric-tools       latest              006c689ec08e        2 weeks ago         1.46GB
hyperledger/fabric-tools       x86_64-1.1.0-rc1    006c689ec08e        2 weeks ago         1.46GB
hyperledger/fabric-orderer     latest              10afc128d402        2 weeks ago         180MB
hyperledger/fabric-orderer     x86_64-1.1.0-rc1    10afc128d402        2 weeks ago         180MB
hyperledger/fabric-peer        latest              6b44b1d021cb        2 weeks ago         187MB
hyperledger/fabric-peer        x86_64-1.1.0-rc1    6b44b1d021cb        2 weeks ago         187MB
hyperledger/fabric-javaenv     latest              ea263125afb1        2 weeks ago         1.52GB
hyperledger/fabric-javaenv     x86_64-1.1.0-rc1    ea263125afb1        2 weeks ago         1.52GB
hyperledger/fabric-ccenv       latest              65c951b9681f        2 weeks ago         1.39GB
hyperledger/fabric-ccenv       x86_64-1.1.0-rc1    65c951b9681f        2 weeks ago         1.39GB
hyperledger/fabric-zookeeper   latest              92cbb952b6f8        3 weeks ago         1.39GB
hyperledger/fabric-zookeeper   x86_64-0.4.6        92cbb952b6f8        3 weeks ago         1.39GB
hyperledger/fabric-kafka       latest              554c591b86a8        3 weeks ago         1.4GB
hyperledger/fabric-kafka       x86_64-0.4.6        554c591b86a8        3 weeks ago         1.4GB
hyperledger/fabric-couchdb     latest              7e73c828fc5b        3 weeks ago         1.56GB
hyperledger/fabric-couchdb     x86_64-0.4.6        7e73c828fc5b        3 weeks ago         1.56GB

可以通过替换1.1.0-rc1来安装任何你想要安装的已发布的版本。

下载完成后,可以在bin文件夹下看到四个二进制工具:

  • cryptogen

  • configtxgen

  • configtxlator

  • peer, orderer and fabric-ca-client

可以使用以下命令将它们添加到环境变量:

export PATH=<path to download location>/bin:$PATH

最后,刚才的指令还会从Docker Hub上下载Fabric Docker的镜像文件,并将它们标识为latest

它们的存放位置在:

/Users/{YourUserName}/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

使用下面指令可以查看所有下载的Docker Images:

yuyangdeMacBook-Pro:~ yuyang$ docker images

相关文章

网友评论

    本文标题:Hyperledger Fabric(一) 1.1.0环境搭建

    本文链接:https://www.haomeiwen.com/subject/uljrqftx.html