Hypterledger Fabric 1.4环境搭建

Github

fabric官方Github地址为: https://github.com/hyperledger/fabric

环境搭建流程
1. 环境依赖

依赖的软件版本根据安装的Fabric的版本差异而略有不同,具体请查看fabric的docs/source目录下的prereqs.rst。

1.1 注

本次配置使用的为阿里云主机,系统:CentOS Linux release 7.5.1804 (Core)

1.2 Git安装
yum install git
1.3 curl安装
yum install curl
1.4 docker安装
curl -fsSL https://get.docker.com/ | sh
注:docker版本不要太old
1.5 docker-compose安装
# 安装
curl -L https://get.daocloud.io/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# 增加可执行权限
chmod +x docker-compose
# 查看是否安装成功
docker-compose --version
1.6 go环境配置
# 下载安装包
wget https://dl.google.com/go/go1.11.11.linux-amd64.tar.gz
# 解压
tar xvf go1.11.11.linux-amd64.tar.gz
# 环境变量配置
[root@Muyi ~]# vi .bash_profile
增加以下两行
export GOPATH=/root/Muyi/Go/go
export PATH=$PATH:$GOPATH/bin
# 生效
source .bash_profile
# 查看是否安装成功
[root@Muyi ~]# go version
go version go1.11.11 linux/amd64
2. fabric
# 新建目录
[root@Muyi Muyi]# mkdir Fabric
# 拉取fabric源码
[root@Muyi Muyi]# git clone https://github.com/hyperledger/fabric.git
# 查看分支,切换到v1.4.3
[root@Muyi Muyi]# cd ./fabric
[root@Muyi Muyi]# git branch -a
[root@Muyi Muyi]# git checkout v1.4.3
3. fabric-samples
3.1 配置镜像加速器

这里选择的是阿里云的镜像加速器:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors,不配置镜像加速器下载速度很慢。

[root@Muyi Muyi]# sudo mkdir -p /etc/docker
[root@Muyi Muyi]# sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["你的加速器地址"]
}
EOF
[root@Muyi Muyi]# sudo systemctl daemon-reload
[root@Muyi Muyi]# sudo systemctl restart docker
3.2 拉取依赖
方法一:

可以在 fabric/scripts 目录下找到 bootstrap.sh 脚本,复制到与 fabric 同级目录下,执行脚本:

./bootstrap.sh 1.4.3 1.4.3 0.4.15

该脚本会帮你干很多事情:

  • 如果当前目录没有 hyperledger/fabric-samples,会从 github.com克隆 hyperledger/fabric-samples 存储库;
  • 使用 checkout 签出对应指定的版本标签;
  • 将指定版本的 Hyperledger Fabric 平台特定的二进制文件和配置文件安装到 fabric-samples 存储库的根目录中;
  • 下载指定版本的 Hyperledger Fabric Docker 镜像文件;
  • 将下载的 Docker 镜像文件标记为 “lastest"。
方法二:

其实查看bootstrap.sh文件可以发现整体的流程大致为三步:

  • ①:下载 fabric-samples 源码
  • ②:下载两个压缩包
  • ③:下载镜像文件

而方式一中经常会卡在下载二进制文件压缩包那里,这里我直接给出了这两个压缩包的网盘地址,可以先下载fabric-samples 源码后然后直接将这两个压缩包放在fabric-samples目录下解压即可,最后只需要执行下bootstrap.sh来下载镜像文件即可。

具体操作流程如下:
1. 下载 fabric-samples 源码
其实就是将 fabric-samples 源码克隆到当前目录下,并切换到指定版本:
[root@Muyi Muyi]# git clone https://github.com/hyperledger/fabric-samples.git
[root@Muyi Muyi]# cd ./fabric-samples
[root@Muyi Muyi]# git branch -a
[root@Muyi Muyi]# git checkout v1.4.3
2. 下载指定版本的 Hyperledger Fabric 平台特定的二进制文件和配置文件
官方地址:
https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.4.3/hyperledger-fabric-linux-amd64-1.4.3.tar.gz
https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/linux-amd64-1.4.3/hyperledger-fabric-ca-linux-amd64-1.4.3.tar.gz
网盘地址:
链接:https://pan.baidu.com/s/1h2IzGCtt9EzQDKGgf28bxA 
提取码:kej4
3. 下载 Docker镜像
首先编辑bootstrap.sh跳过前两个步骤,具体为
[root@Muyi Fabric]# vi bootstrap.sh
# 在文件末尾的samplesInstall和binariesInstall前加注释不执行即可
if [ "$SAMPLES" == "true" ]; then
  echo
  echo "Installing hyperledger/fabric-samples repo"
  echo
#  samplesInstall
fi
if [ "$BINARIES" == "true" ]; then
  echo
  echo "Installing Hyperledger Fabric binaries"
  echo
#  binariesInstall
:wq保存之后执行
[root@Muyi Fabric]# ./bootstrap.sh 1.4.3 1.4.3 0.4.15
3.3 配置环境变量

将fabric-samples目录下的bin目录配置到环境变量中即可,具体如下:

[root@Muyi ~]# vi .bash_profile
增加以下两行
export FABRICPATH=/root/Muyi/Fabric/fabric-samples
export PATH=$PATH:$FABRICPATH/bin
# 生效
source .bash_profile
# 查看是否配置成功
[root@Muyi ~]# fabric-ca-client version
fabric-ca-client:
 Version: 1.4.3
 Go version: go1.11.5
 OS/Arch: linux/amd64

网络测试
4.1 网络启动
# 进入到fabric-samples下的first-network目录下
# 启动网络
[root@Muyi first-network]# ./byfn.sh up
# 关闭网络
[root@Muyi first-network]# ./byfn.sh down
# 当看到以下的END时就代表启动成功
...
===================== Query successful on peer1.org2 on channel 'mychannel' ===================== 

========= All GOOD, BYFN execution completed =========== 


 _____   _   _   ____   
| ____| | \ | | |  _ \  
|  _|   |  \| | | | | | 
| |___  | |\  | | |_| | 
|_____| |_| \_| |____/  
5. Error
5.1 FAILED to execute End-2-End Scenario

问题描述:

在阿里云主机上部署测试时可能会出现下面的问题:
peer1.org1 failed to join the channel, Retry after 3 seconds
+ peer channel join -b mychannel.block
+ res=1
+ set +x
Error: error getting endorser client for channel: endorser client failed to connect to peer1.org1.example.com:8051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp: lookup peer1.org1.example.com: no such host"
!!!!!!!!!!!!!!! After 10 attempts, peer1.org1 has failed to join channel 'mychannel'  !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========

ERROR !!!! Test failed

解决方案
编辑/etc/resolv.conf:
nameserver 100.100.x.xxx
nameserver 100.100.x.xxx
#options timeout:2 attempts:3 rotate single-request-reopen
# 注释掉  options timeout:2 attempts:3 rotate single-request-reopen这一行即可
# 然后关闭后重新启动
[root@Muyi first-network]# ./byfn.sh down
[root@Muyi first-network]# ./byfn.sh up
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值