fabric单机网络环境搭建(v2.2)

tech2022-09-07  118

fabric单机网络环境搭建(v2.2)

文章目录

fabric单机网络环境搭建(v2.2)一、介绍二、系统环境要求三、基础环境搭建1.docker环境搭建2.其它工具安装(git、golang) 四、拉取代码五、fabric单机网络环境搭建1、下载测试源码fabric-samples2、下载二进制文件3、 拉取镜像 六、单机网络测试

一、介绍

This project is an Active Hyperledger project. For more information on the history of this project see the Fabric wiki page. Information on what Active entails can be found in the Hyperledger Project Lifecycle document. Hyperledger Fabric is a platform for distributed ledger solutions, underpinned by a modular architecture delivering high degrees of confidentiality, resiliency, flexibility and scalability. It is designed to support pluggable implementations of different components, and accommodate the complexity and intricacies that exist across the economic ecosystem.

Hyperledger Fabric delivers a uniquely elastic and extensible architecture, distinguishing it from alternative blockchain solutions. Planning for the future of enterprise blockchain requires building on top of a fully-vetted, open source architecture; Hyperledger Fabric is your starting point.

github源码地址:

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

gitee极速镜像地址:

https://gitee.com/ryou5416/fabric.git

二、系统环境要求

操作系统内存CPU网络环境CentOS7.88G以上4核以上可访问互联网

三、基础环境搭建

1.docker环境搭建

docker环境搭建

2.其它工具安装(git、golang)

yum install -y git cd /opt mkdir golang cd golang wget https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz tar -zxvf go1.14.1.linux-amd64.tar.gz vim /etc/profile #追加gradle环境变量 export GRADLE_HOME=/home/gradle/gradle-6.5.1 export GRADLE_USER_HOME=/home/gradle/gradle_user_home export PATH=$PATH:$GRADLE_HOME/bin #追加golang环境变量 export GOPATH=/opt/gopath export GOROOT=/opt/golang/go export PATH=$GOROOT/bin:$PATH export FABRIC=$GOPATH/src/github.com/hyperledger/fabric source /etc/profile go version go env

四、拉取代码

mkdir -p $GOPATH/src/github.com/hyperledger cd $GOPATH/src/github.com/hyperledger git clone https://gitee.com/ryou5416/fabric.git

五、fabric单机网络环境搭建

cd $FABRIC/scripts vim bootstrap.sh

修改fabric-samples下载地址(使用gitee fork之后,再从gitee上拉取) 原地址 https://github.com/hyperledger/fabric-samples.git 改为 https://gitee.com/ryou5416/fabric-samples.git

下载镜像、测试源码fabric-samples二进制文件

初始化脚本 ./bootstrap.sh -dsb

参数说明:-d代表禁用pull镜像(已提取拉取) -s代表禁用pull源码 fabric-samples(可修改git地址为gitee) -b代表禁用拉取二进制文件(下载贼慢,使用https://d.serctl.com/网站委托下载)

1、下载测试源码fabric-samples

./bootstrap.sh -db

2、下载二进制文件

说明:github官网release包,使用迅雷都下不动,可以委托第三方网站下载https://d.serctl.com/。将下载好的二进制文件(版本号可查看初始化脚本bootstrap.sh得知,下载前务必确认)

hyperledger-fabric-linux-amd64-2.2.0.tar.gz

hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz

在$FABRIC/scripts/fabric-samples目录下解压二进制文件

cd bin rm -f * tar -zxvf hyperledger-fabric-linux-amd64-2.2.0.tar.gz tar -zxvf hyperledger-fabric-ca-linux-amd64-1.4.7.tar.gz

解压后bin目录下会多出一些可执行文件,会自动新建config目录,里面放有docker-compose容器编排配置文件,如图:

文件说明

configtxgen:用于生成 Fabric 创世区块初始或更新配置文件

configtxlator:用于编解码 Fabric 区块链配置文件

cryptogen:用于生成节点、用户、客户端等所需的证书和密钥文件

discover:用于 Fabric 网络的服务发现

orderer:Fabric 排序节点程序

peer:Fabric 对等节点程序

fabric-ca-client:Fabric CA 服务程序的客户端,用于注册和添加用户

3、 拉取镜像

说明:docker镜像文件较大,且没有断点续传,下载后需要确认是否全部下载镜像。

./bootstrap.sh -sb

备注:

在执行bootstrap.sh脚本时需要下载大量镜像文件,第一次下载好镜像文件后需将镜像文件备份,然后使用scp命令复制到其它节点。

#备份所有docker镜像 docker save $(docker images | grep -v REPOSITORY |grep -v "<none>" | awk 'BEGIN{OFS=":";ORS=" "}{print $1,$2}') -o all.tar #恢复所有docker镜像 docker load -i all.tar #备份单个docker镜像 docker save busybox:latest -o busybox.tar #恢复单个docker镜像 docker load -i busybox.tar

六、单机网络测试

#执行test-network网络测试案例 cd $FABRIC/scripts/fabric-samples/test-network #启动网络测试案例 ./network.sh up createChannel -ca -c mychannel -s couchdb #关闭通道和卸载镜像 ./network.sh down
最新回复(0)