Fabric配置fabric-sample工程目录,并生成证书
Posted sanqima
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Fabric配置fabric-sample工程目录,并生成证书相关的知识,希望对你有一定的参考价值。
GitHub上的fabric-sample工程,默认只有源码,缺少CA工具和加密工具,它需要从其他地方下载CA工具和加密工具,这里以fabric v1.4.0为例进行说明。步骤如下:
1、下载fabric-sample v1.4.0源码
官网地址: fabric-sample v1.4.0
# 创建hyperleger目录
mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
# 克隆fabric-samples项目并切换到v1.4tag
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-samples
git checkout -b sample v1.4.0
2、下载fabric v1.4.0 CA工具
官网地址: fabric v1.4.0加密工具
wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/linux-amd64-1.4.0/hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz
3、下载fabric v1.4.0 加密工具
官网地址: fabric v1.4.0 CA工具
wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.4.0/hyperledger-fabric-linux-amd64-1.4.0.tar.gz
4、配置fabric-sample工程目录
# 将这2个工具解压到 fabric-samples目录下
tar zxvf hyperledger-fabric-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
tar zxvf hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
#向/etc/profile中写入环境变量
sudo echo 'export PATH=$GOPATH/src/github.com/hyperledger/fabric-samples/bin:$PATH' >> /etc/profile
#使环境变量生效
source /etc/profile
目录结构:
5、使用cryptogen生成证书
5.1 编写证书配置文件crypto-config.yaml
修改fabric-sample/first-network/crypto-config.yaml文件,
Order组织有2个成员: order、order2
Peer组织有2个成员: Org1、Org2
Org1有2个peer节点,1个User
Org2有2个peer节点,1个User
OrdererOrgs:
# ---------------------------------------------------------------------------
# Orderer
# ---------------------------------------------------------------------------
- Name: Orderer
Domain: example.com
Specs:
- Hostname: orderer
- Hostname: orderer2
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
# ---------------------------------------------------------------------------
# Org1
# ---------------------------------------------------------------------------
- Name: Org1
Domain: org1.example.com
EnableNodeOUs: true
Template:
Count: 2
Users:
Count: 1
# ---------------------------------------------------------------------------
# Org2
# ---------------------------------------------------------------------------
- Name: Org2
Domain: org2.example.com
EnableNodeOUs: true
Template:
Count: 2
Users:
Count: 1
5.2 根据yaml文件来生成证书
../bin/cryptogen generate --config=./crypto-config.yaml
以上是关于Fabric配置fabric-sample工程目录,并生成证书的主要内容,如果未能解决你的问题,请参考以下文章
区块链:Hyperledger Fabric环境配置及fabric-sample测试运行
区块链:Hyperledger Fabric-sample入门
区块链:Hyperledger Fabric-sample入门