从零构建Fabric开发运行环境手册(七):安装Fabric 1.4

Fabric开发运行环境安装手册目录如下:
从零构建Fabric开发运行环境手册(一):安装OS虚拟机(CentOS)
从零构建Fabric开发运行环境手册(二):安装Docker及Docker-Compose
从零构建Fabric开发运行环境手册(三):安装GO语言环境
从零构建Fabric开发运行环境手册(四):安装Libtool
从零构建Fabric开发运行环境手册(五):安装Node.js及npm【Linux安装指定二进制版本Node.js(内含卸载】
从零构建Fabric开发运行环境手册(六):安装Python
从零构建Fabric开发运行环境手册(七):安装Fabric 1.4
建议配合更详尽的原文(Commercial paper tutorial )来阅读本博文。

安装前的准备:安装git工具

由于需要从GitHub上下载源代码,建议安装git工具。

sudo yum -y install git

通过版本号查看命令可以确认是否正常安装完成。

git --version

输出例子:

[root@localhost ~]# git --version
git version 1.8.3.1

安装Fabric

1.下载Fabric-sample源代码

下载:
也可以访问https://github.com/hyperledger/fabric-samples,打包成zip文件进行下载。

#设置目录
GOPATH=/home/mark/golangwork
mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
#下载源码
git clone https://github.com/hyperledger/fabric-samples.git
# 列出所有tag
cd fabric-samples
git tag
# checkout 并切换到一个Tag,本次选择最新的v1.4.1-rc1
git checkout v1.4.1-rc1

注:如何顺利完成源程序下载?
目前国内下载github内容非常慢,平均在5-20kbytes/s之间,甚至也会速度太低导致下载失败 。作为对策,

  1. 推荐:参考ubuntu切换国内(清华)镜像源,彻底改善apt安装下载速度
  2. 使用下载工具下载。用浏览器访问github上对应的网页,选择合适的版本进行zip打包下载,下载完成后用ftp工具上传到对应文件夹。
  3. 使用代理。在条件允许的情况下使用SSR代理(我写的博客被屏,请自行谷歌),可以彻底改善下载速度。
  4. 减少下载量。clone的时候加上 --depth=1 参数,只让下载最新版本的源程序。像这样的:git clone https://github.com/hyperledger/fabric.git --depth=1 。

2. 下载fabric二进制程序

下载最新的fabric二进制程序。由于下载量大,这个过程需要花费较长的时间。

curl -sSL http://bit.ly/2ysbOFE | bash -s

注意:如果下载过程中出现问题,有可能是curl版本太老。从cURL下载网页下载升级到相应操作系统的最新版本。

下面的命令可以指定下载某个版本。

curl -sSL http://bit.ly/2ysbOFE | bash -s -- <fabric_version> <fabric-ca_version> <thirdparty_version>
curl -sSL http://bit.ly/2ysbOFE | bash -s -- 1.4.1 1.4.1 0.4.15
curl -sSL http://bit.ly/2ysbOFE | bash -s -- 1.4.4 1.4.4 0.4.18

这里是下载完成后的情况:

[root@localhost bin]# cd /root/golangwork/src/github.com/hyperledger/fabric-samples/bin
[root@localhost bin]# ll
total 175220
-rwxrwxr-x. 1 privoxy privoxy 20472336 Apr 11 23:46 configtxgen
-rwxrwxr-x. 1 privoxy privoxy 22615568 Apr 11 23:46 configtxlator
-rwxrwxr-x. 1 privoxy privoxy 13554768 Apr 11 23:46 cryptogen
-rwxrwxr-x. 1 privoxy privoxy 21542608 Apr 11 23:46 discover
-rwxrwxr-x. 1 privoxy privoxy 18181400 Apr 12 00:21 fabric-ca-client
-rwxrwxr-x. 1 privoxy privoxy 12188496 Apr 11 23:46 idemixgen
-rwxrwxr-x. 1 privoxy privoxy 32257920 Apr 11 23:46 orderer
-rwxrwxr-x. 1 privoxy privoxy 38595984 Apr 11 23:46 peer

3. 设置PATH

为了方便fabric工具的访问,需要设置一下PATH。
本次是下载到/root/golangwork/src/github.com/hyperledger/fabric-samples文件夹下的,所以设置如下:

export PATH=/root/golangwork/src/github.com/hyperledger/fabric-samples/bin:$PATH

补充

安装fabric二进制程序的时候,如果出现连接被重设的如下错误

$ sudo curl -sSL http://bit.ly/2ysbOFE | bash -s -- 1.4.1 1.4.1 0.4.15
curl: (56) Recv failure: Connection reset by peer

这种因为cURL工具版本太低导致的错误在CentOS基本不会出现。因为云服务器版的Ubuntu的cURL工具一直没有最新版本发布。这种情况下,请将脚本bootstrap.sh
下载到服务器上来执行这个安装。如果不指定版本参数,默认版本分别是,主版本1.4.4 CA版本:1.4.4 第三方版本:0.4.18。

sudo bash bootstrap.sh -s

也可以如下指定版本进行下载:

sudo bash bootstrap.sh 1.4.1 1.4.1 0.4.15 -s
sudo bash bootstrap.sh 1.4.3 1.4.3 0.4.17 -s

本文参考:

  1. fabric官网,V1.4安装说明:Install Samples, Binaries and Docker Images
  2. 《深度探索区块链:Hyperledger技术与应用》机械工业出版社 张增骏、董宁、朱轩彤、陈建雄著
  3. 区块链Hyperledger Fabric 学习记录(一)开发环境搭建
发布了73 篇原创文章 · 获赞 27 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/sitebus/article/details/90478865
1.4