如何在Ubuntu 16.04 LTS中安装Hyperledger Fabric 1.2

SeanC52111 · · 814 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

注: 这里使用的是全新安装的ubuntu 16.04 LTS 操作系统。

  • 更新package:
sudo apt-get update

安装curl和软件包以设置Docker存储库

sudo apt-get install curl apt-transport-https ca-certificates software-properties-common
  • 添加Docker gpg key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • 校验gpg key
sudo apt-key fingerprint 0EBFCD88
  • 添加Docker 的存储(repository)
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  • 再一次更新package index
sudo apt-get update
  • 安装最新稳定版本的Docker
sudo apt-get install docker-ce
  • 检查Docker的版本
docker --version
  • 下载Docker Compose
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
  • 添加Docker Compose 二进制文件的执行权限
sudo chmod +x /usr/local/bin/docker-compose
  • 检查Docker Compose的对应版本
docker-compose --version

下载并配置Go语言的编程环境

注: 可以通过 https://golang.org/dl/ 来查看最新的稳定版本,并通过编辑 *.tar.gz来确定下载的二进制文件

curl -O https://storage.googleapis.com/golang/go1.10.3.linux-amd64.tar.gz
sha256sum go1.10.3.linux-amd64.tar.gz
tar -xvf go1.10.3.linux-amd64.tar.gz
sudo mv go /usr/local
  • 打开profile文件来设置Go的环境变量
sudo vim ~/.profile
  • 将以下内容添加到~/.profile 文件
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
  • 重新加载profile 文件
source ~/.profile

安装Node.js

注:这里我们需要站桩Ubuntu的一些packages,并且重新根据源代码编译Node.js因为Hyperledger 1.2 只支持Node.js 8.9+ <9的版本。

  • 再一次更新package index,安装一些必要的packages
sudo apt-get update
sudo apt-get install build-essential openssl libssl-dev pkg-config
  • 前往src目录,建立一个node文件夹,然后进入node文件夹
cd /usr/local/src
sudo mkdir node
cd node
  • 下载Node.js
sudo wget [https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz](https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz)
  • 解压缩tar文件,进入新建立的node-v8.9.3文件夹,然后make, make install命令
sudo tar zxvf node-v8.9.3.tar.gz
cd node-v8.9.3
sudo ./configure
sudo make
sudo make install
  • 查看Node.js的安装版本
node --version
  • 更新NPM版本
sudo npm install npm@5.6.0 -g
npm --version

下载Fabric的引导脚本bootstrap.sh

$ cd ~
$ mkdir hyperledger-fabric
$ cd hyperledger-fabric
$ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/release-1.2/scripts/bootstrap.sh -o bootstrap.sh
$ ls
bootstrap.sh
  • 执行引导脚本
    通过运行脚本去安装fabric,并且下载Fabric-sample,摘取docker镜像。
$ cd ~/hyperledger-fabric/
$ chmod 755 bootstrap.sh
$ sudo ./bootstrap.sh 1.2.0 1.2.0 0.4.10
  • 添加环境变量
$ vi ~/.bashrc
  • 增加下面的环境变量,保存并退出
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:/home/blockchain/hyperledger-fabric/fabric-samples/bin
  • 使环境变量生效
$ source ~/.bashrc
  • 检测环境变量是否成功
$ fabric-ca-client version
fabric-ca-client:
 Version: 1.2.0
 Go version: go1.10
 OS/Arch: linux/amd64

创建和管理网络

  • 执行./byfn.sh generate 命令生成相应的文件
$ cd ~/hyperledger-fabric/fabric-samples/first-network/
$ ./byfn.sh generate
Generating certs and genesis block for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] Y
proceeding ...
.......
  • 执行./byfn.sh up 启动网络
$ ./byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] Y
proceeding ...
LOCAL_VERSION=1.2.0
DOCKER_IMAGE_VERSION=1.2.0
Creating network "net_byfn" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating peer0.org2.example.com ... done
Creating orderer.example.com    ... done
Creating peer0.org1.example.com ... done
Creating peer1.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating cli                    ... done

 ____    _____      _      ____    _____ 
/ ___|  |_   _|    / \    |  _ \  |_   _|
\___ \    | |     / _ \   | |_) |   | |  
 ___) |   | |    / ___ \  |  _ <    | |  
|____/    |_|   /_/   \_\ |_| \_\   |_|  

Build your first network (BYFN) end-to-end test

Channel name : mychannel
Creating channel...
.......
  • 看到START,表示启动成功
  • 执行结束,显示END
  • 停止网络,执行./byfn.sh down
$ ./byfn.sh down
Stopping for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] Y
proceeding ...
Stopping cli                    ... done
Stopping peer0.org1.example.com ... done
Stopping peer1.org2.example.com ... done
Stopping orderer.example.com    ... done
Stopping peer1.org1.example.com ... done
Stopping peer0.org2.example.com ... done
Removing cli                    ... done
Removing peer0.org1.example.com ... done
Removing peer1.org2.example.com ... done
Removing orderer.example.com    ... done
Removing peer1.org1.example.com ... done
Removing peer0.org2.example.com ... done
Removing network net_byfn
Removing volume net_orderer.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_peer1.org1.example.com
Removing volume net_peer0.org2.example.com
Removing volume net_peer1.org2.example.com
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
Removing volume net_peer1.org3.example.com
WARNING: Volume net_peer1.org3.example.com not found.
7c129154a34a
3746b3295e48
d2cdb7e80c20
Untagged: dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab:latest
Deleted: sha256:af423f72155affe6f12819384004ffdbf3506274458e85ace79b85afa9f2edaf
Deleted: sha256:b3fbcd50f54c60d9454612a3ed2a01b0c4d060b27113fc1a9d1289647d43d0fe
Deleted: sha256:71212a99a5c510e8d4e06d998c9238f8aeab0d39b43585c0f592bcb783212115
Deleted: sha256:6a155ef7756a3361c3c549a4bb9bb8b9138ef53ebfada38d65dc00d874ebc5b6
Untagged: dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9:latest
Deleted: sha256:c4c8845cab7101ee6a4456ee544c4a6599c42bbca545b11045d6b47c1223f205
Deleted: sha256:f2f179f4758793728780f909833f710c71f40e77303bd64eb910d572a641c66b
Deleted: sha256:03f9cd5e163dc2fae818d7864f8f068330eb7e0b0709a34d40dfcf0e40bd5d43
Deleted: sha256:8747af4513550fd8f0f6cfd22c61fd531b073a1a733d02ff6e3fb97fb6def027
Untagged: dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b:latest
Deleted: sha256:2bffc21709916a8d9bd1c20a65134ac3ca31ef5cc6e1282cea3b6be28d295acb
Deleted: sha256:7cf57b3452456b8da30c08d92d0c054fe32b2c91cd047dc8075706af2c14dc0d
Deleted: sha256:6e5b8c88c9d03c7d776953ee8c1b638d02a60438130c9d174b99455bc43d07b8
Deleted: sha256:b9eee4e0944c3b35fec12aa4bb5624d02825ab12e71d8a6a73e3de9702831382

References


有疑问加站长微信联系(非本文作者)

本文来自:简书

感谢作者:SeanC52111

查看原文:如何在Ubuntu 16.04 LTS中安装Hyperledger Fabric 1.2

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

814 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传