Hyperledger Fabric BYFN 1: 基础环境配置及测试

fabric基础环境配置及测试

全程root权限执行

建议查看官方文档

  • 环境准备1
  • 安装样例、二进制文件和docker镜像2
  • 建立第一个网络3

最终环境

  • VPS: 阿里云服务器
  • OS: Ubuntu 16.04.4 LTS

docker和docker-compose

配置docker加速器

  • 从阿里云处获取docker容器镜像服务4
#创建docker目录
mkdir -p /etc/docker
#查看文件
ls /etc/docker
#配置daemon
vim daemon.json
#json内容
{
  "registry-mirrors": ["你的加速器地址"]
}
#启用
systemctl daemon-reload
systemctl restart docker

go-lang

注意对版本的需求,

  • fabric1.4要求Go version 1.11.x is required.
#解压安装包
cd /usr
mkdir go
tar -zxvf /usr/go go1.11.1.linux-amd64.tar.gz
#配置环境
vim /etc/profile
#文件末尾追加
export GOROOT=\usr\go
export GOPATH=$HOME\go
export GOBIN=$GOPATH\bin
export PATH=$PATH:$GOROOT\bin:$GOPATH\bin
#启用文件配置
source /etc/profile
#查看go配置
go env
#查看go版本,是否部署成功
go version

Node

If you will be developing applications for Hyperledger Fabric leveraging the Hyperledger Fabric SDK for Node.js, you will need to have version 8.9.x of Node.js installed.

安装NVM对node进行管理

根据教程对nvm进行安装5

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

## 启用环境配置
source ~/.profile
## 查看nvm版本
nvm --version
## 查看远端node版本

nvm ls-remote
## 安装8.9.4版本

安装node、npm

nvm install v8.9.4
## 查看版本信息
node -v
npm -v

下载registry

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

bootstrap

#进入脚本目录
cd fabric-samples/scipts
#下载二进制文件和docker镜像
./bootstrap.sh

测试网络环境

阿里云环境特殊修改

  • 需要将将Fabric的docker compose.yaml中的节点添加environment参数:
    GODEBUG=netdns=go
    • 问题原因:go的静态链接cgo错误所导致的SIGSEGV错误6
cd ~/fabric-samples/first-network
##修改cli内environment
vim docker-compose-cli.yaml
##修改其他节点environment
cd base
vim docker-compose-base.yaml

执行第一个程序

  • 执行测试

    cd ..
    ./byfn.sh up
    
  • 测试成功后可以查看docker相关镜像状态

    $docker ps
    
    CONTAINER ID        IMAGE                                                                                                  COMMAND                  CREATED              STATUS                    PORTS                                              NAMES
    f42657bb2b3a        dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab   "chaincode -peer.add…"   15 seconds ago       Up 14 seconds                                                                dev-peer1.org2.example.com-mycc-1.0
    c8e342777f36        dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9   "chaincode -peer.add…"   47 seconds ago       Up 46 seconds                                                                dev-peer0.org1.example.com-mycc-1.0
    309c0510102f        dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b   "chaincode -peer.add…"   About a minute ago   Up About a minute                                                            dev-peer0.org2.example.com-mycc-1.0
    0da1c6cc9967        hyperledger/fabric-tools:latest                                                                        "/bin/bash"              2 minutes ago        Up 2 minutes                                                                 cli
    7d9d7b9aab46        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes              0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
    f862405b0ae4        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes              0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
    9c9fcc64d326        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes              0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com
    c9bec3b3b354        hyperledger/fabric-peer:latest                                                                         "peer node start"        2 minutes ago        Up 2 minutes              0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com
    01d08e204373        hyperledger/fabric-orderer:latest                                                                      "orderer"                2 minutes ago        Up 2 minutes              0.0.0.0:7050->7050/tcp                             orderer.example.com
    
  • 清除记录

    ./byfn.sh down
    

  1. Docs » Getting Started » Prerequisites ↩︎

  2. Docs » Getting Started » Install Samples, Binaries and Docker Images ↩︎

  3. Docs » Tutorials » Building Your First Network ↩︎

  4. 容器镜像服务 ↩︎

  5. Node Version Manager - Simple bash script to manage multiple active node.js versions ↩︎

  6. 阿里云环境部署Hyperledger Fabric之SIGSEGV问题分析和解决经验分享 ↩︎

你可能感兴趣的:(hyperledger,fabric)