HyperLeger Fabric项目概述
HyperLeger Fabric项目目标是实现一个通用的权限区块链的底层基础框架,为了适用于不同的场合,采用模块化架构提供可切换和可扩展的组件,包括共识算法、加密安全、数字资产、记录仓库、智能合约和身份鉴权等服务。
区块链项目对比
Fabric逻辑架构
Membership Services:会员注册、 份保护、内容保密、交易审计功能,以保证平台访问的安全性。
BlockChain Services:负责节点间的共识管理、账本的分布式计算、账本的存储以及节点间的P2P协议功能的实现,是区块链的核组成部分,为区块链的主体功能提供了底层撑。
ChainCode Services:ChainCode的集成平台,为ChainCode提供部署、运的环境。
Event Stream:贯穿于其他各个组件中间,为各个组件间的异步通信提供了技术实现。
Fabric运行时架构
Fabric网络
Fabric交易处理过程
Fabric Sample:Building Your First Network
1.CentOS docker安装
1.1.下载路径
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
1.2.docker安装
[root@huangzhenhua root]# cd /tmp/docker/docker
[root@huangzhenhua docker]# yum install docker-ce-17.09.1.ce-1.el7.centos.x86_64.rpm
1.3.检查是否安装成功
[root@huangzhenhua docker]# docker --version
1.4.docker启动和停止
[root@huangzhenhua docker]# systemctl start docker
[root@huangzhenhua docker]# systemctl stop docker
#systemctl restart docker
2.安装curl
[root@huangzhenhua docker]# yum install curl
3.docker-compose安装
3.1.安装
[root@huangzhenhua docker]# curl -L https://github.com/docker/compose/releases/download/1.19.0-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
[root@huangzhenhua docker]# chmod +x /usr/local/bin/docker-compose
3.2.检查是否安装成功
docker-compose --version
4.Go安装
4.1.Go下载路径
https://dl.gocn.io/
https://dl.gocn.io/golang/1.9.2/go1.9.2.linux-amd64.tar.gz
4.2.Go安装
[root@huangzhenhua docker]# tar -zxf go1.9.2.linux-amd64.tar.gz -C /usr/local/
4.3.Go环境配置
[root@huangzhenhua go]# vi /etc/profile
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/opt/gopath
[root@huangzhenhua go]# source /etc/profile
4.4.检查是否安装成功
[root@huangzhenhua go]# go version
5.Fabric源码下载
5.1.samples源码
https://github.com/hyperledger/fabric-samples
源码放置路径
cd /opt/gopath/src/github.com/hyperledger/fabric-samples
5.2.release源码
https://github.com/hyperledger/fabric
源码放置路径
/opt/gopath/src/github.com/hyperledger/fabric
5.3.拷贝fabric-release中的bootstrap-1.0.1.sh到fabric-samples,并运行
[root@huangzhenhua root]# cd /opt/gopath/src/github.com/hyperledger/fabric-samples
[root@huangzhenhua fabric-samples]# cp /opt/gopath/src/github.com/hyperledger/fabric/scripts/bootstrap-1.0.1.sh /opt/gopath/src/github.com/hyperledger/fabric-samples
[root@huangzhenhua fabric-samples]# ./bootstrap-1.0.1.sh
#否则运行./byfn.sh -m generate 报cryptogen tool not found. exiting错
运行成功后会生成bin目录
[root@huangzhenhua bin]# ls
configtxgen configtxlator cryptogen get-byfn.sh get-docker-images.sh orderer peer
6.启动Fabric
[root@huangzhenhua fabric-samples]# cd first-network/
[root@huangzhenhua first-network]# ./byfn.sh -m generate
[root@huangzhenhua first-network]# ./byfn.sh -m up
7.停止Fabric
[root@huangzhenhua first-network]# ./byfn.sh -m down
Next----> ChainCode