使用hyperledger fabric

参考 https://www.cnblogs.com/zongmin/p/11635686.html

 

一、安装通用软件

我这里只是提下,具体的安装可以找其它的教程

1、安装git

2、安装python2

3、安装golang

在ubuntu18.04下系统安装的是1.6版本,版本低了

我参照了这个https://studygolang.com/articles/21132

4、安装docker和docker-compose

这里不能安装系统自带的版本

备注: apt install docker-cn版本在后面安装images时候出现问题,最好不要安装太新的版本。docker-ce/bionic,now 5:19.03.8~3-0~ubuntu-bionic amd64 [installed]。

docke镜像用docker-cn。在/etc/docker文件夹下新建daemon.json, 写入如下内容

{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/","https://hub-mirror.c.163.com","https://registry.docker-cn.com"]
}

重启docker服务

sudo service docker restart

记录:在windows的子系统ubuntu18.04上启动不了docker,报不能“failed to create NAT chain DOCKER”

要用系统管理员启动子系统

Using CMD (Administrator)
net stop LxssManager
net start LxssManager

 

二、安装fabric

1、新建hyperledger文件夹

cd ~/go/src/github.com/

mkdir hyperledger

cd hyperledger

2、拉取 fabric 的源码

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

3、执行安装脚本

fabric/scripts/bootstrap.sh 1.4.3 1.4.3 0.4.15

这个脚本

功能1:会git clone fabric-sample,并checkout v1.4.3

功能2、 下载hyperledger-fabric平台二进制包hyperledger-fabric

https://github.com/hyperledger/fabric/releases/download/v1.4.3/hyperledger-fabric-linux-amd64-1.4.3.tar.gz

记录:这个文件比较难下载,我手动下载的。用axel命令,后面接上面网址重定向后的网站。把hyperledger-fabric-linux-amd64-1.4.3.tar.gz拷贝到fabric-samples目录,解压就可以,它会在bin和config目录多些文件。

功能3、下载hyperledger-fabric-ca

https://github.com/hyperledger/fabric-ca/releases/download/v1.4.3/hyperledger-fabric-ca-linux-amd64-1.4.3.tar.gz

功能4、下载docker images: fabric-peer

hyperledger/fabric-peer:1.4.3

功能5、下载docker images: abric-orderer

hyperledger/fabric-orderer:1.4.3

 

记录:docker版本太高了,failed to register layer: Error processing tar file(exit status 1): remount /, flags: 0x84000: invalid argument

参考: https://blog.csdn.net/yysstrp/article/details/100136355

 

 

三、使用fabric

1、启动网络

cd ./fabric-samples/first-network/

./byfn.sh up

===================== Query successful on peer1.org2 on channel 'mychannel' =====================

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


_____ _ _ ____ 
| ____| | \ | | | _ \ 
| _| | \| | | | | | 
| |___ | |\ | | |_| | 
|_____| |_| \_| |____/

如果出现这个,就是建立自己的联盟链成功了,并且脚本交易测试成功。

记录:建立NAT网络失败,不知道是不是子系统的原因。

ERROR: Failed to Setup IP tables: Unable to enable NAT rule: (iptables failed: iptables --wait -t nat -I POSTROUTING -s 172.22.0.0/16 ! -o br-48225c15fd53 -j MASQUERADE: iptables: No chain/target/match by that name.
(exit status 1))

2、关闭网络

./byfn.sh down

记录:最后 最好把~/go/src/github.com/hyperledger/fabric-samples/bin添加到PATH中

 

posted on 2020-04-14 16:23  qq575654643  阅读(337)  评论(0编辑  收藏  举报